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

Unified 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: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/crd/js/client_plugin.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/browser_test/mock_client_plugin.js
diff --git a/remoting/webapp/browser_test/mock_client_plugin.js b/remoting/webapp/browser_test/mock_client_plugin.js
index 2ba1145391a639f3c70ef1d22f88c0b0aaa84771..09858e0a179fa932916d3dadf39278a710e2c480 100644
--- a/remoting/webapp/browser_test/mock_client_plugin.js
+++ b/remoting/webapp/browser_test/mock_client_plugin.js
@@ -22,11 +22,10 @@ remoting.MockClientPlugin = function(container) {
this.container_ = container;
this.element_ = document.createElement('div');
this.element_.style.backgroundImage = 'linear-gradient(45deg, blue, red)';
- this.width_ = 640;
- this.height_ = 480;
this.connectionStatusUpdateHandler_ = null;
this.desktopSizeUpdateHandler_ = null;
this.container_.appendChild(this.element_);
+ this.hostDesktop_ = new remoting.MockClientPlugin.HostDesktop();
};
remoting.MockClientPlugin.prototype.dispose = function() {
@@ -35,20 +34,8 @@ remoting.MockClientPlugin.prototype.dispose = function() {
this.connectionStatusUpdateHandler_ = null;
};
-remoting.MockClientPlugin.prototype.getDesktopWidth = function() {
- return this.width_;
-};
-
-remoting.MockClientPlugin.prototype.getDesktopHeight = function() {
- return this.height_;
-};
-
-remoting.MockClientPlugin.prototype.getDesktopXDpi = function() {
- return 96;
-};
-
-remoting.MockClientPlugin.prototype.getDesktopYDpi = function() {
- return 96;
+remoting.MockClientPlugin.prototype.hostDesktop = function() {
+ return this.hostDesktop_;
};
remoting.MockClientPlugin.prototype.element = function() {
@@ -79,15 +66,6 @@ remoting.MockClientPlugin.prototype.remapKey = function(from, to) {};
remoting.MockClientPlugin.prototype.releaseAllKeys = function() {};
-remoting.MockClientPlugin.prototype.notifyClientResolution =
- function(width, height, dpi) {
- this.width_ = width;
- this.height_ = height;
- if (this.desktopSizeUpdateHandler_) {
- window.setTimeout(this.desktopSizeUpdateHandler_, 0);
- }
-};
-
remoting.MockClientPlugin.prototype.onIncomingIq = function(iq) {};
remoting.MockClientPlugin.prototype.isSupportedVersion = function() {
@@ -152,11 +130,6 @@ remoting.MockClientPlugin.prototype.setRouteChangedHandler =
remoting.MockClientPlugin.prototype.setConnectionReadyHandler =
function(handler) {};
-remoting.MockClientPlugin.prototype.setDesktopSizeUpdateHandler =
- function(handler) {
- this.desktopSizeUpdateHandler_ = handler;
-};
-
remoting.MockClientPlugin.prototype.setCapabilitiesHandler =
function(handler) {};
@@ -175,6 +148,61 @@ remoting.MockClientPlugin.prototype.setFetchThirdPartyTokenHandler =
remoting.MockClientPlugin.prototype.setFetchPinHandler =
function(handler) {};
+/**
+ * @constructor
+ * @implements {remoting.HostDesktop}
+ * @extends {base.EventSourceImpl}
+ */
+remoting.MockClientPlugin.HostDesktop = function() {
+ /** @private */
+ this.width_ = 0;
+ /** @private */
+ this.height_ = 0;
+ /** @private */
+ this.xDpi_ = 96;
+ /** @private */
+ this.yDpi_ = 96;
+ /** @private */
+ this.resizable_ = true;
+ this.defineEvents(base.values(remoting.HostDesktop.Events));
+};
+base.extend(remoting.MockClientPlugin.HostDesktop, base.EventSourceImpl);
+
+/**
+ * @return {{width:number, height:number, xDpi:number, yDpi:number}}
+ * @override
+ */
+remoting.MockClientPlugin.HostDesktop.prototype.getDimensions = function() {
+ return {
+ width: this.width_,
+ height: this.height_,
+ xDpi: this.xDpi_,
+ yDpi: this.yDpi_
+ };
+};
+
+/**
+ * @return {boolean}
+ * @override
+ */
+remoting.MockClientPlugin.HostDesktop.prototype.isResizable = function() {
+ return this.resizable_;
+};
+
+/**
+ * @param {number} width
+ * @param {number} height
+ * @param {number} deviceScale
+ * @override
+ */
+remoting.MockClientPlugin.HostDesktop.prototype.resize =
+ function(width, height, deviceScale) {
+ this.width_ = width;
+ this.height_ = height;
+ this.xDpi_ = this.yDpi_ = Math.floor(deviceScale * 96);
+ this.raiseEvent(remoting.HostDesktop.Events.sizeChanged,
+ this.getDimensions());
+};
/**
* @constructor
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/crd/js/client_plugin.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698