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

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

Issue 1133913002: [Chromoting] Move shared webapp JS files from crd/js -> base/js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 (function() {
6
7 'use strict';
8
9 /** @type {remoting.MockConnection} */
10 var mockConnection;
11 /** @type {remoting.ClientSessionFactory} */
12 var factory;
13 /** @type {remoting.ClientSession.EventHandler} */
14 var listener;
15
16 /**
17 * @constructor
18 * @implements {remoting.ClientSession.EventHandler}
19 */
20 var SessionListener = function() {};
21 SessionListener.prototype.onConnectionFailed = function(error) {};
22 SessionListener.prototype.onConnected = function(connectionInfo) {};
23 SessionListener.prototype.onDisconnected = function(reason) {};
24 SessionListener.prototype.onError = function(error) {};
25
26 QUnit.module('ClientSessionFactory', {
27 beforeEach: function() {
28 chromeMocks.activate(['identity']);
29 chromeMocks.identity.mock$setToken('fake_token');
30
31 mockConnection = new remoting.MockConnection();
32 listener = new SessionListener();
33 factory = new remoting.ClientSessionFactory(
34 document.createElement('div'),
35 [remoting.ClientSession.Capability.VIDEO_RECORDER]);
36 },
37 afterEach: function() {
38 mockConnection.restore();
39 chromeMocks.restore();
40 }
41 });
42
43 QUnit.test('createSession() should return a remoting.ClientSession',
44 function(assert) {
45 return factory.createSession(listener).then(
46 function(/** remoting.ClientSession */ session){
47 assert.ok(session instanceof remoting.ClientSession);
48 assert.ok(
49 mockConnection.plugin().hasCapability(
50 remoting.ClientSession.Capability.VIDEO_RECORDER),
51 'Capability is set correctly.');
52 });
53 });
54
55 QUnit.test('createSession() should reject on signal strategy failure',
56 function(assert) {
57 var mockSignalStrategy = mockConnection.signalStrategy();
58 mockSignalStrategy.connect = function() {
59 Promise.resolve().then(function () {
60 mockSignalStrategy.setStateForTesting(
61 remoting.SignalStrategy.State.FAILED);
62 });
63 };
64
65 var signalStrategyDispose = sinon.stub(mockSignalStrategy, 'dispose');
66
67 return factory.createSession(listener).then(
68 assert.ok.bind(assert, false, 'Expect createSession() to fail.')
69 ).catch(function(/** remoting.Error */ error) {
70 assert.ok(
71 signalStrategyDispose.called, 'SignalStrategy is disposed on failure.');
72 assert.equal(error.getDetail(), 'setStateForTesting',
73 'Error message is set correctly.');
74 });
75 });
76
77 QUnit.test('createSession() should reject on plugin initialization failure',
78 function(assert) {
79 var mockSignalStrategy = mockConnection.signalStrategy();
80 var plugin = mockConnection.plugin();
81 plugin.mock$initializationResult = false;
82
83 var signalStrategyDispose = sinon.stub(mockSignalStrategy, 'dispose');
84
85 return factory.createSession(listener).then(function() {
86 assert.ok(false, 'Expect createSession() to fail.');
87 }).catch(function(/** remoting.Error */ error) {
88 assert.ok(
89 signalStrategyDispose.called, 'SignalStrategy is disposed on failure.');
90 assert.ok(error.hasTag(remoting.Error.Tag.MISSING_PLUGIN),
91 'Initialization failed with MISSING_PLUGIN.');
92 });
93 });
94
95 })();
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/client_session_factory.js ('k') | remoting/webapp/crd/js/client_session_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698