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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Unit tests for host_controller.js. | 7 * Unit tests for host_controller.js. |
8 */ | 8 */ |
9 | 9 |
10 (function() { | 10 (function() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 var mockHostListApi; | 75 var mockHostListApi; |
76 | 76 |
77 QUnit.module('host_controller', { | 77 QUnit.module('host_controller', { |
78 beforeEach: function(/** QUnit.Assert */ assert) { | 78 beforeEach: function(/** QUnit.Assert */ assert) { |
79 chromeMocks.activate(['identity', 'runtime']); | 79 chromeMocks.activate(['identity', 'runtime']); |
80 chromeMocks.identity.mock$setToken(FAKE_IDENTITY_TOKEN); | 80 chromeMocks.identity.mock$setToken(FAKE_IDENTITY_TOKEN); |
81 remoting.settings = new remoting.Settings(); | 81 remoting.settings = new remoting.Settings(); |
82 remoting.identity = new remoting.Identity(); | 82 remoting.identity = new remoting.Identity(); |
83 mockHostListApi = new remoting.MockHostListApi; | 83 mockHostListApi = new remoting.MockHostListApi; |
84 mockHostListApi.registerResult = FAKE_AUTH_CODE; | 84 mockHostListApi.registerResult = FAKE_AUTH_CODE; |
85 remoting.hostListApi = mockHostListApi; | 85 remoting.HostListApi.setInstance(mockHostListApi); |
86 base.debug.assert(remoting.oauth2 === null); | 86 base.debug.assert(remoting.oauth2 === null); |
87 remoting.oauth2 = new remoting.OAuth2(); | 87 remoting.oauth2 = new remoting.OAuth2(); |
88 base.debug.assert(remoting.hostList === null); | 88 base.debug.assert(remoting.hostList === null); |
89 remoting.hostList = /** @type {remoting.HostList} */ | 89 remoting.hostList = /** @type {remoting.HostList} */ |
90 (Object.create(remoting.HostList.prototype)); | 90 (Object.create(remoting.HostList.prototype)); |
91 | 91 |
92 // When the HostList's unregisterHostById method is called, make | 92 // When the HostList's unregisterHostById method is called, make |
93 // sure the argument is correct. | 93 // sure the argument is correct. |
94 unregisterHostByIdSpy = | 94 unregisterHostByIdSpy = |
95 sinon.stub(remoting.hostList, 'unregisterHostById', function( | 95 sinon.stub(remoting.hostList, 'unregisterHostById', function( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 afterEach: function() { | 167 afterEach: function() { |
168 controller = null; | 168 controller = null; |
169 getCredentialsFromAuthCodeSpy.restore(); | 169 getCredentialsFromAuthCodeSpy.restore(); |
170 generateUuidStub.restore(); | 170 generateUuidStub.restore(); |
171 hostDaemonFacadeCtorStub.restore(); | 171 hostDaemonFacadeCtorStub.restore(); |
172 signalStrategyCreateStub.restore(); | 172 signalStrategyCreateStub.restore(); |
173 remoting.hostList = null; | 173 remoting.hostList = null; |
174 remoting.oauth2 = null; | 174 remoting.oauth2 = null; |
175 chromeMocks.restore(); | 175 chromeMocks.restore(); |
176 remoting.hostListApi = null; | 176 remoting.HostListApi.setInstance(null); |
177 remoting.identity = null; | 177 remoting.identity = null; |
178 } | 178 } |
179 }); | 179 }); |
180 | 180 |
181 /** | 181 /** |
182 * @param {string} hostId | 182 * @param {string} hostId |
183 * @param {string} pin | 183 * @param {string} pin |
184 * @return {string} | 184 * @return {string} |
185 */ | 185 */ |
186 function fakePinHashFunc(hostId, pin) { | 186 function fakePinHashFunc(hostId, pin) { |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 resolve(null); | 637 resolve(null); |
638 }); | 638 }); |
639 }); | 639 }); |
640 }); | 640 }); |
641 | 641 |
642 // Tests omitted for hasFeature, getPairedClients, deletePairedClient, | 642 // Tests omitted for hasFeature, getPairedClients, deletePairedClient, |
643 // and clearPairedClients because they simply call through to | 643 // and clearPairedClients because they simply call through to |
644 // HostDaemonFacade. | 644 // HostDaemonFacade. |
645 | 645 |
646 })(); | 646 })(); |
OLD | NEW |