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

Side by Side Diff: third_party/WebKit/LayoutTests/bluetooth/connect.html

Issue 1898263002: bluetooth: Separate connection tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-separate-tests-get-primary-service
Patch Set: Add name to test Created 4 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/bluetooth/connect/connectGATT.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/bluetooth/bluetooth-helpers.js"></script>
5 <script>
6 'use strict';
7
8 test(t => { assert_true(window.testRunner instanceof Object); t.done(); },
9 'window.testRunner is required for the following tests.');
10
11 promise_test(() => {
12 return setBluetoothFakeAdapter('HeartRateAdapter')
13 .then(() => requestDeviceWithKeyDown({
14 filters: [{services: ['heart_rate']}]}))
15 .then(device => {
16 return setBluetoothFakeAdapter('EmptyAdapter')
17 .then(() => assert_promise_rejects_with_message(
18 device.gatt.connect(),
19 new DOMException('Bluetooth Device is no longer in range.',
20 'NetworkError'),
21 'Device went out of range.'));
22 });
23 }, 'Device goes out of range. Reject with NetworkError.');
24
25 // The following tests make sure the Web Bluetooth implementation
26 // responds correctly to the different types of errors the
27 // underlying platform might throw.
28
29 // Each implementation maps these devices to specific code paths
30 // that result in different errors thus increasing code coverage
31 // when testing. Therefore some of these devices might not be useful
32 // for all implementations.
33 [{
34 testName: 'Unknown error when connnecting.',
35 uuid: errorUUID(0x0),
36 error: new DOMException('Unknown error when connecting to the device.',
37 'NetworkError')
38 }, {
39 testName: 'Connection was already in progress.',
40 uuid: errorUUID(0x1),
41 error: new DOMException('Connection already in progress.',
42 'NetworkError')
43 }, {
44 testName: 'Connection failed.',
45 uuid: errorUUID(0x2),
46 error: new DOMException('Connection failed for unknown reason.',
47 'NetworkError')
48 }, {
49 testName: 'Authentication failed when connecting.',
50 uuid: errorUUID(0x3),
51 error: new DOMException('Authentication failed.',
52 'NetworkError')
53 }, {
54 testName: 'Authentication canceled when connecting.',
55 uuid: errorUUID(0x4),
56 error: new DOMException('Authentication canceled.',
57 'NetworkError')
58 }, {
59 testName: 'Authentication rejected when connecting.',
60 uuid: errorUUID(0x5),
61 error: new DOMException('Authentication rejected.',
62 'NetworkError')
63 }, {
64 testName: 'Authentication timed out when connecting.',
65 uuid: errorUUID(0x6),
66 error: new DOMException('Authentication timeout.',
67 'NetworkError')
68 }, {
69 testName: 'Tried to connect to an unsupported device.',
70 uuid: errorUUID(0x7),
71 error: new DOMException('Unsupported device.',
72 'NetworkError')
73 }, {
74 testName: 'A write operation exceeds the maximum length of the attribute.',
75 uuid: errorUUID(0x8),
76 error: new DOMException('Attribute length invalid.',
77 'NetworkError')
78 }, {
79 testName: 'A remote device connection is congested.',
80 uuid: errorUUID(0x9),
81 error: new DOMException('Connection congested.',
82 'NetworkError')
83 }, {
84 testName: 'Insufficient encryption for a given operation.',
85 uuid: errorUUID(0xa),
86 error: new DOMException('Insufficient encryption.',
87 'NetworkError')
88 }, {
89 testName: 'A read or write operation was requested with an invalid offset.',
90 uuid: errorUUID(0xb),
91 error: new DOMException('Offset invalid.',
92 'NetworkError')
93 }, {
94 testName: 'GATT read operation is not permitted.',
95 uuid: errorUUID(0xc),
96 error: new DOMException('Read not permitted.',
97 'NetworkError')
98 }, {
99 testName: 'The given request is not supported.',
100 uuid: errorUUID(0xd),
101 error: new DOMException('Request not supported.',
102 'NetworkError')
103 }, {
104 testName: 'GATT write operation is not permitted.',
105 uuid: errorUUID(0xe),
106 error: new DOMException('Write not permitted.',
107 'NetworkError')
108 }].forEach(testSpec => {
109 promise_test(() => {
110 return setBluetoothFakeAdapter('FailingConnectionsAdapter')
111 .then(() => requestDeviceWithKeyDown({
112 filters: [{services: [testSpec.uuid]}]}))
113 // This test was not returning the assert_promise_rejects_with_message
114 // promise so when the underlying implementation of BluetoothDevice
115 // changed no one noticed that the promise started to reject.
116 // Furthermore, no platform returns the new errors added so they
117 // need to be cleaned up.
118 // TODO(ortuno): Re-enable the test when the errors are cleaned up.
119 // http://crbug.com/598341
120 // .then(device => assert_promise_rejects_with_message(
121 // device.gatt.connect(),
122 // testSpec.error,
123 // 'Adapter failed to connect to device.'))
124 }, testSpec.testName);
125 });
126
127 promise_test(() => {
128 return setBluetoothFakeAdapter('HeartRateAdapter')
129 .then(() => requestDeviceWithKeyDown({
130 filters: [{services: ['heart_rate']}]}))
131 .then(device => device.gatt.connect())
132 .then(gattServer => assert_true(gattServer.connected));
133 }, 'Device will connect');
134
135 promise_test(() => {
136 return setBluetoothFakeAdapter('HeartRateAdapter')
137 .then(() => requestDeviceWithKeyDown({
138 filters: [{services: ['heart_rate']}]}))
139 .then(device => {
140 return Promise.all([device.gatt.connect(), device.gatt.connect()])
141 }).then(gattServers => {
142 assert_equals(gattServers[0], gattServers[1]);
143 });
144 });
145
146 // TODO(ortuno): Remove connectGATT in M52.
147 // http://crbug.com/582292
148 promise_test(() => {
149 return setBluetoothFakeAdapter('HeartRateAdapter')
150 .then(() => requestDeviceWithKeyDown({
151 filters: [{services: ['heart_rate']}]}))
152 .then(device => device.connectGATT())
153 }, 'Make sure deprecated method is still usable.')
154 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/bluetooth/connect/connectGATT.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698