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

Side by Side Diff: LayoutTests/bluetooth/getPrimaryService.html

Issue 1152393002: bluetooth: Blink side implementation of getPrimaryService (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@bluetooth-get-primary-service-interface
Patch Set: Add BluetoothGATTService to webexposed layout test Created 5 years, 6 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 | LayoutTests/webexposed/global-interface-listing-expected.txt » ('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="bluetooth-helpers.js"></script>
5 <script>
6 test(function(t) { assert_exists(window, "testRunner"); t.done(); },
7 "window.testRunner is required for the following tests.");
8
9 var generic_access = "00001800-0000-1000-8000-00805f9b34fb";
10 var heart_rate = "0000180D-0000-1000-8000-00805f9b34fb";
11
12 sequential_promise_test(function() {
13 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
14 return navigator.bluetooth.requestDevice().then(function(device) {
15 return device.connectGATT();
16 }).then(function(gattServer) {
17 testRunner.setBluetoothMockDataSet('EmptyAdapter');
18 return gattServer.getPrimaryService(generic_access).then(function() {
19 assert_unreached('Should return error if device not in adapter.');
20 }, function(e) {
21 assert_equals(e.name, "NetworkError");
22 });
23 });
24 }, 'Device goes out of range. Reject with NetworkError.');
25
26 sequential_promise_test(function() {
27 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
28 return navigator.bluetooth.requestDevice().then(function(device) {
29 return device.connectGATT();
30 }).then(function(gattServer) {
31 return gattServer.getPrimaryService(heart_rate);
32 }).then(function(service) {
33 assert_equals(service, null,
34 "Non existent services should return null.");
35 });
36 }, 'Request for wrong service. Should return null.');
37
38 sequential_promise_test(function() {
39 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
40 return navigator.bluetooth.requestDevice().then(function(device) {
41 return device.connectGATT();
42 }).then(function(gattServer) {
43 return gattServer.getPrimaryService(generic_access);
44 }).then(function(service) {
45 assert_equals(service.uuid, generic_access,
46 "Service UUID should be the same as requested UUID.");
47 assert_true(service.isPrimary,
48 "getPrimaryService should return a primary service.");
49 });
50 }, 'Request for service. Should return right service');
51
52 sequential_promise_test(function() {
53 testRunner.setBluetoothMockDataSet('ConnectableDeviceAdapter');
54 return navigator.bluetooth.requestDevice().then(function(device) {
55 return device.connectGATT();
56 }).then(function(gattServer) {
57 return Promise.all([gattServer.getPrimaryService(generic_access),
58 gattServer.getPrimaryService(generic_access)]);
59 }).then(function(services) {
60 // getPrimaryService should return the same object if it was created
61 // earlier. https://crbug.com/495270
62 // TODO(ortuno): Change to assert_equals.
63 assert_not_equals(services[0], services[1],
64 "Should return the same service as the first call.");
65 });
66 }, 'Calls to get the same service should return the same object.');
67
68 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698