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

Unified Diff: remoting/webapp/browser_test/mock_client_plugin.js

Issue 593313003: Implement basic mocks for testing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer feedback. Created 6 years, 3 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/browser_test/mock_session_connector.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
new file mode 100644
index 0000000000000000000000000000000000000000..dfe0ffebe80d359a867227650e9059e308abcbdb
--- /dev/null
+++ b/remoting/webapp/browser_test/mock_client_plugin.js
@@ -0,0 +1,184 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * Mock implementation of ClientPlugin for testing.
+ * @suppress {checkTypes}
+ */
+
+'use strict';
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+/**
+ * @constructor
+ * @implements {remoting.ClientPlugin}
+ */
+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_);
+};
+
+remoting.MockClientPlugin.prototype.dispose = function() {
+ this.container_.removeChild(this.element_);
+ this.element_ = null;
+ 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.element = function() {
+ return this.element_;
+};
+
+remoting.MockClientPlugin.prototype.initialize = function(onDone) {
+ window.setTimeout(onDone.bind(null, true), 0);
+};
+
+remoting.MockClientPlugin.prototype.connect = function(
+ hostJid, hostPublicKey, localJid, sharedSecret,
+ authenticationMethods, authenticationTag,
+ clientPairingId, clientPairedSecret) {
+ base.debug.assert(this.connectionStatusUpdateHandler_ != null);
+ window.setTimeout(
+ this.connectionStatusUpdateHandler_.bind(
+ this,
+ remoting.ClientSession.State.CONNECTED,
+ remoting.ClientSession.ConnectionError.NONE),
+ 0);
+};
+
+remoting.MockClientPlugin.prototype.injectKeyEvent =
+ function(key, down) {};
+
+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() {
+ return true;
+};
+
+remoting.MockClientPlugin.prototype.hasFeature = function(feature) {
+ return false;
+};
+
+remoting.MockClientPlugin.prototype.enableMediaSourceRendering =
+ function(mediaSourceRenderer) {};
+
+remoting.MockClientPlugin.prototype.sendClipboardItem =
+ function(mimeType, item) {};
+
+remoting.MockClientPlugin.prototype.useAsyncPinDialog = function() {};
+
+remoting.MockClientPlugin.prototype.requestPairing =
+ function(clientName, onDone) {};
+
+remoting.MockClientPlugin.prototype.onPinFetched = function(pin) {};
+
+remoting.MockClientPlugin.prototype.onThirdPartyTokenFetched =
+ function(token, sharedSecret) {};
+
+remoting.MockClientPlugin.prototype.pauseAudio = function(pause) {};
+
+remoting.MockClientPlugin.prototype.pauseVideo = function(pause) {};
+
+remoting.MockClientPlugin.prototype.getPerfStats = function() {
+ var result = new remoting.ClientSession.PerfStats;
+ result.videoBandwidth = 999;
+ result.videoFrameRate = 60;
+ result.captureLatency = 10;
+ result.encodeLatency = 10;
+ result.decodeLatency = 10;
+ result.renderLatency = 10;
+ result.roundtripLatency = 10;
+ return result;
+};
+
+remoting.MockClientPlugin.prototype.sendClientMessage =
+ function(name, data) {};
+
+remoting.MockClientPlugin.prototype.setOnOutgoingIqHandler =
+ function(handler) {};
+
+remoting.MockClientPlugin.prototype.setOnDebugMessageHandler =
+ function(handler) {};
+
+remoting.MockClientPlugin.prototype.setConnectionStatusUpdateHandler =
+ function(handler) {
+ this.connectionStatusUpdateHandler_ = handler;
+};
+
+remoting.MockClientPlugin.prototype.setConnectionReadyHandler =
+ function(handler) {};
+
+remoting.MockClientPlugin.prototype.setDesktopSizeUpdateHandler =
+ function(handler) {
+ this.desktopSizeUpdateHandler_ = handler;
+};
+
+remoting.MockClientPlugin.prototype.setCapabilitiesHandler =
+ function(handler) {};
+
+remoting.MockClientPlugin.prototype.setGnubbyAuthHandler =
+ function(handler) {};
+
+remoting.MockClientPlugin.prototype.setCastExtensionHandler =
+ function(handler) {};
+
+remoting.MockClientPlugin.prototype.setMouseCursorHandler =
+ function(handler) {};
+
+remoting.MockClientPlugin.prototype.setFetchThirdPartyTokenHandler =
+ function(handler) {};
+
+remoting.MockClientPlugin.prototype.setFetchPinHandler =
+ function(handler) {};
+
+
+/**
+ * @constructor
+ * @extends {remoting.ClientPluginFactory}
+ */
+remoting.MockClientPluginFactory = function() {};
+
+remoting.MockClientPluginFactory.prototype.createPlugin =
+ function(container, onExtensionMessage) {
+ return new remoting.MockClientPlugin(container);
+};
+
+remoting.MockClientPluginFactory.prototype.preloadPlugin = function() {};
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/browser_test/mock_session_connector.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698