Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: remoting/webapp/browser_test/mock_client_plugin.js

Issue 984203003: Move mocks and unittest JS files to sit alongside production code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 /**
6 * @fileoverview
7 * Mock implementation of ClientPlugin for testing.
8 * @suppress {checkTypes}
9 */
10
11 'use strict';
12
13 /** @suppress {duplicate} */
14 var remoting = remoting || {};
15
16 /**
17 * @param {Element} container
18 * @constructor
19 * @implements {remoting.ClientPlugin}
20 */
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();
29 };
30
31 remoting.MockClientPlugin.prototype.dispose = function() {
32 this.container_.removeChild(this.element_);
33 this.element_ = null;
34 this.connectionStatusUpdateHandler_ = null;
35 };
36
37 remoting.MockClientPlugin.prototype.hostDesktop = function() {
38 return this.hostDesktop_;
39 };
40
41 remoting.MockClientPlugin.prototype.element = function() {
42 return this.element_;
43 };
44
45 remoting.MockClientPlugin.prototype.initialize = function(onDone) {
46 window.setTimeout(onDone.bind(null, true), 0);
47 };
48
49
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);
59 };
60
61 remoting.MockClientPlugin.prototype.injectKeyEvent =
62 function(key, down) {};
63
64 remoting.MockClientPlugin.prototype.remapKey = function(from, to) {};
65
66 remoting.MockClientPlugin.prototype.releaseAllKeys = function() {};
67
68 remoting.MockClientPlugin.prototype.onIncomingIq = function(iq) {};
69
70 remoting.MockClientPlugin.prototype.isSupportedVersion = function() {
71 return true;
72 };
73
74 remoting.MockClientPlugin.prototype.hasFeature = function(feature) {
75 return false;
76 };
77
78 remoting.MockClientPlugin.prototype.sendClipboardItem =
79 function(mimeType, item) {};
80
81 remoting.MockClientPlugin.prototype.requestPairing =
82 function(clientName, onDone) {};
83
84 remoting.MockClientPlugin.prototype.pauseAudio = function(pause) {};
85
86 remoting.MockClientPlugin.prototype.pauseVideo = function(pause) {};
87
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;
98 };
99
100 remoting.MockClientPlugin.prototype.sendClientMessage =
101 function(name, data) {};
102
103 remoting.MockClientPlugin.prototype.setOnOutgoingIqHandler =
104 function(handler) {};
105
106 remoting.MockClientPlugin.prototype.setOnDebugMessageHandler =
107 function(handler) {};
108
109 /**
110 * @param {function(number, number):void} handler
111 * @private
112 */
113 remoting.MockClientPlugin.prototype.setConnectionStatusUpdateHandler =
114 function(handler) {
115 /** @type {function(number, number):void} */
116 this.connectionStatusUpdateHandler_ = handler;
117 };
118
119 remoting.MockClientPlugin.prototype.setRouteChangedHandler =
120 function(handler) {};
121
122 remoting.MockClientPlugin.prototype.setConnectionReadyHandler =
123 function(handler) {};
124
125 remoting.MockClientPlugin.prototype.setCapabilitiesHandler =
126 function(handler) {};
127
128 remoting.MockClientPlugin.prototype.setGnubbyAuthHandler =
129 function(handler) {};
130
131 remoting.MockClientPlugin.prototype.setCastExtensionHandler =
132 function(handler) {};
133
134 remoting.MockClientPlugin.prototype.setMouseCursorHandler =
135 function(handler) {};
136
137 /**
138 * @constructor
139 * @implements {remoting.HostDesktop}
140 * @extends {base.EventSourceImpl}
141 */
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));
154 };
155 base.extend(remoting.MockClientPlugin.HostDesktop, base.EventSourceImpl);
156
157 /**
158 * @return {{width:number, height:number, xDpi:number, yDpi:number}}
159 * @override
160 */
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_
167 };
168 };
169
170 /**
171 * @return {boolean}
172 * @override
173 */
174 remoting.MockClientPlugin.HostDesktop.prototype.isResizable = function() {
175 return this.resizable_;
176 };
177
178 /**
179 * @param {number} width
180 * @param {number} height
181 * @param {number} deviceScale
182 * @override
183 */
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());
191 };
192
193 /**
194 * @constructor
195 * @extends {remoting.ClientPluginFactory}
196 */
197 remoting.MockClientPluginFactory = function() {};
198
199 remoting.MockClientPluginFactory.prototype.createPlugin =
200 function(container, onExtensionMessage) {
201 return new remoting.MockClientPlugin(container);
202 };
203
204 remoting.MockClientPluginFactory.prototype.preloadPlugin = function() {};
OLDNEW
« no previous file with comments | « remoting/webapp/base/js/ipc_unittest.js ('k') | remoting/webapp/browser_test/mock_host_list_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698