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

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

Issue 929323003: Separate host desktop related functionality into remoting.HostDesktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's feedback Created 5 years, 10 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Mock implementation of ClientPlugin for testing. 7 * Mock implementation of ClientPlugin for testing.
8 * @suppress {checkTypes} 8 * @suppress {checkTypes}
9 */ 9 */
10 10
11 'use strict'; 11 'use strict';
12 12
13 /** @suppress {duplicate} */ 13 /** @suppress {duplicate} */
14 var remoting = remoting || {}; 14 var remoting = remoting || {};
15 15
16 /** 16 /**
17 * @constructor 17 * @constructor
18 * @implements {remoting.ClientPlugin} 18 * @implements {remoting.ClientPlugin}
19 */ 19 */
20 remoting.MockClientPlugin = function(container) { 20 remoting.MockClientPlugin = function(container) {
21 this.container_ = container; 21 this.container_ = container;
22 this.element_ = document.createElement('div'); 22 this.element_ = document.createElement('div');
23 this.element_.style.backgroundImage = 'linear-gradient(45deg, blue, red)'; 23 this.element_.style.backgroundImage = 'linear-gradient(45deg, blue, red)';
24 this.width_ = 640;
25 this.height_ = 480;
26 this.connectionStatusUpdateHandler_ = null; 24 this.connectionStatusUpdateHandler_ = null;
27 this.desktopSizeUpdateHandler_ = null; 25 this.desktopSizeUpdateHandler_ = null;
28 this.container_.appendChild(this.element_); 26 this.container_.appendChild(this.element_);
27 this.hostDesktop_ = new remoting.MockClientPlugin.HostDesktop();
29 }; 28 };
30 29
31 remoting.MockClientPlugin.prototype.dispose = function() { 30 remoting.MockClientPlugin.prototype.dispose = function() {
32 this.container_.removeChild(this.element_); 31 this.container_.removeChild(this.element_);
33 this.element_ = null; 32 this.element_ = null;
34 this.connectionStatusUpdateHandler_ = null; 33 this.connectionStatusUpdateHandler_ = null;
35 }; 34 };
36 35
37 remoting.MockClientPlugin.prototype.getDesktopWidth = function() { 36 remoting.MockClientPlugin.prototype.hostDesktop = function() {
38 return this.width_; 37 return this.hostDesktop_;
39 };
40
41 remoting.MockClientPlugin.prototype.getDesktopHeight = function() {
42 return this.height_;
43 };
44
45 remoting.MockClientPlugin.prototype.getDesktopXDpi = function() {
46 return 96;
47 };
48
49 remoting.MockClientPlugin.prototype.getDesktopYDpi = function() {
50 return 96;
51 }; 38 };
52 39
53 remoting.MockClientPlugin.prototype.element = function() { 40 remoting.MockClientPlugin.prototype.element = function() {
54 return this.element_; 41 return this.element_;
55 }; 42 };
56 43
57 remoting.MockClientPlugin.prototype.initialize = function(onDone) { 44 remoting.MockClientPlugin.prototype.initialize = function(onDone) {
58 window.setTimeout(onDone.bind(null, true), 0); 45 window.setTimeout(onDone.bind(null, true), 0);
59 }; 46 };
60 47
(...skipping 10 matching lines...) Expand all
71 0); 58 0);
72 }; 59 };
73 60
74 remoting.MockClientPlugin.prototype.injectKeyEvent = 61 remoting.MockClientPlugin.prototype.injectKeyEvent =
75 function(key, down) {}; 62 function(key, down) {};
76 63
77 remoting.MockClientPlugin.prototype.remapKey = function(from, to) {}; 64 remoting.MockClientPlugin.prototype.remapKey = function(from, to) {};
78 65
79 remoting.MockClientPlugin.prototype.releaseAllKeys = function() {}; 66 remoting.MockClientPlugin.prototype.releaseAllKeys = function() {};
80 67
81 remoting.MockClientPlugin.prototype.notifyClientResolution =
82 function(width, height, dpi) {
83 this.width_ = width;
84 this.height_ = height;
85 if (this.desktopSizeUpdateHandler_) {
86 window.setTimeout(this.desktopSizeUpdateHandler_, 0);
87 }
88 };
89
90 remoting.MockClientPlugin.prototype.onIncomingIq = function(iq) {}; 68 remoting.MockClientPlugin.prototype.onIncomingIq = function(iq) {};
91 69
92 remoting.MockClientPlugin.prototype.isSupportedVersion = function() { 70 remoting.MockClientPlugin.prototype.isSupportedVersion = function() {
93 return true; 71 return true;
94 }; 72 };
95 73
96 remoting.MockClientPlugin.prototype.hasFeature = function(feature) { 74 remoting.MockClientPlugin.prototype.hasFeature = function(feature) {
97 return false; 75 return false;
98 }; 76 };
99 77
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 function(handler) { 117 function(handler) {
140 this.connectionStatusUpdateHandler_ = handler; 118 this.connectionStatusUpdateHandler_ = handler;
141 }; 119 };
142 120
143 remoting.MockClientPlugin.prototype.setRouteChangedHandler = 121 remoting.MockClientPlugin.prototype.setRouteChangedHandler =
144 function(handler) {}; 122 function(handler) {};
145 123
146 remoting.MockClientPlugin.prototype.setConnectionReadyHandler = 124 remoting.MockClientPlugin.prototype.setConnectionReadyHandler =
147 function(handler) {}; 125 function(handler) {};
148 126
149 remoting.MockClientPlugin.prototype.setDesktopSizeUpdateHandler =
150 function(handler) {
151 this.desktopSizeUpdateHandler_ = handler;
152 };
153
154 remoting.MockClientPlugin.prototype.setCapabilitiesHandler = 127 remoting.MockClientPlugin.prototype.setCapabilitiesHandler =
155 function(handler) {}; 128 function(handler) {};
156 129
157 remoting.MockClientPlugin.prototype.setGnubbyAuthHandler = 130 remoting.MockClientPlugin.prototype.setGnubbyAuthHandler =
158 function(handler) {}; 131 function(handler) {};
159 132
160 remoting.MockClientPlugin.prototype.setCastExtensionHandler = 133 remoting.MockClientPlugin.prototype.setCastExtensionHandler =
161 function(handler) {}; 134 function(handler) {};
162 135
163 remoting.MockClientPlugin.prototype.setMouseCursorHandler = 136 remoting.MockClientPlugin.prototype.setMouseCursorHandler =
164 function(handler) {}; 137 function(handler) {};
165 138
166 remoting.MockClientPlugin.prototype.setFetchThirdPartyTokenHandler = 139 remoting.MockClientPlugin.prototype.setFetchThirdPartyTokenHandler =
167 function(handler) {}; 140 function(handler) {};
168 141
169 remoting.MockClientPlugin.prototype.setFetchPinHandler = 142 remoting.MockClientPlugin.prototype.setFetchPinHandler =
170 function(handler) {}; 143 function(handler) {};
171 144
145 /**
146 * @constructor
147 * @implements {remoting.HostDesktop}
148 */
149 remoting.MockClientPlugin.HostDesktop = function() {
150 /** @private */
151 this.width_ = 0;
152 /** @private */
153 this.height_ = 0;
154 /** @private */
155 this.xDpi_ = 96;
156 /** @private */
157 this.yDpi_ = 96;
158 /** @private */
159 this.resizable_ = true;
160 this.defineEvents(Object.keys(remoting.ClientPlugin.HostDesktop.Events));
161 };
162 base.extend(remoting.MockClientPlugin.HostDesktop, base.EventSourceImpl);
163
164 /**
165 * @return {{width:number, height:number, xDpi:number, yDpi:number}}
166 * @override
167 */
168 remoting.MockClientPlugin.HostDesktop.prototype.getDimensions = function() {
169 return {
170 width: this.width_,
171 height: this.height_,
172 xDpi: this.xDpi_,
173 yDpi: this.yDpi_
174 };
175 };
176
177 /**
178 * @return {boolean}
179 * @override
180 */
181 remoting.MockClientPlugin.HostDesktop.prototype.isResizable = function() {
182 return this.resizable_;
183 };
184
185 /**
186 * @return {boolean}
187 * @override
188 */
189 remoting.MockClientPlugin.HostDesktop.prototype.hasResizeRateLimit =
190 function() {
191 return false;
Jamie 2015/02/18 23:06:19 Nit: Indentation.
kelvinp 2015/02/19 20:58:14 Done.
192 };
193
194 /**
195 * @param {number} width
196 * @param {number} height
197 * @param {number} dpi
198 * @override
199 */
200 remoting.MockClientPlugin.HostDesktop.prototype.resize = function(
201 width, height, device_scale) {
Jamie 2015/02/18 23:06:19 s/device_scale/dpi/
kelvinp 2015/02/19 20:58:15 The parameter is about device scale (1.0) instead
202 this.width_ = width;
203 this.height_ = height;
204 this.xDpi_ = this.yDpi_ = device_scale;
205 this.raiseEvent(remoting.ClientPlugin.HostDesktop.Events.sizeChanged);
Jamie 2015/02/18 23:06:19 How does the event recipient know the new size? It
kelvinp 2015/02/19 20:58:15 Done. In order to hook this event, the client alr
206 };
172 207
173 /** 208 /**
174 * @constructor 209 * @constructor
175 * @extends {remoting.ClientPluginFactory} 210 * @extends {remoting.ClientPluginFactory}
176 */ 211 */
177 remoting.MockClientPluginFactory = function() {}; 212 remoting.MockClientPluginFactory = function() {};
178 213
179 remoting.MockClientPluginFactory.prototype.createPlugin = 214 remoting.MockClientPluginFactory.prototype.createPlugin =
180 function(container, onExtensionMessage) { 215 function(container, onExtensionMessage) {
181 return new remoting.MockClientPlugin(container); 216 return new remoting.MockClientPlugin(container);
182 }; 217 };
183 218
184 remoting.MockClientPluginFactory.prototype.preloadPlugin = function() {}; 219 remoting.MockClientPluginFactory.prototype.preloadPlugin = function() {};
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698