Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: third_party/WebKit/LayoutTests/bluetooth/server/connect/connection-fails.html

Issue 2727683003: bluetooth: Clean up connection errors (Closed)
Patch Set: merge Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script> 2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script> 3 <script src="../../../resources/testharnessreport.js"></script>
4 <script src="../../../resources/bluetooth/bluetooth-helpers.js"></script> 4 <script src="../../../resources/bluetooth/bluetooth-helpers.js"></script>
5 <script> 5 <script>
6 'use strict'; 6 'use strict';
7 // The following tests make sure the Web Bluetooth implementation 7 // The following tests make sure the Web Bluetooth implementation
8 // responds correctly to the different types of errors the 8 // responds correctly to the different types of errors the
9 // underlying platform might throw. 9 // underlying platform might throw.
10 10
11 // Each implementation maps these devices to specific code paths 11 // Each implementation maps these devices to specific code paths
12 // that result in different errors thus increasing code coverage 12 // that result in different errors thus increasing code coverage
13 // when testing. Therefore some of these devices might not be useful 13 // when testing. Therefore some of these devices might not be useful
14 // for all implementations. 14 // for all implementations.
15 15
16 let connection_test_specs = [{ 16 let connection_test_specs = [{
17 testName: 'Unknown error when connnecting.', 17 testName: 'Authentication canceled when connecting.',
18 uuid: errorUUID(0x0), 18 uuid: errorUUID(0x0),
19 error: new DOMException('Unknown error when connecting to the device.', 19 error: new DOMException('Authentication canceled.',
20 'NetworkError')
21 }, {
22 testName: 'Connection was already in progress.',
23 uuid: errorUUID(0x1),
24 error: new DOMException('Connection already in progress.',
25 'NetworkError')
26 }, {
27 testName: 'Connection failed.',
28 uuid: errorUUID(0x2),
29 error: new DOMException('Connection failed for unknown reason.',
30 'NetworkError') 20 'NetworkError')
31 }, { 21 }, {
32 testName: 'Authentication failed when connecting.', 22 testName: 'Authentication failed when connecting.',
33 uuid: errorUUID(0x3), 23 uuid: errorUUID(0x1),
34 error: new DOMException('Authentication failed.', 24 error: new DOMException('Authentication failed.',
35 'NetworkError') 25 'NetworkError')
36 }, { 26 }, {
37 testName: 'Authentication canceled when connecting.',
38 uuid: errorUUID(0x4),
39 error: new DOMException('Authentication canceled.',
40 'NetworkError')
41 }, {
42 testName: 'Authentication rejected when connecting.', 27 testName: 'Authentication rejected when connecting.',
43 uuid: errorUUID(0x5), 28 uuid: errorUUID(0x2),
44 error: new DOMException('Authentication rejected.', 29 error: new DOMException('Authentication rejected.',
45 'NetworkError') 30 'NetworkError')
46 }, { 31 }, {
47 testName: 'Authentication timed out when connecting.', 32 testName: 'Authentication timed out when connecting.',
33 uuid: errorUUID(0x3),
34 error: new DOMException('Authentication timeout.',
35 'NetworkError')
36 }, {
37 testName: 'Connection failed.',
38 uuid: errorUUID(0x4),
39 error: new DOMException('Connection failed for unknown reason.',
40 'NetworkError')
41 }, {
42 testName: 'Connection was already in progress.',
43 uuid: errorUUID(0x5),
44 error: new DOMException('Connection already in progress.',
45 'NetworkError')
46 }, {
47 testName: 'Unknown error when connnecting.',
48 uuid: errorUUID(0x6), 48 uuid: errorUUID(0x6),
49 error: new DOMException('Authentication timeout.', 49 error: new DOMException('Unknown error when connecting to the device.',
50 'NetworkError') 50 'NetworkError')
51 }, { 51 }, {
52 testName: 'Tried to connect to an unsupported device.', 52 testName: 'Tried to connect to an unsupported device.',
53 uuid: errorUUID(0x7), 53 uuid: errorUUID(0x7),
54 error: new DOMException('Unsupported device.', 54 error: new DOMException('Unsupported device.',
55 'NetworkError') 55 'NetworkError')
56 }, {
57 testName: 'A write operation exceeds the maximum length of the attribute.',
58 uuid: errorUUID(0x8),
59 error: new DOMException('Attribute length invalid.',
60 'NetworkError')
61 }, {
62 testName: 'A remote device connection is congested.',
63 uuid: errorUUID(0x9),
64 error: new DOMException('Connection congested.',
65 'NetworkError')
66 }, {
67 testName: 'Insufficient encryption for a given operation.',
68 uuid: errorUUID(0xa),
69 error: new DOMException('Insufficient encryption.',
70 'NetworkError')
71 }, {
72 testName: 'A read or write operation was requested with an invalid offset.',
73 uuid: errorUUID(0xb),
74 error: new DOMException('Offset invalid.',
75 'NetworkError')
76 }, {
77 testName: 'GATT read operation is not permitted.',
78 uuid: errorUUID(0xc),
79 error: new DOMException('Read not permitted.',
80 'NetworkError')
81 }, {
82 testName: 'The given request is not supported.',
83 uuid: errorUUID(0xd),
84 error: new DOMException('Request not supported.',
85 'NetworkError')
86 }, {
87 testName: 'GATT write operation is not permitted.',
88 uuid: errorUUID(0xe),
89 error: new DOMException('Write not permitted.',
90 'NetworkError')
91 }]; 56 }];
92 57
93 promise_test(() => { 58 promise_test(() => {
94 return setBluetoothFakeAdapter('FailingConnectionsAdapter') 59 return setBluetoothFakeAdapter('FailingConnectionsAdapter')
95 .then(() => { 60 .then(() => {
96 let test_promises = Promise.resolve(); 61 let test_promises = Promise.resolve();
97 connection_test_specs.forEach(testSpec => { 62 connection_test_specs.forEach(testSpec => {
98 test_promises = test_promises 63 test_promises = test_promises
99 .then(() => requestDeviceWithKeyDown({ 64 .then(() => requestDeviceWithKeyDown({
100 filters: [{services: [testSpec.uuid]}]})); 65 filters: [{services: [testSpec.uuid]}]}))
101 // This test was not returning the assert_promise_rejects_with_messa ge 66 .then(device => assert_promise_rejects_with_message(
102 // promise so when the underlying implementation of BluetoothDevice 67 device.gatt.connect(),
103 // changed no one noticed that the promise started to reject. 68 testSpec.error,
104 // Furthermore, no platform returns the new errors added so they 69 testSpec.testName));
105 // need to be cleaned up.
106 // TODO(ortuno): Re-enable the test when the errors are cleaned up.
107 // http://crbug.com/598341
108 // .then(device => assert_promise_rejects_with_message(
109 // device.gatt.connect(),
110 // testSpec.error,
111 // testSpec.testName));
112 }); 70 });
113 return test_promises; 71 return test_promises;
114 }); 72 });
115 }, 'Adapter fails to connect to device. Should reject with the correct ' + 73 }, 'Adapter fails to connect to device. Should reject with the correct ' +
116 'exception.'); 74 'exception.');
117 </script> 75 </script>
OLDNEW
« no previous file with comments | « extensions/common/api/bluetooth_private.idl ('k') | third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698