| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 /** @fileoverview Suite of tests for settings-bluetooth-page. */ | 5 /** @fileoverview Suite of tests for settings-bluetooth-page. */ |
| 6 | 6 |
| 7 GEN_INCLUDE(['settings_page_browsertest.js']); | 7 GEN_INCLUDE(['settings_page_browsertest.js']); |
| 8 | 8 |
| 9 var bluetoothPage = bluetoothPage || {}; | 9 var bluetoothPage = bluetoothPage || {}; |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 GEN('#define MAYBE_Bluetooth Bluetooth'); | 53 GEN('#define MAYBE_Bluetooth Bluetooth'); |
| 54 GEN('#endif'); | 54 GEN('#endif'); |
| 55 | 55 |
| 56 // Runs bluetooth tests. | 56 // Runs bluetooth tests. |
| 57 TEST_F('SettingsBluetoothPageBrowserTest', 'MAYBE_Bluetooth', function() { | 57 TEST_F('SettingsBluetoothPageBrowserTest', 'MAYBE_Bluetooth', function() { |
| 58 // Differentiate |this| in the Test from |this| in suite() and test(), see | 58 // Differentiate |this| in the Test from |this| in suite() and test(), see |
| 59 // comment at the top of mocha_adapter.js. | 59 // comment at the top of mocha_adapter.js. |
| 60 var self = this; | 60 var self = this; |
| 61 | 61 |
| 62 self.toggleAdvanced(); | 62 self.toggleAdvanced(); |
| 63 var advanced = self.getPage('advanced'); | 63 var page = self.getPage('basic'); |
| 64 assertTrue(!!advanced); | 64 assertTrue(!!page); |
| 65 advanced.set('pageVisibility.bluetooth', true); | 65 page.set('pageVisibility.bluetooth', true); |
| 66 Polymer.dom.flush(); | 66 Polymer.dom.flush(); |
| 67 | 67 |
| 68 /** @type {!Array<!chrome.bluetooth.Device>} */ var fakeDevices_ = [ | 68 /** @type {!Array<!chrome.bluetooth.Device>} */ var fakeDevices_ = [ |
| 69 { | 69 { |
| 70 address: '10:00:00:00:00:01', | 70 address: '10:00:00:00:00:01', |
| 71 name: 'FakePairedDevice1', | 71 name: 'FakePairedDevice1', |
| 72 paired: true, | 72 paired: true, |
| 73 connected: true, | 73 connected: true, |
| 74 }, | 74 }, |
| 75 { | 75 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 87 { | 87 { |
| 88 address: '00:00:00:00:00:02', | 88 address: '00:00:00:00:00:02', |
| 89 name: 'FakeUnPairedDevice2', | 89 name: 'FakeUnPairedDevice2', |
| 90 paired: false, | 90 paired: false, |
| 91 }, | 91 }, |
| 92 ]; | 92 ]; |
| 93 | 93 |
| 94 suite('SettingsBluetoothPage', function() { | 94 suite('SettingsBluetoothPage', function() { |
| 95 test('enable', function() { | 95 test('enable', function() { |
| 96 assertFalse(self.bluetoothApi_.adapterState.powered); | 96 assertFalse(self.bluetoothApi_.adapterState.powered); |
| 97 var bluetoothSection = self.getSection(advanced, 'bluetooth'); | 97 var bluetoothSection = self.getSection(page, 'bluetooth'); |
| 98 assertTrue(!!bluetoothSection); | 98 assertTrue(!!bluetoothSection); |
| 99 var bluetooth = | 99 var bluetooth = |
| 100 bluetoothSection.querySelector('settings-bluetooth-page'); | 100 bluetoothSection.querySelector('settings-bluetooth-page'); |
| 101 assertTrue(!!bluetooth); | 101 assertTrue(!!bluetooth); |
| 102 expectFalse(bluetooth.bluetoothEnabled); | 102 expectFalse(bluetooth.bluetoothEnabled); |
| 103 var enable = bluetooth.$.enableBluetooth; | 103 var enable = bluetooth.$.enableBluetooth; |
| 104 assertTrue(!!enable); | 104 assertTrue(!!enable); |
| 105 expectFalse(enable.checked); | 105 expectFalse(enable.checked); |
| 106 // Test that tapping the enable checkbox changes its value and calls | 106 // Test that tapping the enable checkbox changes its value and calls |
| 107 // bluetooth.setAdapterState with powered = false. | 107 // bluetooth.setAdapterState with powered = false. |
| 108 MockInteractions.tap(enable); | 108 MockInteractions.tap(enable); |
| 109 Polymer.dom.flush(); | 109 Polymer.dom.flush(); |
| 110 expectTrue(enable.checked); | 110 expectTrue(enable.checked); |
| 111 expectTrue(self.bluetoothApi_.adapterState.powered); | 111 expectTrue(self.bluetoothApi_.adapterState.powered); |
| 112 // Confirm that 'bluetoothEnabled' remains set to true. | 112 // Confirm that 'bluetoothEnabled' remains set to true. |
| 113 expectTrue(bluetooth.bluetoothEnabled); | 113 expectTrue(bluetooth.bluetoothEnabled); |
| 114 // Set 'bluetoothEnabled' directly and confirm that the checkbox | 114 // Set 'bluetoothEnabled' directly and confirm that the checkbox |
| 115 // toggles. | 115 // toggles. |
| 116 bluetooth.bluetoothEnabled = false; | 116 bluetooth.bluetoothEnabled = false; |
| 117 Polymer.dom.flush(); | 117 Polymer.dom.flush(); |
| 118 expectFalse(enable.checked); | 118 expectFalse(enable.checked); |
| 119 }); | 119 }); |
| 120 | 120 |
| 121 test('device list', function() { | 121 test('device list', function() { |
| 122 var bluetoothSection = self.getSection(advanced, 'bluetooth'); | 122 var bluetoothSection = self.getSection(page, 'bluetooth'); |
| 123 var bluetooth = | 123 var bluetooth = |
| 124 bluetoothSection.querySelector('settings-bluetooth-page'); | 124 bluetoothSection.querySelector('settings-bluetooth-page'); |
| 125 assertTrue(!!bluetooth); | 125 assertTrue(!!bluetooth); |
| 126 var deviceList = bluetooth.$.deviceList; | 126 var deviceList = bluetooth.$.deviceList; |
| 127 assertTrue(!!deviceList); | 127 assertTrue(!!deviceList); |
| 128 // Set enabled, with default (empty) device list. | 128 // Set enabled, with default (empty) device list. |
| 129 self.bluetoothApi_.setEnabled(true); | 129 self.bluetoothApi_.setEnabled(true); |
| 130 Polymer.dom.flush(); | 130 Polymer.dom.flush(); |
| 131 // Ensure that initially the 'no devices' element is visible. | 131 // Ensure that initially the 'no devices' element is visible. |
| 132 expectFalse(deviceList.hidden); | 132 expectFalse(deviceList.hidden); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 146 // Confirm that there are two paired devices in the list. | 146 // Confirm that there are two paired devices in the list. |
| 147 var devices = deviceList.querySelectorAll('bluetooth-device-list-item'); | 147 var devices = deviceList.querySelectorAll('bluetooth-device-list-item'); |
| 148 assertEquals(2, devices.length); | 148 assertEquals(2, devices.length); |
| 149 // Check the state of each device. | 149 // Check the state of each device. |
| 150 assertTrue(devices[0].device.connected); | 150 assertTrue(devices[0].device.connected); |
| 151 assertFalse(devices[1].device.connected); | 151 assertFalse(devices[1].device.connected); |
| 152 assertTrue(devices[1].device.connecting); | 152 assertTrue(devices[1].device.connecting); |
| 153 }); | 153 }); |
| 154 | 154 |
| 155 test('device dialog', function() { | 155 test('device dialog', function() { |
| 156 var bluetoothSection = self.getSection(advanced, 'bluetooth'); | 156 var bluetoothSection = self.getSection(page, 'bluetooth'); |
| 157 var bluetooth = | 157 var bluetooth = |
| 158 bluetoothSection.querySelector('settings-bluetooth-page'); | 158 bluetoothSection.querySelector('settings-bluetooth-page'); |
| 159 assertTrue(!!bluetooth); | 159 assertTrue(!!bluetooth); |
| 160 self.bluetoothApi_.setEnabled(true); | 160 self.bluetoothApi_.setEnabled(true); |
| 161 | 161 |
| 162 // Tap the 'add device' button. | 162 // Tap the 'add device' button. |
| 163 MockInteractions.tap(bluetooth.$$('.primary-button')); | 163 MockInteractions.tap(bluetooth.$$('.primary-button')); |
| 164 Polymer.dom.flush(); | 164 Polymer.dom.flush(); |
| 165 // Ensure the dialog appears. | 165 // Ensure the dialog appears. |
| 166 var dialog = bluetooth.$$('#deviceDialog'); | 166 var dialog = bluetooth.$$('#deviceDialog'); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 189 // Close the dialog. | 189 // Close the dialog. |
| 190 dialog.close(); | 190 dialog.close(); |
| 191 Polymer.dom.flush(); | 191 Polymer.dom.flush(); |
| 192 assertFalse(dialog.$.dialog.open); | 192 assertFalse(dialog.$.dialog.open); |
| 193 }); | 193 }); |
| 194 }); | 194 }); |
| 195 | 195 |
| 196 // Run all registered tests. | 196 // Run all registered tests. |
| 197 mocha.run(); | 197 mocha.run(); |
| 198 }); | 198 }); |
| OLD | NEW |