| OLD | NEW |
| 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 /** | 5 /** |
| 6 * @fileoverview Fake implementation of chrome.networkingPrivate for testing. | 6 * @fileoverview Fake implementation of chrome.networkingPrivate for testing. |
| 7 */ | 7 */ |
| 8 cr.define('settings', function() { | 8 cr.define('settings', function() { |
| 9 /** | 9 /** |
| 10 * @constructor | 10 * @constructor |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 this.resetForTest(); | 23 this.resetForTest(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 FakeNetworkingPrivate.prototype = { | 26 FakeNetworkingPrivate.prototype = { |
| 27 resetForTest() { | 27 resetForTest() { |
| 28 this.deviceStates_ = { | 28 this.deviceStates_ = { |
| 29 Ethernet: {Type: 'Ethernet', State: 'Enabled'}, | 29 Ethernet: {Type: 'Ethernet', State: 'Enabled'}, |
| 30 WiFi: {Type: 'WiFi', State: ''}, | 30 WiFi: {Type: 'WiFi', State: ''}, |
| 31 Cellular: {Type: 'Cellular', State: ''}, | 31 Cellular: {Type: 'Cellular', State: ''}, |
| 32 Tether: {Type: 'Tether', State: ''}, |
| 32 WiMAX: {Type: 'WiMAX', State: ''}, | 33 WiMAX: {Type: 'WiMAX', State: ''}, |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 this.networkStates_ = [ | 36 this.networkStates_ = [ |
| 36 {GUID: 'eth0_guid', Type: 'Ethernet'}, | 37 {GUID: 'eth0_guid', Type: 'Ethernet'}, |
| 37 ]; | 38 ]; |
| 38 | 39 |
| 39 this.globalPolicy_ = {}; | 40 this.globalPolicy_ = {}; |
| 40 }, | 41 }, |
| 41 | 42 |
| 42 /** @param {!Array<!CrOnc.NetworkStateProperties>} network */ | 43 /** @param {!Array<!CrOnc.NetworkStateProperties>} network */ |
| 43 addNetworksForTest: function(networks) { | 44 addNetworksForTest: function(networks) { |
| 44 this.networkStates_ = this.networkStates_.concat(networks); | 45 this.networkStates_ = this.networkStates_.concat(networks); |
| 45 }, | 46 }, |
| 46 | 47 |
| 47 /** | 48 /** |
| 48 * @param {string} type | 49 * @param {string} type |
| 49 * @return {?chrome.networkingPrivate.DeviceStateProperties} | 50 * @return {?chrome.networkingPrivate.DeviceStateProperties} |
| 50 */ | 51 */ |
| 51 getDeviceStateForTest: function(type) { | 52 getDeviceStateForTest: function(type) { |
| 52 return this.deviceStates_[type] || null; | 53 return this.deviceStates_[type] || null; |
| 53 }, | 54 }, |
| 54 | 55 |
| 55 /** @override */ | 56 /** @override */ |
| 56 getProperties: assertNotReached, | 57 getProperties: assertNotReached, |
| 57 | 58 |
| 58 /** @override */ | 59 /** @override */ |
| 59 getManagedProperties: assertNotReached, | 60 getManagedProperties: function(guid) { |
| 61 var result = this.networkStates_.find(function(state) { |
| 62 return state.GUID == guid; |
| 63 }); |
| 64 // TODO(stevenjb): Convert state to ManagedProperties. |
| 65 return result; |
| 66 }, |
| 60 | 67 |
| 61 /** @override */ | 68 /** @override */ |
| 62 getState: assertNotReached, | 69 getState: assertNotReached, |
| 63 | 70 |
| 64 /** @override */ | 71 /** @override */ |
| 65 setProperties: assertNotReached, | 72 setProperties: assertNotReached, |
| 66 | 73 |
| 67 /** @override */ | 74 /** @override */ |
| 68 createNetwork: assertNotReached, | 75 createNetwork: assertNotReached, |
| 69 | 76 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 161 |
| 155 /** @type {!FakeChromeEvent} */ | 162 /** @type {!FakeChromeEvent} */ |
| 156 onDeviceStateListChanged: new FakeChromeEvent(), | 163 onDeviceStateListChanged: new FakeChromeEvent(), |
| 157 | 164 |
| 158 /** @type {!FakeChromeEvent} */ | 165 /** @type {!FakeChromeEvent} */ |
| 159 onPortalDetectionCompleted: new FakeChromeEvent(), | 166 onPortalDetectionCompleted: new FakeChromeEvent(), |
| 160 }; | 167 }; |
| 161 | 168 |
| 162 return {FakeNetworkingPrivate: FakeNetworkingPrivate}; | 169 return {FakeNetworkingPrivate: FakeNetworkingPrivate}; |
| 163 }); | 170 }); |
| OLD | NEW |