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

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

Issue 984203003: Move mocks and unittest JS files to sit alongside production code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 9 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 'use strict';
6
7 /** @suppress {duplicate} */
8 var remoting = remoting || {};
9
10
11 /**
12 * @param {string=} jid
13 * @param {remoting.SignalStrategy.Type=} type
14 *
15 * @implements {remoting.SignalStrategy}
16 * @constructor
17 */
18 remoting.MockSignalStrategy = function(jid, type) {
19 this.jid_ = (jid != undefined) ? jid : "jid@example.com";
20 this.type_ = (type != undefined) ? type : remoting.SignalStrategy.Type.XMPP;
21 this.onStateChangedCallback_ = null;
22
23 /** @type {remoting.SignalStrategy.State} */
24 this.state_ = remoting.SignalStrategy.State.NOT_CONNECTED;
25
26 this.onIncomingStanzaCallback_ = function() {};
27 this.dispose = sinon.spy();
28 this.connect = sinon.spy();
29 this.sendMessage = sinon.spy();
30 this.sendConnectionSetupResults = sinon.spy();
31 };
32
33 /**
34 * @param {function(remoting.SignalStrategy.State):void} onStateChangedCallback
35 * Callback to call on state change.
36 */
37 remoting.MockSignalStrategy.prototype.setStateChangedCallback = function(
38 onStateChangedCallback) {
39 this.onStateChangedCallback_ = onStateChangedCallback;
40 };
41
42 /**
43 * @param {?function(Element):void} onIncomingStanzaCallback Callback to call on
44 * incoming messages.
45 */
46 remoting.MockSignalStrategy.prototype.setIncomingStanzaCallback =
47 function(onIncomingStanzaCallback) {
48 this.onIncomingStanzaCallback_ =
49 onIncomingStanzaCallback ? onIncomingStanzaCallback
50 : function() {};
51 };
52
53 /** @return {remoting.SignalStrategy.State} */
54 remoting.MockSignalStrategy.prototype.getState = function() {
55 return this.state_;
56 };
57
58 /** @return {!remoting.Error} */
59 remoting.MockSignalStrategy.prototype.getError = function() {
60 return remoting.Error.NONE;
61 };
62
63 /** @return {string} */
64 remoting.MockSignalStrategy.prototype.getJid = function() {
65 return this.jid_;
66 };
67
68 /** @return {remoting.SignalStrategy.Type} */
69 remoting.MockSignalStrategy.prototype.getType = function() {
70 return this.type_;
71 };
72
73 /**
74 * @param {remoting.SignalStrategy.State} state
75 */
76 remoting.MockSignalStrategy.prototype.setStateForTesting = function(state) {
77 this.state_ = state;
78 this.onStateChangedCallback_(state);
79 };
OLDNEW
« no previous file with comments | « remoting/webapp/unittests/menu_button_unittest.js ('k') | remoting/webapp/unittests/xhr_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698