OLD | NEW |
---|---|
(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() { | |
28 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
| |
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 callback(); | |
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 }); | |
OLD | NEW |