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
3 // found in the LICENSE file.
7 * Mock implementation of ClientPlugin for testing.
8 * @suppress {checkTypes}
13 /** @suppress {duplicate} */
14 var remoting = remoting || {};
18 * @implements {remoting.ClientPlugin}
20 remoting.MockClientPlugin = function(container) {
21 this.container_ = container;
22 this.element_ = document.createElement('div');
23 this.element_.style.backgroundImage = 'linear-gradient(45deg, blue, red)';
26 this.connectionStatusUpdateHandler_ = null;
27 this.desktopSizeUpdateHandler_ = null;
28 this.container_.appendChild(this.element_);
31 remoting.MockClientPlugin.prototype.dispose = function() {
32 this.container_.removeChild(this.element_);
34 this.connectionStatusUpdateHandler_ = null;
37 remoting.MockClientPlugin.prototype.getDesktopWidth = function() {
41 remoting.MockClientPlugin.prototype.getDesktopHeight = function() {
45 remoting.MockClientPlugin.prototype.getDesktopXDpi = function() {
49 remoting.MockClientPlugin.prototype.getDesktopYDpi = function() {
53 remoting.MockClientPlugin.prototype.element = function() {
57 remoting.MockClientPlugin.prototype.initialize = function(onDone) {
58 window.setTimeout(onDone.bind(null, true), 0);
61 remoting.MockClientPlugin.prototype.connect = function(
62 hostJid, hostPublicKey, localJid, sharedSecret,
63 authenticationMethods, authenticationTag,
64 clientPairingId, clientPairedSecret) {
65 base.debug.assert(this.connectionStatusUpdateHandler_ != null);
67 this.connectionStatusUpdateHandler_.bind(
69 remoting.ClientSession.State.CONNECTED,
70 remoting.ClientSession.ConnectionError.NONE),
74 remoting.MockClientPlugin.prototype.injectKeyEvent =
75 function(key, down) {};
77 remoting.MockClientPlugin.prototype.remapKey = function(from, to) {};
79 remoting.MockClientPlugin.prototype.releaseAllKeys = function() {};
81 remoting.MockClientPlugin.prototype.notifyClientResolution =
82 function(width, height, dpi) {
84 this.height_ = height;
85 if (this.desktopSizeUpdateHandler_) {
86 window.setTimeout(this.desktopSizeUpdateHandler_, 0);
90 remoting.MockClientPlugin.prototype.onIncomingIq = function(iq) {};
92 remoting.MockClientPlugin.prototype.isSupportedVersion = function() {
96 remoting.MockClientPlugin.prototype.hasFeature = function(feature) {
100 remoting.MockClientPlugin.prototype.enableMediaSourceRendering =
101 function(mediaSourceRenderer) {};
103 remoting.MockClientPlugin.prototype.sendClipboardItem =
104 function(mimeType, item) {};
106 remoting.MockClientPlugin.prototype.useAsyncPinDialog = function() {};
108 remoting.MockClientPlugin.prototype.requestPairing =
109 function(clientName, onDone) {};
111 remoting.MockClientPlugin.prototype.onPinFetched = function(pin) {};
113 remoting.MockClientPlugin.prototype.onThirdPartyTokenFetched =
114 function(token, sharedSecret) {};
116 remoting.MockClientPlugin.prototype.pauseAudio = function(pause) {};
118 remoting.MockClientPlugin.prototype.pauseVideo = function(pause) {};
120 remoting.MockClientPlugin.prototype.getPerfStats = function() {
121 var result = new remoting.ClientSession.PerfStats;
122 result.videoBandwidth = 999;
123 result.videoFrameRate = 60;
124 result.captureLatency = 10;
125 result.encodeLatency = 10;
126 result.decodeLatency = 10;
127 result.renderLatency = 10;
128 result.roundtripLatency = 10;
132 remoting.MockClientPlugin.prototype.sendClientMessage =
133 function(name, data) {};
135 remoting.MockClientPlugin.prototype.setOnOutgoingIqHandler =
136 function(handler) {};
138 remoting.MockClientPlugin.prototype.setOnDebugMessageHandler =
139 function(handler) {};
141 remoting.MockClientPlugin.prototype.setConnectionStatusUpdateHandler =
143 this.connectionStatusUpdateHandler_ = handler;
146 remoting.MockClientPlugin.prototype.setConnectionReadyHandler =
147 function(handler) {};
149 remoting.MockClientPlugin.prototype.setDesktopSizeUpdateHandler =
151 this.desktopSizeUpdateHandler_ = handler;
154 remoting.MockClientPlugin.prototype.setCapabilitiesHandler =
155 function(handler) {};
157 remoting.MockClientPlugin.prototype.setGnubbyAuthHandler =
158 function(handler) {};
160 remoting.MockClientPlugin.prototype.setCastExtensionHandler =
161 function(handler) {};
163 remoting.MockClientPlugin.prototype.setMouseCursorHandler =
164 function(handler) {};
166 remoting.MockClientPlugin.prototype.setFetchThirdPartyTokenHandler =
167 function(handler) {};
169 remoting.MockClientPlugin.prototype.setFetchPinHandler =
170 function(handler) {};
175 * @extends {remoting.ClientPluginFactory}
177 remoting.MockClientPluginFactory = function() {};
179 remoting.MockClientPluginFactory.prototype.createPlugin =
180 function(container, onExtensionMessage) {
181 return new remoting.MockClientPlugin(container);
184 remoting.MockClientPluginFactory.prototype.preloadPlugin = function() {};