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

Unified 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 5 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/settings/fake_bluetooth.js
diff --git a/chrome/test/data/webui/settings/fake_bluetooth.js b/chrome/test/data/webui/settings/fake_bluetooth.js
new file mode 100644
index 0000000000000000000000000000000000000000..64e646eb1bea8884a0f28dee665b109faed7f9e1
--- /dev/null
+++ b/chrome/test/data/webui/settings/fake_bluetooth.js
@@ -0,0 +1,77 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview Fake implementation of chrome.bluetooth for testing.
+ */
+cr.define('settings', function() {
+ /**
+ * Fake of the chrome.bluetooth API.
+ * @constructor
+ * @implements {Bluetooth}
+ */
+ function FakeBluetooth() {
+ /** @type {boolean} */ this.enabled = false;
+
+ /** @type {!Array<!chrome.bluetooth.Device>} */ this.devices = [];
+ }
+
+ FakeBluetooth.prototype = {
+ // Public testing methods.
+ /**
+ * @param {!Array<!chrome.bluetooth.Device>} devices
+ */
+ setDevicesForTest: function(devices) {
+ for (var d of this.devices)
+ this.onDeviceRemoved.callListeners(d);
+ this.devices = devices;
+ for (var d of this.devices)
+ this.onDeviceAdded.callListeners(d);
+ },
+
+ // Bluetooth overrides.
+ /** @override */
+ getAdapterState: function(callback) {
+ setTimeout(function() {
+ callback({
+ address: '00:11:22:33:44:55:66',
+ name: 'Fake Adapter',
+ powered: this.enabled,
+ available: true,
+ discovering: false
+ });
+ }.bind(this));
+ },
+
+ /** @override */
+ getDevice: assertNotReached,
+
+ /** @override */
+ getDevices: function(callback) {
+ setTimeout(function() {
+ callback(this.devices);
+ }.bind(this));
+ },
+
+ /** @override */
+ startDiscovery: assertNotReached,
+
+ /** @override */
+ stopDiscovery: assertNotReached,
+
+ /** @override */
+ onAdapterStateChanged: new FakeChromeEvent(),
+
+ /** @override */
+ onDeviceAdded: new FakeChromeEvent(),
+
+ /** @override */
+ onDeviceChanged: new FakeChromeEvent(),
+
+ /** @override */
+ onDeviceRemoved: new FakeChromeEvent(),
+ };
+
+ return {FakeBluetooth: FakeBluetooth};
+});

Powered by Google App Engine
This is Rietveld 408576698