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

Unified Diff: chrome/test/data/webui/settings/bluetooth_page_browsertest.js

Issue 1466433002: Add Settings bluetooth page test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More feedback Created 5 years, 1 month 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/bluetooth_page_browsertest.js
diff --git a/chrome/test/data/webui/settings/bluetooth_page_browsertest.js b/chrome/test/data/webui/settings/bluetooth_page_browsertest.js
new file mode 100644
index 0000000000000000000000000000000000000000..8b073a624623c8e2e655da76c5a7dbadecf98b68
--- /dev/null
+++ b/chrome/test/data/webui/settings/bluetooth_page_browsertest.js
@@ -0,0 +1,62 @@
+// 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 Suite of tests for settings-bluetooth-page. */
+
+GEN_INCLUDE(['settings_page_browsertest.js']);
+
+/**
+ * @constructor
+ * @extends {SettingsPageBrowserTest}
+*/
+function SettingsBluetoothPageBrowserTest() {}
+
+SettingsBluetoothPageBrowserTest.prototype = {
+ __proto__: SettingsPageBrowserTest.prototype,
+};
+
+// Runs bluetooth tests.
+TEST_F('SettingsBluetoothPageBrowserTest', 'Bluetooth', function() {
+ // Assign |self| to |this| instead of binding since 'this' in suite()
+ // and test() will be a Mocha 'Suite' or 'Test' instance.
+ var self = this;
+
+ var enabled = false;
+
+ chrome.bluetooth.getAdapterState = function(callback) {
+ setTimeout(callback({
+ address: '00:11:22:33:44:55:66',
+ name: 'Fake Adapter',
+ powered: enabled,
+ available: true,
+ discovering: false
+ }));
+ };
+
+ chrome.bluetoothPrivate.setAdapterState = function(state, callback) {
+ enabled = state.powered;
+ setTimeout(callback());
michaelpg 2015/11/24 15:55:49 Did you mean this without the parens, so "callback
stevenjb 2015/11/24 17:04:50 Doh. Yes. I think the other one is wrong too. Isn'
+ };
+
+ suite('SettingsBluetoothPage', function() {
+ test('enable', function() {
+ var bluetoothSection =
+ self.getSection(self.getPage('advanced'), 'bluetooth');
+ assertTrue(!!bluetoothSection);
+ var bluetooth =
+ bluetoothSection.querySelector('settings-bluetooth-page');
+ assertTrue(!!bluetooth);
+ var enable = bluetooth.$.enableBluetooth;
+ assertTrue(!!enable);
+ assertFalse(enabled);
+ expectFalse(enable.checked);
+ MockInteractions.tap(enable);
+ expectTrue(enable.checked);
+ expectTrue(enabled);
+ });
+ });
+
+ // Run all registered tests.
+ mocha.run();
+});

Powered by Google App Engine
This is Rietveld 408576698