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

Side by Side Diff: remoting/webapp/base/js/client_session_unittest.js

Issue 1410563006: [Chromoting] SessionLogger refactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 1 month 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 (function() { 5 (function() {
6 6
7 'use strict'; 7 'use strict';
8 8
9 /** @type {remoting.MockConnection} */ 9 /** @type {remoting.MockConnection} */
10 var mockConnection; 10 var mockConnection;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 QUnit.module('ClientSession', { 71 QUnit.module('ClientSession', {
72 beforeEach: function() { 72 beforeEach: function() {
73 chromeMocks.identity.mock$setToken('fake_token'); 73 chromeMocks.identity.mock$setToken('fake_token');
74 74
75 mockConnection = new remoting.MockConnection(); 75 mockConnection = new remoting.MockConnection();
76 listener = new SessionListener(); 76 listener = new SessionListener();
77 logger = new remoting.SessionLogger(remoting.ChromotingEvent.Role.CLIENT, 77 logger = new remoting.SessionLogger(remoting.ChromotingEvent.Role.CLIENT,
78 base.doNothing); 78 base.doNothing);
79 logToServerStub = sinon.stub(logger, 'logClientSessionStateChange'); 79 logToServerStub = sinon.stub(logger, 'logSessionStateChange');
80 }, 80 },
81 afterEach: function() { 81 afterEach: function() {
82 session.dispose(); 82 session.dispose();
83 mockConnection.restore(); 83 mockConnection.restore();
84 } 84 }
85 }); 85 });
86 86
87 QUnit.test('should raise CONNECTED event on connected', function(assert) { 87 QUnit.test('should raise CONNECTED event on connected', function(assert) {
88 return connect().then(function(){ 88 return connect().then(function(){
89 assert.ok(true, 'Expect session to connect.'); 89 assert.ok(true, 'Expect session to connect.');
(...skipping 24 matching lines...) Expand all
114 var onDisconnected = sinon.stub(listener, 'onDisconnected'); 114 var onDisconnected = sinon.stub(listener, 'onDisconnected');
115 session.disconnect(remoting.Error.none()); 115 session.disconnect(remoting.Error.none());
116 assert.equal(onDisconnected.callCount, 1); 116 assert.equal(onDisconnected.callCount, 1);
117 }); 117 });
118 }); 118 });
119 119
120 QUnit.test( 120 QUnit.test(
121 'Connection error after CONNECTED should raise the CONNECTION_DROPPED event', 121 'Connection error after CONNECTED should raise the CONNECTION_DROPPED event',
122 function(assert) { 122 function(assert) {
123 123
124 var State = remoting.ClientSession.State; 124 var State = remoting.ChromotingEvent.SessionState;
125 125
126 return connect().then(function() { 126 return connect().then(function() {
127 var onDisconnected = sinon.stub(listener, 'onDisconnected'); 127 var onDisconnected = sinon.stub(listener, 'onDisconnected');
128 session.disconnect(new remoting.Error(remoting.Error.Tag.P2P_FAILURE)); 128 session.disconnect(new remoting.Error(remoting.Error.Tag.P2P_FAILURE));
129 assert.equal(onDisconnected.callCount, 1); 129 assert.equal(onDisconnected.callCount, 1);
130 assert.equal(logToServerStub.args[2][0], State.CONNECTION_DROPPED); 130 assert.equal(logToServerStub.args[4][0], State.CONNECTION_DROPPED);
131 }); 131 });
132 }); 132 });
133 133
134 QUnit.test( 134 QUnit.test(
135 'Connection error before CONNECTED should raise the CONNECTION_FAILED event', 135 'Connection error before CONNECTED should raise the CONNECTION_FAILED event',
136 function(assert) { 136 function(assert) {
137 137
138 var PluginError = remoting.ClientSession.ConnectionError; 138 var PluginError = remoting.ClientSession.ConnectionError;
139 var State = remoting.ClientSession.State; 139 var State = remoting.ChromotingEvent.SessionState;
140 140
141 return connect(PluginError.SESSION_REJECTED).then(function() { 141 return connect(PluginError.SESSION_REJECTED).then(function() {
142 assert.ok(false, 'Expect connection to fail'); 142 assert.ok(false, 'Expect connection to fail');
143 }).catch(function(/** remoting.Error */ error) { 143 }).catch(function(/** remoting.Error */ error) {
144 assert.ok(error.hasTag(remoting.Error.Tag.INVALID_ACCESS_CODE)); 144 assert.ok(error.hasTag(remoting.Error.Tag.INVALID_ACCESS_CODE));
145 assert.equal(logToServerStub.args[1][0], State.FAILED); 145 assert.equal(logToServerStub.args[3][0], State.CONNECTION_FAILED);
146 var errorLogged = /** @type {remoting.Error} */(logToServerStub.args[1][1]); 146 var errorLogged = /** @type {remoting.Error} */(logToServerStub.args[3][1]);
147 assert.equal(errorLogged.getTag(), remoting.Error.Tag.INVALID_ACCESS_CODE); 147 assert.equal(errorLogged.getTag(), remoting.Error.Tag.INVALID_ACCESS_CODE);
148 }); 148 });
149 }); 149 });
150 150
151 })(); 151 })();
OLDNEW
« no previous file with comments | « remoting/webapp/base/js/client_session_factory.js ('k') | remoting/webapp/base/js/session_logger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698