OLD | NEW |
---|---|
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 12 matching lines...) Expand all Loading... | |
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 = | 68 remoting.MockClientPlugin.prototype.notifyClientResolution = |
82 function(width, height, dpi) { | 69 function(width, height, dpi) { |
83 this.width_ = width; | 70 this.hostDesktop_.resize(width, height, dpi); |
84 this.height_ = height; | |
85 if (this.desktopSizeUpdateHandler_) { | 71 if (this.desktopSizeUpdateHandler_) { |
86 window.setTimeout(this.desktopSizeUpdateHandler_, 0); | 72 window.setTimeout(this.desktopSizeUpdateHandler_, 0); |
87 } | 73 } |
88 }; | 74 }; |
89 | 75 |
90 remoting.MockClientPlugin.prototype.onIncomingIq = function(iq) {}; | 76 remoting.MockClientPlugin.prototype.onIncomingIq = function(iq) {}; |
91 | 77 |
92 remoting.MockClientPlugin.prototype.isSupportedVersion = function() { | 78 remoting.MockClientPlugin.prototype.isSupportedVersion = function() { |
93 return true; | 79 return true; |
94 }; | 80 }; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 function(handler) { | 125 function(handler) { |
140 this.connectionStatusUpdateHandler_ = handler; | 126 this.connectionStatusUpdateHandler_ = handler; |
141 }; | 127 }; |
142 | 128 |
143 remoting.MockClientPlugin.prototype.setRouteChangedHandler = | 129 remoting.MockClientPlugin.prototype.setRouteChangedHandler = |
144 function(handler) {}; | 130 function(handler) {}; |
145 | 131 |
146 remoting.MockClientPlugin.prototype.setConnectionReadyHandler = | 132 remoting.MockClientPlugin.prototype.setConnectionReadyHandler = |
147 function(handler) {}; | 133 function(handler) {}; |
148 | 134 |
149 remoting.MockClientPlugin.prototype.setDesktopSizeUpdateHandler = | |
150 function(handler) { | |
151 this.desktopSizeUpdateHandler_ = handler; | |
152 }; | |
153 | |
154 remoting.MockClientPlugin.prototype.setCapabilitiesHandler = | 135 remoting.MockClientPlugin.prototype.setCapabilitiesHandler = |
155 function(handler) {}; | 136 function(handler) {}; |
156 | 137 |
157 remoting.MockClientPlugin.prototype.setGnubbyAuthHandler = | 138 remoting.MockClientPlugin.prototype.setGnubbyAuthHandler = |
158 function(handler) {}; | 139 function(handler) {}; |
159 | 140 |
160 remoting.MockClientPlugin.prototype.setCastExtensionHandler = | 141 remoting.MockClientPlugin.prototype.setCastExtensionHandler = |
161 function(handler) {}; | 142 function(handler) {}; |
162 | 143 |
163 remoting.MockClientPlugin.prototype.setMouseCursorHandler = | 144 remoting.MockClientPlugin.prototype.setMouseCursorHandler = |
164 function(handler) {}; | 145 function(handler) {}; |
165 | 146 |
166 remoting.MockClientPlugin.prototype.setFetchThirdPartyTokenHandler = | 147 remoting.MockClientPlugin.prototype.setFetchThirdPartyTokenHandler = |
167 function(handler) {}; | 148 function(handler) {}; |
168 | 149 |
169 remoting.MockClientPlugin.prototype.setFetchPinHandler = | 150 remoting.MockClientPlugin.prototype.setFetchPinHandler = |
170 function(handler) {}; | 151 function(handler) {}; |
171 | 152 |
153 remoting.MockClientPlugin.HostDesktop = function() { | |
Jamie
2015/02/18 00:33:10
Although we don't run jscompile over this file, it
| |
154 this.width_ = 0; | |
155 this.height_ = 0; | |
156 this.xDpi_ = 96; | |
157 this.yDpi_ = 96; | |
158 this.resizable_ = true; | |
159 this.defineEvents(Object.keys(remoting.ClientPlugin.HostDesktop.Events)); | |
160 }; | |
161 base.extend(remoting.MockClientPlugin.HostDesktop, base.EventSourceImpl); | |
162 | |
163 remoting.MockClientPlugin.HostDesktop.prototype.getDimensions = function() { | |
164 return { | |
165 width: this.width_, | |
166 height: this.height_, | |
167 xDpi: this.xDpi_, | |
168 yDpi: this.yDpi_ | |
169 }; | |
170 }; | |
171 | |
172 remoting.MockClientPlugin.HostDesktop.prototype.isResizable = function() { | |
173 return this.resizable_; | |
174 }; | |
175 | |
176 remoting.MockClientPlugin.HostDesktop.prototype.hasResizeRateLimit = | |
177 function() { | |
178 return false; | |
179 }; | |
180 | |
181 remoting.MockClientPlugin.HostDesktop.prototype.resize = function( | |
182 width, height, device_scale) { | |
183 this.width_ = width; | |
184 this.height_ = height; | |
185 this.xDpi_ = this.yDpi_ = device_scale; | |
186 this.raiseEvent(remoting.ClientPlugin.HostDesktop.Events.sizeChanged); | |
187 }; | |
172 | 188 |
173 /** | 189 /** |
174 * @constructor | 190 * @constructor |
175 * @extends {remoting.ClientPluginFactory} | 191 * @extends {remoting.ClientPluginFactory} |
176 */ | 192 */ |
177 remoting.MockClientPluginFactory = function() {}; | 193 remoting.MockClientPluginFactory = function() {}; |
178 | 194 |
179 remoting.MockClientPluginFactory.prototype.createPlugin = | 195 remoting.MockClientPluginFactory.prototype.createPlugin = |
180 function(container, onExtensionMessage) { | 196 function(container, onExtensionMessage) { |
181 return new remoting.MockClientPlugin(container); | 197 return new remoting.MockClientPlugin(container); |
182 }; | 198 }; |
183 | 199 |
184 remoting.MockClientPluginFactory.prototype.preloadPlugin = function() {}; | 200 remoting.MockClientPluginFactory.prototype.preloadPlugin = function() {}; |
OLD | NEW |