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