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..ff1cd91b0ff5953c0bfbe7625fe7b39649d1f306 |
| --- /dev/null |
| +++ b/chrome/test/data/webui/settings/bluetooth_page_browsertest.js |
| @@ -0,0 +1,63 @@ |
| +// 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. */ |
| + |
| +// Polymer BrowserTest fixture. |
|
michaelpg
2015/11/20 15:08:17
comment
stevenjb
2015/11/20 17:47:40
removed
|
| +GEN_INCLUDE(['settings_page_browsertest.js']); |
| + |
| +/** |
| + * @constructor |
| + * @extends {PolymerTest} |
|
michaelpg
2015/11/20 15:08:17
extends SPBT
stevenjb
2015/11/20 17:47:41
Done.
|
| +*/ |
| +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; |
| + |
| + self.enabled_ = false; |
|
dpapad
2015/11/19 23:12:32
Nit: How about turning enabled into a simple local
stevenjb
2015/11/20 17:47:40
Done.
|
| + |
| + chrome.bluetooth.getAdapterState = function() { |
|
michaelpg
2015/11/20 15:08:17
shouldn't this take a callback?
if this is passin
stevenjb
2015/11/20 17:47:41
Yes it should. Done.
The test is passing because
|
| + return { |
| + address: '00:11:22:33:44:55:66', |
| + name: 'Fake Adapter', |
| + powered: self.enabled_, |
| + available: true, |
| + discovering: false |
| + }; |
| + }; |
| + |
| + chrome.bluetoothPrivate.setAdapterState = function(state, callback) { |
| + self.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'); |
|
michaelpg
2015/11/20 15:08:17
$$ because getSection returns a SettingsSection.
stevenjb
2015/11/20 17:47:40
I changed the return types, but $$ doesn't work be
michaelpg
2015/11/20 18:46:37
Acknowledged.
|
| + assertTrue(!!bluetooth); |
| + var enable = bluetooth.$$('#enableBluetooth'); |
|
michaelpg
2015/11/20 15:08:17
bluetooth.$.enableBluetooth
stevenjb
2015/11/20 17:47:40
Done.
|
| + assertTrue(!!enable); |
| + assertFalse(self.enabled_); |
| + expectFalse(enable.checked); |
| + MockInteractions.tap(enable); |
| + expectTrue(enable.checked); |
| + expectTrue(self.enabled_); |
| + }); |
| + }); |
| + |
| + // Run all registered tests. |
| + mocha.run(); |
| +}); |