Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / remoting / webapp / browser_test / mock_client_plugin.js
blob09858e0a179fa932916d3dadf39278a710e2c480
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);
49 remoting.MockClientPlugin.prototype.connect = function(
50 hostJid, hostPublicKey, localJid, sharedSecret,
51 authenticationMethods, authenticationTag,
52 clientPairingId, clientPairedSecret) {
53 base.debug.assert(this.connectionStatusUpdateHandler_ != null);
54 window.setTimeout(
55 this.connectionStatusUpdateHandler_.bind(
56 this,
57 remoting.ClientSession.State.CONNECTED,
58 remoting.ClientSession.ConnectionError.NONE),
59 0);
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() {
72 return true;
75 remoting.MockClientPlugin.prototype.hasFeature = function(feature) {
76 return false;
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;
105 return result;
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
119 * @private
121 remoting.MockClientPlugin.prototype.setConnectionStatusUpdateHandler =
122 function(handler) {
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) {};
152 * @constructor
153 * @implements {remoting.HostDesktop}
154 * @extends {base.EventSourceImpl}
156 remoting.MockClientPlugin.HostDesktop = function() {
157 /** @private */
158 this.width_ = 0;
159 /** @private */
160 this.height_ = 0;
161 /** @private */
162 this.xDpi_ = 96;
163 /** @private */
164 this.yDpi_ = 96;
165 /** @private */
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}}
173 * @override
175 remoting.MockClientPlugin.HostDesktop.prototype.getDimensions = function() {
176 return {
177 width: this.width_,
178 height: this.height_,
179 xDpi: this.xDpi_,
180 yDpi: this.yDpi_
185 * @return {boolean}
186 * @override
188 remoting.MockClientPlugin.HostDesktop.prototype.isResizable = function() {
189 return this.resizable_;
193 * @param {number} width
194 * @param {number} height
195 * @param {number} deviceScale
196 * @override
198 remoting.MockClientPlugin.HostDesktop.prototype.resize =
199 function(width, height, deviceScale) {
200 this.width_ = width;
201 this.height_ = height;
202 this.xDpi_ = this.yDpi_ = Math.floor(deviceScale * 96);
203 this.raiseEvent(remoting.HostDesktop.Events.sizeChanged,
204 this.getDimensions());
208 * @constructor
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() {};