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);
50 remoting
.MockClientPlugin
.prototype.connect
=
51 function(host
, localJid
, credentialsProvider
) {
52 base
.debug
.assert(this.connectionStatusUpdateHandler_
!= null);
54 this.connectionStatusUpdateHandler_
.bind(
56 remoting
.ClientSession
.State
.CONNECTED
,
57 remoting
.ClientSession
.ConnectionError
.NONE
),
61 remoting
.MockClientPlugin
.prototype.injectKeyEvent
=
62 function(key
, down
) {};
64 remoting
.MockClientPlugin
.prototype.remapKey = function(from, to
) {};
66 remoting
.MockClientPlugin
.prototype.releaseAllKeys = function() {};
68 remoting
.MockClientPlugin
.prototype.onIncomingIq = function(iq
) {};
70 remoting
.MockClientPlugin
.prototype.isSupportedVersion = function() {
74 remoting
.MockClientPlugin
.prototype.hasFeature = function(feature
) {
78 remoting
.MockClientPlugin
.prototype.sendClipboardItem
=
79 function(mimeType
, item
) {};
81 remoting
.MockClientPlugin
.prototype.requestPairing
=
82 function(clientName
, onDone
) {};
84 remoting
.MockClientPlugin
.prototype.pauseAudio = function(pause
) {};
86 remoting
.MockClientPlugin
.prototype.pauseVideo = function(pause
) {};
88 remoting
.MockClientPlugin
.prototype.getPerfStats = function() {
89 var result
= new remoting
.ClientSession
.PerfStats
;
90 result
.videoBandwidth
= 999;
91 result
.videoFrameRate
= 60;
92 result
.captureLatency
= 10;
93 result
.encodeLatency
= 10;
94 result
.decodeLatency
= 10;
95 result
.renderLatency
= 10;
96 result
.roundtripLatency
= 10;
100 remoting
.MockClientPlugin
.prototype.sendClientMessage
=
101 function(name
, data
) {};
103 remoting
.MockClientPlugin
.prototype.setOnOutgoingIqHandler
=
104 function(handler
) {};
106 remoting
.MockClientPlugin
.prototype.setOnDebugMessageHandler
=
107 function(handler
) {};
110 * @param {function(number, number):void} handler
113 remoting
.MockClientPlugin
.prototype.setConnectionStatusUpdateHandler
=
115 /** @type {function(number, number):void} */
116 this.connectionStatusUpdateHandler_
= handler
;
119 remoting
.MockClientPlugin
.prototype.setRouteChangedHandler
=
120 function(handler
) {};
122 remoting
.MockClientPlugin
.prototype.setConnectionReadyHandler
=
123 function(handler
) {};
125 remoting
.MockClientPlugin
.prototype.setCapabilitiesHandler
=
126 function(handler
) {};
128 remoting
.MockClientPlugin
.prototype.setGnubbyAuthHandler
=
129 function(handler
) {};
131 remoting
.MockClientPlugin
.prototype.setCastExtensionHandler
=
132 function(handler
) {};
134 remoting
.MockClientPlugin
.prototype.setMouseCursorHandler
=
135 function(handler
) {};
139 * @implements {remoting.HostDesktop}
140 * @extends {base.EventSourceImpl}
142 remoting
.MockClientPlugin
.HostDesktop = function() {
152 this.resizable_
= true;
153 this.defineEvents(base
.values(remoting
.HostDesktop
.Events
));
155 base
.extend(remoting
.MockClientPlugin
.HostDesktop
, base
.EventSourceImpl
);
158 * @return {{width:number, height:number, xDpi:number, yDpi:number}}
161 remoting
.MockClientPlugin
.HostDesktop
.prototype.getDimensions = function() {
164 height
: this.height_
,
174 remoting
.MockClientPlugin
.HostDesktop
.prototype.isResizable = function() {
175 return this.resizable_
;
179 * @param {number} width
180 * @param {number} height
181 * @param {number} deviceScale
184 remoting
.MockClientPlugin
.HostDesktop
.prototype.resize
=
185 function(width
, height
, deviceScale
) {
187 this.height_
= height
;
188 this.xDpi_
= this.yDpi_
= Math
.floor(deviceScale
* 96);
189 this.raiseEvent(remoting
.HostDesktop
.Events
.sizeChanged
,
190 this.getDimensions());
195 * @extends {remoting.ClientPluginFactory}
197 remoting
.MockClientPluginFactory = function() {};
199 remoting
.MockClientPluginFactory
.prototype.createPlugin
=
200 function(container
, onExtensionMessage
) {
201 return new remoting
.MockClientPlugin(container
);
204 remoting
.MockClientPluginFactory
.prototype.preloadPlugin = function() {};