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

Side by Side Diff: remoting/webapp/crd/js/legacy_host_list_api_unittest.js

Issue 1161813006: Updated handling of GCD devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops--ignore Created 5 years, 6 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 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() {
11 11
12 'use strict'; 12 'use strict';
13 13
14 var FAKE_HOST_ID = '0bad0bad-0bad-0bad-0bad-0bad0bad0bad'; 14 var FAKE_HOST_ID = '0bad0bad-0bad-0bad-0bad-0bad0bad0bad';
15 var FAKE_HOST_NAME = '<FAKE_HOST_NAME>'; 15 var FAKE_HOST_NAME = '<FAKE_HOST_NAME>';
16 var FAKE_PUBLIC_KEY = '<FAKE_PUBLIC_KEY>'; 16 var FAKE_PUBLIC_KEY = '<FAKE_PUBLIC_KEY>';
17 var FAKE_HOST_CLIENT_ID = '<FAKE_HOST_CLIENT_ID>'; 17 var FAKE_HOST_CLIENT_ID = '<FAKE_HOST_CLIENT_ID>';
18 var FAKE_AUTH_CODE = '<FAKE_AUTH_CODE>'; 18 var FAKE_AUTH_CODE = '<FAKE_AUTH_CODE>';
19 19
20 /** @type {sinon.TestStub} */
21 var generateUuidStub;
22
20 QUnit.module('host_list_api_impl', { 23 QUnit.module('host_list_api_impl', {
21 beforeEach: function(/** QUnit.Assert */ assert) { 24 beforeEach: function(/** QUnit.Assert */ assert) {
22 remoting.settings = new remoting.Settings(); 25 remoting.settings = new remoting.Settings();
23 remoting.MockXhr.activate(); 26 remoting.MockXhr.activate();
27 generateUuidStub = sinon.stub(base, 'generateUuid');
28 generateUuidStub.returns(FAKE_HOST_ID);
24 }, 29 },
25 afterEach: function(/** QUnit.Assert */ assert) { 30 afterEach: function(/** QUnit.Assert */ assert) {
31 generateUuidStub.restore();
26 remoting.MockXhr.restore(); 32 remoting.MockXhr.restore();
27 remoting.settings = null; 33 remoting.settings = null;
28 } 34 }
29 }); 35 });
30 36
31 /** 37 /**
32 * Install an HTTP response for requests to the registry. 38 * Install an HTTP response for requests to the registry.
33 * @param {QUnit.Assert} assert 39 * @param {QUnit.Assert} assert
34 */ 40 */
35 function queueRegistryResponse(assert) { 41 function queueRegistryResponse(assert) {
(...skipping 11 matching lines...) Expand all
47 { data: { 53 { data: {
48 hostId: FAKE_HOST_ID, 54 hostId: FAKE_HOST_ID,
49 hostName: FAKE_HOST_NAME, 55 hostName: FAKE_HOST_NAME,
50 publicKey: FAKE_PUBLIC_KEY 56 publicKey: FAKE_PUBLIC_KEY
51 } }); 57 } });
52 xhr.setJsonResponse(200, responseJson); 58 xhr.setJsonResponse(200, responseJson);
53 }); 59 });
54 } 60 }
55 61
56 QUnit.test('register', function(assert) { 62 QUnit.test('register', function(assert) {
57 var impl = new remoting.HostListApiImpl(); 63 var impl = new remoting.LegacyHostListApi();
58 queueRegistryResponse(assert); 64 queueRegistryResponse(assert);
59 return impl.register( 65 return impl.register(
60 FAKE_HOST_ID,
61 FAKE_HOST_NAME, 66 FAKE_HOST_NAME,
62 FAKE_PUBLIC_KEY, 67 FAKE_PUBLIC_KEY,
63 FAKE_HOST_CLIENT_ID 68 FAKE_HOST_CLIENT_ID
64 ). then(function(regResult) { 69 ). then(function(regResult) {
65 assert.equal(regResult.authCode, FAKE_AUTH_CODE); 70 assert.equal(regResult.authCode, FAKE_AUTH_CODE);
66 assert.equal(regResult.email, ''); 71 assert.equal(regResult.email, '');
67 }); 72 });
68 }); 73 });
69 74
70 QUnit.test('register failure', function(assert) { 75 QUnit.test('register failure', function(assert) {
71 var impl = new remoting.HostListApiImpl(); 76 var impl = new remoting.LegacyHostListApi();
72 remoting.MockXhr.setEmptyResponseFor( 77 remoting.MockXhr.setEmptyResponseFor(
73 'POST', 'DIRECTORY_API_BASE_URL/@me/hosts', 500); 78 'POST', 'DIRECTORY_API_BASE_URL/@me/hosts', 500);
74 return impl.register( 79 return impl.register(
75 FAKE_HOST_ID,
76 FAKE_HOST_NAME, 80 FAKE_HOST_NAME,
77 FAKE_PUBLIC_KEY, 81 FAKE_PUBLIC_KEY,
78 FAKE_HOST_CLIENT_ID 82 FAKE_HOST_CLIENT_ID
79 ).then(function(authCode) { 83 ).then(function(authCode) {
80 throw 'test failed'; 84 throw 'test failed';
81 }, function(/** remoting.Error */ e) { 85 }, function(/** remoting.Error */ e) {
82 assert.equal(e.getTag(), remoting.Error.Tag.REGISTRATION_FAILED); 86 assert.equal(e.getTag(), remoting.Error.Tag.REGISTRATION_FAILED);
83 }); 87 });
84 }); 88 });
85 89
86 })(); 90 })();
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/legacy_host_list_api.js ('k') | remoting/webapp/crd/js/mock_host_list_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698