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

Side by Side Diff: chrome/test/data/webui/settings/fake_bluetooth.js

Issue 1466433002: Add Settings bluetooth page test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chrome OS only Take 2 Created 4 years, 11 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview Fake implementation of chrome.bluetooth for testing.
7 */
8 cr.define('settings', function() {
9 /**
10 * Fake of the chrome.bluetooth API.
11 * @constructor
12 * @implements {Bluetooth}
13 */
14 function FakeBluetooth() {
15 /** @type {boolean} */ this.enabled = false;
16
17 /** @type {!Array<!chrome.bluetooth.Device>} */ this.devices = [];
18 }
19
20 FakeBluetooth.prototype = {
21 // Public testing methods.
22 /**
23 * @param {!Array<!chrome.bluetooth.Device>} devices
24 */
25 setDevicesForTest: function(devices) {
26 for (var d of this.devices)
27 this.onDeviceRemoved.callListeners(d);
28 this.devices = devices;
29 for (var d of this.devices)
30 this.onDeviceAdded.callListeners(d);
31 },
32
33 // Bluetooth overrides.
34 /** @override */
35 getAdapterState: function(callback) {
36 setTimeout(function() {
37 callback({
38 address: '00:11:22:33:44:55:66',
39 name: 'Fake Adapter',
40 powered: this.enabled,
41 available: true,
42 discovering: false
43 });
44 }.bind(this));
45 },
46
47 /** @override */
48 getDevice: assertNotReached,
49
50 /** @override */
51 getDevices: function(callback) {
52 setTimeout(function() {
53 callback(this.devices);
54 }.bind(this));
55 },
56
57 /** @override */
58 startDiscovery: assertNotReached,
59
60 /** @override */
61 stopDiscovery: assertNotReached,
62
63 /** @override */
64 onAdapterStateChanged: new FakeChromeEvent(),
65
66 /** @override */
67 onDeviceAdded: new FakeChromeEvent(),
68
69 /** @override */
70 onDeviceChanged: new FakeChromeEvent(),
71
72 /** @override */
73 onDeviceRemoved: new FakeChromeEvent(),
74 };
75
76 return {FakeBluetooth: FakeBluetooth};
77 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698