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
|| {};
17 * @param {Element} container
19 * @implements {remoting.ClientPlugin}
21 remoting
.MockClientPlugin = function(container
) {
22 this.container_
= container
;
23 this.element_
= document
.createElement('div');
24 this.element_
.style
.backgroundImage
= 'linear-gradient(45deg, blue, red)';
25 this.connectionStatusUpdateHandler_
= null;
26 this.desktopSizeUpdateHandler_
= null;
27 this.container_
.appendChild(this.element_
);
28 this.hostDesktop_
= new remoting
.MockClientPlugin
.HostDesktop();
31 remoting
.MockClientPlugin
.prototype.dispose = function() {
32 this.container_
.removeChild(this.element_
);
34 this.connectionStatusUpdateHandler_
= null;
37 remoting
.MockClientPlugin
.prototype.hostDesktop = function() {
38 return this.hostDesktop_
;
41 remoting
.MockClientPlugin
.prototype.element = function() {
45 remoting
.MockClientPlugin
.prototype.initialize = function(onDone
) {
46 window
.setTimeout(onDone
.bind(null, true), 0);
49 remoting
.MockClientPlugin
.prototype.connect = function(
50 hostJid
, hostPublicKey
, localJid
, sharedSecret
,
51 authenticationMethods
, authenticationTag
,
52 clientPairingId
, clientPairedSecret
) {
53 base
.debug
.assert(this.connectionStatusUpdateHandler_
!= null);
55 this.connectionStatusUpdateHandler_
.bind(
57 remoting
.ClientSession
.State
.CONNECTED
,
58 remoting
.ClientSession
.ConnectionError
.NONE
),
62 remoting
.MockClientPlugin
.prototype.injectKeyEvent
=
63 function(key
, down
) {};
65 remoting
.MockClientPlugin
.prototype.remapKey = function(from, to
) {};
67 remoting
.MockClientPlugin
.prototype.releaseAllKeys = function() {};
69 remoting
.MockClientPlugin
.prototype.onIncomingIq = function(iq
) {};
71 remoting
.MockClientPlugin
.prototype.isSupportedVersion = function() {
75 remoting
.MockClientPlugin
.prototype.hasFeature = function(feature
) {
79 remoting
.MockClientPlugin
.prototype.sendClipboardItem
=
80 function(mimeType
, item
) {};
82 remoting
.MockClientPlugin
.prototype.useAsyncPinDialog = function() {};
84 remoting
.MockClientPlugin
.prototype.requestPairing
=
85 function(clientName
, onDone
) {};
87 remoting
.MockClientPlugin
.prototype.onPinFetched = function(pin
) {};
89 remoting
.MockClientPlugin
.prototype.onThirdPartyTokenFetched
=
90 function(token
, sharedSecret
) {};
92 remoting
.MockClientPlugin
.prototype.pauseAudio = function(pause
) {};
94 remoting
.MockClientPlugin
.prototype.pauseVideo = function(pause
) {};
96 remoting
.MockClientPlugin
.prototype.getPerfStats = function() {
97 var result
= new remoting
.ClientSession
.PerfStats
;
98 result
.videoBandwidth
= 999;
99 result
.videoFrameRate
= 60;
100 result
.captureLatency
= 10;
101 result
.encodeLatency
= 10;
102 result
.decodeLatency
= 10;
103 result
.renderLatency
= 10;
104 result
.roundtripLatency
= 10;
108 remoting
.MockClientPlugin
.prototype.sendClientMessage
=
109 function(name
, data
) {};
111 remoting
.MockClientPlugin
.prototype.setOnOutgoingIqHandler
=
112 function(handler
) {};
114 remoting
.MockClientPlugin
.prototype.setOnDebugMessageHandler
=
115 function(handler
) {};
118 * @param {function(number, number):void} handler
121 remoting
.MockClientPlugin
.prototype.setConnectionStatusUpdateHandler
=
123 /** @type {function(number, number):void} */
124 this.connectionStatusUpdateHandler_
= handler
;
127 remoting
.MockClientPlugin
.prototype.setRouteChangedHandler
=
128 function(handler
) {};
130 remoting
.MockClientPlugin
.prototype.setConnectionReadyHandler
=
131 function(handler
) {};
133 remoting
.MockClientPlugin
.prototype.setCapabilitiesHandler
=
134 function(handler
) {};
136 remoting
.MockClientPlugin
.prototype.setGnubbyAuthHandler
=
137 function(handler
) {};
139 remoting
.MockClientPlugin
.prototype.setCastExtensionHandler
=
140 function(handler
) {};
142 remoting
.MockClientPlugin
.prototype.setMouseCursorHandler
=
143 function(handler
) {};
145 remoting
.MockClientPlugin
.prototype.setFetchThirdPartyTokenHandler
=
146 function(handler
) {};
148 remoting
.MockClientPlugin
.prototype.setFetchPinHandler
=
149 function(handler
) {};
153 * @implements {remoting.HostDesktop}
154 * @extends {base.EventSourceImpl}
156 remoting
.MockClientPlugin
.HostDesktop = function() {
166 this.resizable_
= true;
167 this.defineEvents(base
.values(remoting
.HostDesktop
.Events
));
169 base
.extend(remoting
.MockClientPlugin
.HostDesktop
, base
.EventSourceImpl
);
172 * @return {{width:number, height:number, xDpi:number, yDpi:number}}
175 remoting
.MockClientPlugin
.HostDesktop
.prototype.getDimensions = function() {
178 height
: this.height_
,
188 remoting
.MockClientPlugin
.HostDesktop
.prototype.isResizable = function() {
189 return this.resizable_
;
193 * @param {number} width
194 * @param {number} height
195 * @param {number} deviceScale
198 remoting
.MockClientPlugin
.HostDesktop
.prototype.resize
=
199 function(width
, height
, deviceScale
) {
201 this.height_
= height
;
202 this.xDpi_
= this.yDpi_
= Math
.floor(deviceScale
* 96);
203 this.raiseEvent(remoting
.HostDesktop
.Events
.sizeChanged
,
204 this.getDimensions());
209 * @extends {remoting.ClientPluginFactory}
211 remoting
.MockClientPluginFactory = function() {};
213 remoting
.MockClientPluginFactory
.prototype.createPlugin
=
214 function(container
, onExtensionMessage
) {
215 return new remoting
.MockClientPlugin(container
);
218 remoting
.MockClientPluginFactory
.prototype.preloadPlugin = function() {};