Chromium Code Reviews| 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..47debea08a718a450b28c3bd9623e5d0f59a7447 |
| --- /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({ |
|
dpapad
2015/11/20 18:05:22
Where is 'callback' defined? Should be passed as a
stevenjb
2015/11/20 18:28:16
Gah, yes. Done.
Need to closure working for tests
|
| + 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; |
| + callback(); |
| + }; |
| + |
| + 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(); |
| +}); |