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

Side by Side 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 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 /** @fileoverview Suite of tests for settings-bluetooth-page. */
6
7 GEN_INCLUDE(['settings_page_browsertest.js']);
8
9 /**
10 * @constructor
11 * @extends {SettingsPageBrowserTest}
12 */
13 function SettingsBluetoothPageBrowserTest() {}
14
15 SettingsBluetoothPageBrowserTest.prototype = {
16 __proto__: SettingsPageBrowserTest.prototype,
17 };
18
19 // Runs bluetooth tests.
20 TEST_F('SettingsBluetoothPageBrowserTest', 'Bluetooth', function() {
21 // Assign |self| to |this| instead of binding since 'this' in suite()
22 // and test() will be a Mocha 'Suite' or 'Test' instance.
23 var self = this;
24
25 var enabled = false;
26
27 chrome.bluetooth.getAdapterState = function(callback) {
28 setTimeout(callback({
29 address: '00:11:22:33:44:55:66',
30 name: 'Fake Adapter',
31 powered: enabled,
32 available: true,
33 discovering: false
34 }));
35 };
36
37 chrome.bluetoothPrivate.setAdapterState = function(state, callback) {
38 enabled = state.powered;
39 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'
40 };
41
42 suite('SettingsBluetoothPage', function() {
43 test('enable', function() {
44 var bluetoothSection =
45 self.getSection(self.getPage('advanced'), 'bluetooth');
46 assertTrue(!!bluetoothSection);
47 var bluetooth =
48 bluetoothSection.querySelector('settings-bluetooth-page');
49 assertTrue(!!bluetooth);
50 var enable = bluetooth.$.enableBluetooth;
51 assertTrue(!!enable);
52 assertFalse(enabled);
53 expectFalse(enable.checked);
54 MockInteractions.tap(enable);
55 expectTrue(enable.checked);
56 expectTrue(enabled);
57 });
58 });
59
60 // Run all registered tests.
61 mocha.run();
62 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698