ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / remoting / webapp / browser_test / mock_client_plugin.js
blob8a8dafad8d4980c8181817eb0c7de8587ba4e3eb
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.
5 /**
6 * @fileoverview
7 * Mock implementation of ClientPlugin for testing.
8 * @suppress {checkTypes}
9 */
11 'use strict';
13 /** @suppress {duplicate} */
14 var remoting = remoting || {};
16 /**
17 * @param {Element} container
18 * @constructor
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_);
33 this.element_ = null;
34 this.connectionStatusUpdateHandler_ = null;
37 remoting.MockClientPlugin.prototype.hostDesktop = function() {
38 return this.hostDesktop_;
41 remoting.MockClientPlugin.prototype.element = function() {
42 return this.element_;
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);
53 window.setTimeout(
54 this.connectionStatusUpdateHandler_.bind(
55 this,
56 remoting.ClientSession.State.CONNECTED,
57 remoting.ClientSession.ConnectionError.NONE),
58 0);
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() {
71 return true;
74 remoting.MockClientPlugin.prototype.hasFeature = function(feature) {
75 return false;
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;
97 return result;
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
111 * @private
113 remoting.MockClientPlugin.prototype.setConnectionStatusUpdateHandler =
114 function(handler) {
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) {};
138 * @constructor
139 * @implements {remoting.HostDesktop}
140 * @extends {base.EventSourceImpl}
142 remoting.MockClientPlugin.HostDesktop = function() {
143 /** @private */
144 this.width_ = 0;
145 /** @private */
146 this.height_ = 0;
147 /** @private */
148 this.xDpi_ = 96;
149 /** @private */
150 this.yDpi_ = 96;
151 /** @private */
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}}
159 * @override
161 remoting.MockClientPlugin.HostDesktop.prototype.getDimensions = function() {
162 return {
163 width: this.width_,
164 height: this.height_,
165 xDpi: this.xDpi_,
166 yDpi: this.yDpi_
171 * @return {boolean}
172 * @override
174 remoting.MockClientPlugin.HostDesktop.prototype.isResizable = function() {
175 return this.resizable_;
179 * @param {number} width
180 * @param {number} height
181 * @param {number} deviceScale
182 * @override
184 remoting.MockClientPlugin.HostDesktop.prototype.resize =
185 function(width, height, deviceScale) {
186 this.width_ = width;
187 this.height_ = height;
188 this.xDpi_ = this.yDpi_ = Math.floor(deviceScale * 96);
189 this.raiseEvent(remoting.HostDesktop.Events.sizeChanged,
190 this.getDimensions());
194 * @constructor
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() {};