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

Side by Side Diff: remoting/webapp/unittests/it2me_helpee_channel_unittest.js

Issue 503063004: Hangouts Remote Desktop Part VI - Show confirm dialog before retrieving access code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 (function() { 5 (function() {
6 6
7 'use strict'; 7 'use strict';
8 8
9 var hostInstaller = null; 9 var hostInstaller = null;
10 var hangoutPort = null; 10 var hangoutPort = null;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 sinon.assert.calledWith(hangoutPort.postMessage, { 75 sinon.assert.calledWith(hangoutPort.postMessage, {
76 method: MessageTypes.IS_HOST_INSTALLED_RESPONSE, 76 method: MessageTypes.IS_HOST_INSTALLED_RESPONSE,
77 result: false 77 result: false
78 }); 78 });
79 QUnit.start(); 79 QUnit.start();
80 }); 80 });
81 }); 81 });
82 82
83 QUnit.asyncTest('isHostInstalled() should return true if host is installed', 83 QUnit.asyncTest('isHostInstalled() should return true if host is installed',
84 function() { 84 function() {
85 sinon.stub(hostInstaller, "isInstalled").returns(Promise.resolve(true)); 85 sinon.stub(hostInstaller, 'isInstalled').returns(Promise.resolve(true));
kelvinp 2014/08/25 23:49:34 The replacement of double quotes to single quotes
86 86
87 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes; 87 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes;
88 hangoutPort.onMessage.mock$fire({ 88 hangoutPort.onMessage.mock$fire({
89 method: MessageTypes.IS_HOST_INSTALLED 89 method: MessageTypes.IS_HOST_INSTALLED
90 }); 90 });
91 91
92 window.requestAnimationFrame(function() { 92 window.requestAnimationFrame(function() {
93 sinon.assert.calledWith(hangoutPort.postMessage, { 93 sinon.assert.calledWith(hangoutPort.postMessage, {
94 method: MessageTypes.IS_HOST_INSTALLED_RESPONSE, 94 method: MessageTypes.IS_HOST_INSTALLED_RESPONSE,
95 result: true 95 result: true
96 }); 96 });
97 QUnit.start(); 97 QUnit.start();
98 }); 98 });
99 }); 99 });
100 100
101 test('downloadHost() should trigger a host download', 101 test('downloadHost() should trigger a host download',
102 function() { 102 function() {
103 sinon.stub(hostInstaller, "download").returns(Promise.resolve(true)); 103 sinon.stub(hostInstaller, 'download').returns(Promise.resolve(true));
104 104
105 hangoutPort.onMessage.mock$fire({ 105 hangoutPort.onMessage.mock$fire({
106 method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.DOWNLOAD_HOST 106 method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.DOWNLOAD_HOST
107 }); 107 });
108 108
109 sinon.assert.called(hostInstaller.download); 109 sinon.assert.called(hostInstaller.download);
110 }); 110 });
111 111
112 test('connect() should return error if email is missing', 112 test('connect() should return error if email is missing',
113 function() { 113 function() {
114 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes; 114 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes;
115 115
116 hangoutPort.onMessage.mock$fire({ 116 hangoutPort.onMessage.mock$fire({
117 method: MessageTypes.CONNECT 117 method: MessageTypes.CONNECT
118 }); 118 });
119 119
120 sinon.assert.calledWithMatch(hangoutPort.postMessage, { 120 sinon.assert.calledWithMatch(hangoutPort.postMessage, {
121 method: MessageTypes.ERROR 121 method: MessageTypes.ERROR
122 }); 122 });
123 }); 123 });
124 124
125 QUnit.asyncTest('connect() should return access code', 125 QUnit.asyncTest('connect() should return access code',
126 function() { 126 function() {
127 // Stubs authentication. 127 // Stubs authentication.
128 sinon.stub(base, "isAppsV2").returns(true); 128 sinon.stub(base, 'isAppsV2').returns(true);
129 sinon.stub(chrome.identity, "getAuthToken") 129 sinon.stub(remoting.MessageWindow, 'showConfirmWindow')
130 .callsArgWith(4, 1 /* 1 for OK. */);
131 sinon.stub(chrome.identity, 'getAuthToken')
130 .callsArgWith(1, 'token'); 132 .callsArgWith(1, 'token');
131 // Stubs Host behavior. 133 // Stubs Host behavior.
132 sinon.stub(host, "initialized").returns(true); 134 sinon.stub(host, 'initialized').returns(true);
133 sinon.stub(host, "connect") 135 sinon.stub(host, 'connect')
134 .callsArgWith(2, remoting.HostSession.State.RECEIVED_ACCESS_CODE); 136 .callsArgWith(2, remoting.HostSession.State.RECEIVED_ACCESS_CODE);
135 sinon.stub(host, "getAccessCode").returns('accessCode'); 137 sinon.stub(host, 'getAccessCode').returns('accessCode');
136 138
137 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes; 139 var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes;
138 hangoutPort.onMessage.mock$fire({ 140 hangoutPort.onMessage.mock$fire({
139 method: MessageTypes.CONNECT, 141 method: MessageTypes.CONNECT,
140 email: 'test@chromium.org' 142 email: 'test@chromium.org'
141 }); 143 });
142 144
143 window.requestAnimationFrame(function(){ 145 window.requestAnimationFrame(function(){
144 // Verify that access code is correct in the response. 146 // Verify that access code is correct in the response.
145 sinon.assert.calledWithMatch(hangoutPort.postMessage, { 147 sinon.assert.calledWithMatch(hangoutPort.postMessage, {
146 method: MessageTypes.CONNECT_RESPONSE, 148 method: MessageTypes.CONNECT_RESPONSE,
147 accessCode: 'accessCode' 149 accessCode: 'accessCode'
148 }); 150 });
149 151
150 chrome.identity.getAuthToken.restore(); 152 chrome.identity.getAuthToken.restore();
151 base.isAppsV2.restore(); 153 base.isAppsV2.restore();
152 QUnit.start(); 154 QUnit.start();
153 }); 155 });
154 }); 156 });
155 157
156 test('should disconnect the session if Hangout crashes', function() { 158 test('should disconnect the session if Hangout crashes', function() {
157 sinon.spy(host, "disconnect"); 159 sinon.spy(host, 'disconnect');
158 hangoutPort.onDisconnect.mock$fire(); 160 hangoutPort.onDisconnect.mock$fire();
159 161
160 sinon.assert.called(onDisposedCallback); 162 sinon.assert.called(onDisposedCallback);
161 sinon.assert.called(host.disconnect); 163 sinon.assert.called(host.disconnect);
162 }); 164 });
163 165
164 })(); 166 })();
OLDNEW
« remoting/resources/remoting_strings.grd ('K') | « remoting/webapp/unittests/base_unittest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698