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

Side by Side Diff: chrome/test/data/webui/settings/bluetooth_page_tests.js

Issue 2801403002: MD Settings: Bluetooth: Fix adapter state and discovery (Closed)
Patch Set: Use CHECK instead of early exit Created 3 years, 8 months 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 suite('Bluetooth', function() { 5 suite('Bluetooth', function() {
6 var bluetoothPage = null; 6 var bluetoothPage = null;
7 7
8 /** @type {Bluetooth} */ 8 /** @type {Bluetooth} */
9 var bluetoothApi_; 9 var bluetoothApi_;
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 bluetoothApi_.setDevicesForTest([]); 65 bluetoothApi_.setDevicesForTest([]);
66 document.body.appendChild(bluetoothPage); 66 document.body.appendChild(bluetoothPage);
67 Polymer.dom.flush(); 67 Polymer.dom.flush();
68 }); 68 });
69 69
70 teardown(function() { 70 teardown(function() {
71 bluetoothPage.remove(); 71 bluetoothPage.remove();
72 }); 72 });
73 73
74 test('MainPage', function() { 74 test('MainPage', function() {
75 assertFalse(bluetoothApi_.adapterState.powered); 75 assertFalse(bluetoothApi_.getAdapterStateForTest().powered);
76 assertFalse(bluetoothPage.bluetoothEnabled_); 76 assertFalse(bluetoothPage.bluetoothToggleState_);
77 // Test that tapping the single settings-box div enables bluetooth. 77 // Test that tapping the single settings-box div enables bluetooth.
78 var div = bluetoothPage.$$('div.settings-box'); 78 var div = bluetoothPage.$$('div.settings-box');
79 assertTrue(!!div); 79 assertTrue(!!div);
80 MockInteractions.tap(div); 80 MockInteractions.tap(div);
81 assertTrue(bluetoothPage.bluetoothEnabled_); 81 assertTrue(bluetoothPage.bluetoothToggleState_);
82 assertTrue(bluetoothApi_.adapterState.powered); 82 assertTrue(bluetoothApi_.getAdapterStateForTest().powered);
83 }); 83 });
84 84
85 suite('SubPage', function() { 85 suite('SubPage', function() {
86 var subpage; 86 var subpage;
87 87
88 setup(function() { 88 setup(function() {
89 bluetoothPage.bluetoothEnabled_ = true; 89 bluetoothApi_.setEnabled(true);
90 Polymer.dom.flush();
90 var div = bluetoothPage.$$('div.settings-box'); 91 var div = bluetoothPage.$$('div.settings-box');
91 MockInteractions.tap(div); 92 MockInteractions.tap(div);
92 subpage = bluetoothPage.$$('settings-bluetooth-subpage'); 93 subpage = bluetoothPage.$$('settings-bluetooth-subpage');
93 assertTrue(!!subpage); 94 assertTrue(!!subpage);
95 assertTrue(subpage.bluetoothToggleState);
96 assertFalse(subpage.bluetoothToggleDisabled);
94 }); 97 });
95 98
96 test('toggle', function() { 99 test('toggle', function() {
97 assertTrue(subpage.bluetoothEnabled); 100 assertTrue(subpage.bluetoothToggleState);
98 101
99 var enableButton = subpage.$.enableBluetooth; 102 var enableButton = subpage.$.enableBluetooth;
100 assertTrue(!!enableButton); 103 assertTrue(!!enableButton);
101 assertTrue(enableButton.checked); 104 assertTrue(enableButton.checked);
102 105
103 subpage.bluetoothEnabled = false; 106 subpage.bluetoothToggleState = false;
104 assertFalse(enableButton.checked); 107 assertFalse(enableButton.checked);
105 assertFalse(bluetoothApi_.adapterState.powered);; 108 assertFalse(bluetoothApi_.getAdapterStateForTest().powered);
106 assertFalse(bluetoothPage.bluetoothEnabled_); 109 assertFalse(bluetoothPage.bluetoothToggleState_);
107 }); 110 });
108 111
109 test('paired device list', function() { 112 test('paired device list', function() {
110 var pairedContainer = subpage.$.pairedContainer; 113 var pairedContainer = subpage.$.pairedContainer;
111 assertTrue(!!pairedContainer); 114 assertTrue(!!pairedContainer);
112 assertTrue(pairedContainer.hidden); 115 assertTrue(pairedContainer.hidden);
113 assertFalse(subpage.$.noPairedDevices.hidden); 116 assertFalse(subpage.$.noPairedDevices.hidden);
114 117
115 bluetoothApi_.setDevicesForTest(fakeDevices_); 118 bluetoothApi_.setDevicesForTest(fakeDevices_);
116 Polymer.dom.flush(); 119 Polymer.dom.flush();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 assertTrue(!!dialog); 176 assertTrue(!!dialog);
174 assertFalse(dialog.$.dialog.open); 177 assertFalse(dialog.$.dialog.open);
175 178
176 // Simulate selecting an unpaired device; should show the pair dialog. 179 // Simulate selecting an unpaired device; should show the pair dialog.
177 subpage.connectDevice_(subpage.unpairedDeviceList_[0]); 180 subpage.connectDevice_(subpage.unpairedDeviceList_[0]);
178 Polymer.dom.flush(); 181 Polymer.dom.flush();
179 assertTrue(dialog.$.dialog.open); 182 assertTrue(dialog.$.dialog.open);
180 }); 183 });
181 }); 184 });
182 }); 185 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698