summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 01:02:25 +0000
committerjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 01:02:25 +0000
commit6395ecdac82bf02fd0a43e25d77922719ed34912 (patch)
tree35ce0bba2f6a586f5d0cdf7651231406789c3a91
parentd5a74be564d5f86133aad1b66db3ab310a250952 (diff)
downloadchromium_src-6395ecdac82bf02fd0a43e25d77922719ed34912.zip
chromium_src-6395ecdac82bf02fd0a43e25d77922719ed34912.tar.gz
chromium_src-6395ecdac82bf02fd0a43e25d77922719ed34912.tar.bz2
Implement bump-scroll browser-test.
Review URL: https://codereview.chromium.org/421433002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288185 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome_tests.gypi3
-rw-r--r--chrome/test/remoting/fullscreen_browsertest.cc75
-rw-r--r--chrome/test/remoting/me2me_browsertest.cc50
-rw-r--r--chrome/test/remoting/remote_desktop_browsertest.cc4
-rw-r--r--remoting/remoting_webapp_files.gypi3
-rw-r--r--remoting/webapp/browser_test/browser_test.js2
-rw-r--r--remoting/webapp/browser_test/bump_scroll_browser_test.js266
-rw-r--r--remoting/webapp/client_session.js38
-rw-r--r--remoting/webapp/js_proto/dom_proto.js23
9 files changed, 403 insertions, 61 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 3f30b4e..bfade2c 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1605,10 +1605,11 @@
'test/gpu/webgl_infobar_browsertest.cc',
'test/ppapi/ppapi_browsertest.cc',
'test/remoting/auth_browsertest.cc',
- 'test/remoting/launch_browsertest.cc',
+ 'test/remoting/fullscreen_browsertest.cc',
'test/remoting/key_code_conv.cc',
'test/remoting/key_code_conv.h',
'test/remoting/key_code_map.h',
+ 'test/remoting/launch_browsertest.cc',
'test/remoting/me2me_browsertest.cc',
'test/remoting/page_load_notification_observer.cc',
'test/remoting/page_load_notification_observer.h',
diff --git a/chrome/test/remoting/fullscreen_browsertest.cc b/chrome/test/remoting/fullscreen_browsertest.cc
new file mode 100644
index 0000000..6b9f510
--- /dev/null
+++ b/chrome/test/remoting/fullscreen_browsertest.cc
@@ -0,0 +1,75 @@
+// 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.
+
+#include "base/file_util.h"
+#include "base/files/file_path.h"
+#include "chrome/test/remoting/remote_desktop_browsertest.h"
+#include "chrome/test/remoting/waiter.h"
+
+namespace remoting {
+
+class FullscreenBrowserTest : public RemoteDesktopBrowserTest {
+ protected:
+ bool WaitForFullscreenChange(bool expect_fullscreen);
+};
+
+bool FullscreenBrowserTest::WaitForFullscreenChange(bool expect_fullscreen) {
+ std::string javascript = expect_fullscreen ?
+ "remoting.fullscreen.isActive()" :
+ "!remoting.fullscreen.isActive()";
+ ConditionalTimeoutWaiter waiter(
+ base::TimeDelta::FromSeconds(20),
+ base::TimeDelta::FromSeconds(1),
+ base::Bind(&RemoteDesktopBrowserTest::IsHostActionComplete,
+ active_web_contents(),
+ javascript));
+ bool result = waiter.Wait();
+ // Entering or leaving full-screen mode causes local and remote desktop
+ // reconfigurations that can take a while to settle down, so wait a few
+ // seconds before continuing.
+ TimeoutWaiter(base::TimeDelta::FromSeconds(10)).Wait();
+ return result;
+}
+
+IN_PROC_BROWSER_TEST_F(FullscreenBrowserTest, MANUAL_Me2Me_Fullscreen) {
+ SetUpTestForMe2Me();
+ ConnectToLocalHost(false);
+
+ // Verify that we're initially not full-screen.
+ EXPECT_FALSE(ExecuteScriptAndExtractBool(
+ "remoting.fullscreen.isActive()"));
+
+ // Click the full-screen button and verify that it activates full-screen mode.
+ ClickOnControl("toggle-full-screen");
+ EXPECT_TRUE(WaitForFullscreenChange(true));
+
+ // Click the full-screen button again and verify that it deactivates
+ // full-screen mode.
+ ClickOnControl("toggle-full-screen");
+ EXPECT_TRUE(WaitForFullscreenChange(false));
+
+ // Enter full-screen mode again, then disconnect and verify that full-screen
+ // mode is deactivated upon disconnection.
+ // TODO(jamiewalch): For the v2 app, activate full-screen mode indirectly by
+ // maximizing the window for the second test.
+ ClickOnControl("toggle-full-screen");
+ EXPECT_TRUE(WaitForFullscreenChange(true));
+ DisconnectMe2Me();
+ EXPECT_TRUE(WaitForFullscreenChange(false));
+
+ Cleanup();
+}
+
+IN_PROC_BROWSER_TEST_F(FullscreenBrowserTest, MANUAL_Me2Me_Bump_Scroll) {
+ SetUpTestForMe2Me();
+
+ content::WebContents* content = app_web_content();
+ LoadScript(content, FILE_PATH_LITERAL("bump_scroll_browser_test.js"));
+
+ RunJavaScriptTest(content, "Bump_Scroll", "{pin: '" + me2me_pin() + "'}");
+
+ Cleanup();
+}
+
+} // namespace remoting
diff --git a/chrome/test/remoting/me2me_browsertest.cc b/chrome/test/remoting/me2me_browsertest.cc
index a8bc82b..a53d071 100644
--- a/chrome/test/remoting/me2me_browsertest.cc
+++ b/chrome/test/remoting/me2me_browsertest.cc
@@ -16,7 +16,6 @@ class Me2MeBrowserTest : public RemoteDesktopBrowserTest {
void ConnectPinlessAndCleanupPairings(bool cleanup_all);
bool IsPairingSpinnerHidden();
- bool WaitForFullscreenChange(bool expect_fullscreen);
};
IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest,
@@ -67,42 +66,6 @@ IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest,
Cleanup();
}
-IN_PROC_BROWSER_TEST_F(Me2MeBrowserTest, MANUAL_Me2Me_Fullscreen) {
- VerifyInternetAccess();
- Install();
- LaunchChromotingApp();
-
- // Authorize, Authenticate, and Approve.
- Auth();
- ExpandMe2Me();
-
- ConnectToLocalHost(false);
-
- // Verify that we're initially not full-screen.
- EXPECT_FALSE(ExecuteScriptAndExtractBool(
- "remoting.fullscreen.isActive()"));
-
- // Click the full-screen button and verify that it activates full-screen mode.
- ClickOnControl("toggle-full-screen");
- EXPECT_TRUE(WaitForFullscreenChange(true));
-
- // Click the full-screen button again and verify that it deactivates
- // full-screen mode.
- ClickOnControl("toggle-full-screen");
- EXPECT_TRUE(WaitForFullscreenChange(false));
-
- // Enter full-screen mode again, then disconnect and verify that full-screen
- // mode is deactivated upon disconnection.
- // TODO(jamiewalch): For the v2 app, activate full-screen mode indirectly by
- // maximizing the window for the second test.
- ClickOnControl("toggle-full-screen");
- EXPECT_TRUE(WaitForFullscreenChange(true));
- DisconnectMe2Me();
- EXPECT_TRUE(WaitForFullscreenChange(false));
-
- Cleanup();
-}
-
void Me2MeBrowserTest::TestKeyboardInput() {
// We will assume here that the browser window is already open on the host
// and in focus.
@@ -187,17 +150,4 @@ bool Me2MeBrowserTest::IsPairingSpinnerHidden() {
return !HtmlElementVisible("paired-client-manager-dialog-working");
}
-bool Me2MeBrowserTest::WaitForFullscreenChange(bool expect_fullscreen) {
- std::string javascript = expect_fullscreen ?
- "remoting.fullscreen.isActive()" :
- "!remoting.fullscreen.isActive()";
- ConditionalTimeoutWaiter waiter(
- base::TimeDelta::FromSeconds(10),
- base::TimeDelta::FromMilliseconds(500),
- base::Bind(&RemoteDesktopBrowserTest::IsHostActionComplete,
- active_web_contents(),
- javascript));
- return waiter.Wait();
-}
-
} // namespace remoting
diff --git a/chrome/test/remoting/remote_desktop_browsertest.cc b/chrome/test/remoting/remote_desktop_browsertest.cc
index 6510489..e5ed2e6 100644
--- a/chrome/test/remoting/remote_desktop_browsertest.cc
+++ b/chrome/test/remoting/remote_desktop_browsertest.cc
@@ -721,7 +721,7 @@ void RemoteDesktopBrowserTest::EnterPin(const std::string& pin,
// we should verify that it only pops up at the right circumstance. That
// probably belongs in a separate test case though.
ConditionalTimeoutWaiter waiter(
- base::TimeDelta::FromSeconds(5),
+ base::TimeDelta::FromSeconds(30),
base::TimeDelta::FromSeconds(1),
base::Bind(&RemoteDesktopBrowserTest::IsPinFormVisible, this));
EXPECT_TRUE(waiter.Wait());
@@ -747,7 +747,7 @@ void RemoteDesktopBrowserTest::WaitForConnection() {
// TODO(weitaosu): Instead of polling, can we register a callback to
// remoting.clientSession.onStageChange_?
ConditionalTimeoutWaiter waiter(
- base::TimeDelta::FromSeconds(4),
+ base::TimeDelta::FromSeconds(30),
base::TimeDelta::FromSeconds(1),
base::Bind(&RemoteDesktopBrowserTest::IsSessionConnected, this));
EXPECT_TRUE(waiter.Wait());
diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi
index 78021cf..070f899 100644
--- a/remoting/remoting_webapp_files.gypi
+++ b/remoting/remoting_webapp_files.gypi
@@ -123,6 +123,7 @@
# browser test JavaScript files.
'remoting_webapp_js_browser_test_files': [
'webapp/browser_test/browser_test.js',
+ 'webapp/browser_test/bump_scroll_browser_test.js',
'webapp/browser_test/cancel_pin_browser_test.js',
'webapp/browser_test/invalid_pin_browser_test.js',
'webapp/browser_test/update_pin_browser_test.js',
@@ -163,7 +164,7 @@
'<@(remoting_webapp_js_wcs_container_files)',
# Uncomment this line to include browser test files in the web app
# to expedite debugging or local development.
- # '<@(remoting_webapp_js_browser_test_files)'
+ '<@(remoting_webapp_js_browser_test_files)'
],
# The JavaScript files required by wcs_sandbox.html.
diff --git a/remoting/webapp/browser_test/browser_test.js b/remoting/webapp/browser_test/browser_test.js
index 4785175..a35e57d 100644
--- a/remoting/webapp/browser_test/browser_test.js
+++ b/remoting/webapp/browser_test/browser_test.js
@@ -324,7 +324,7 @@ browserTest.ensureHostStartedWithPIN = function(pin) {
browserTest.ensureRemoteConnectionEnabled = function(pin) {
browserTest.ensureHostStartedWithPIN(pin).then(function(){
browserTest.automationController_.send(true);
- }).catch(function(errorMessage){
+ }, function(errorMessage){
console.error(errorMessage);
browserTest.automationController_.send(false);
});
diff --git a/remoting/webapp/browser_test/bump_scroll_browser_test.js b/remoting/webapp/browser_test/bump_scroll_browser_test.js
new file mode 100644
index 0000000..cc94734
--- /dev/null
+++ b/remoting/webapp/browser_test/bump_scroll_browser_test.js
@@ -0,0 +1,266 @@
+// 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
+ * @suppress {checkTypes}
+ * Browser test for the scenario below:
+ * 1. Enter full-screen mode
+ * 2. Move the mouse to each edge; verify that the desktop bump-scrolls.
+ */
+
+'use strict';
+
+/** @constructor */
+browserTest.FakeClientSession = function() {
+ this.pluginPosition = {
+ top: 0,
+ left: 0
+ };
+ this.defineEvents(Object.keys(remoting.ClientSession.Events));
+};
+
+base.extend(browserTest.FakeClientSession, base.EventSource);
+
+browserTest.FakeClientSession.prototype.getPluginPositionForTesting =
+ function() {
+ return this.pluginPosition;
+};
+
+
+/** @constructor */
+browserTest.Bump_Scroll = function() {
+ // To aviod dependencies on the actual host desktop size, we simulate a
+ // desktop larger or smaller than the client window. The exact value is
+ // arbitrary, but must be positive.
+ this.kHostDesktopSizeDelta = 10;
+};
+
+browserTest.Bump_Scroll.prototype.run = function(data) {
+ browserTest.expect(typeof data.pin == 'string');
+
+ if (!remoting.isAppsV2) {
+ browserTest.fail(
+ 'Bump-scroll requires full-screen, which can only be activated ' +
+ 'programmatically in apps v2.')
+ }
+
+ this.testVerifyScroll().then(function() {
+ return browserTest.connectMe2Me();
+ }).then(function() {
+ return browserTest.enterPIN(data.pin);
+ }).then(
+ this.noScrollWindowed.bind(this)
+ ).then(
+ this.activateFullscreen.bind(this)
+ ).then(
+ this.noScrollSmaller.bind(this)
+ // The order of these operations is important. Because the plugin starts
+ // scrolled to the top-left, it needs to be scrolled right and down first.
+ ).then(
+ this.scrollDirection.bind(this, 1.0, 0.5) // Right edge
+ ).then(
+ this.scrollDirection.bind(this, 0.5, 1.0) // Bottom edge
+ ).then(
+ this.scrollDirection.bind(this, 0.0, 0.5) // Left edge
+ ).then(
+ this.scrollDirection.bind(this, 0.5, 0.0) // Top edge
+ ).then(
+ function(value) {
+ browserTest.disconnect();
+ return browserTest.pass(value);
+ },
+ function(error) {
+ browserTest.disconnect();
+ return browserTest.fail(error);
+ }
+ );
+};
+
+browserTest.Bump_Scroll.prototype.noScrollWindowed = function() {
+ remoting.clientSession.pluginWidthForBumpScrollTesting =
+ window.innerWidth + this.kHostDesktopSizeDelta;
+ remoting.clientSession.pluginHeightForBumpScrollTesting =
+ window.innerHeight + this.kHostDesktopSizeDelta;
+ this.moveMouseTo(0, 0);
+ return this.verifyScroll(undefined, undefined);
+};
+
+browserTest.Bump_Scroll.prototype.noScrollSmaller = function() {
+ remoting.clientSession.pluginWidthForBumpScrollTesting =
+ window.innerWidth - this.kHostDesktopSizeDelta;
+ remoting.clientSession.pluginHeightForBumpScrollTesting =
+ window.innerHeight - this.kHostDesktopSizeDelta;
+ this.moveMouseTo(0, 0);
+ return this.verifyScroll(undefined, undefined);
+};
+
+browserTest.Bump_Scroll.prototype.scrollDirection =
+ function(widthFraction, heightFraction) {
+ remoting.clientSession.pluginWidthForBumpScrollTesting =
+ screen.width + this.kHostDesktopSizeDelta;
+ remoting.clientSession.pluginHeightForBumpScrollTesting =
+ screen.height + this.kHostDesktopSizeDelta;
+ var expectedTop = heightFraction == 0.0 ? 0 :
+ heightFraction == 1.0 ? -this.kHostDesktopSizeDelta :
+ undefined;
+ var expectedLeft = widthFraction == 0.0 ? 0 :
+ widthFraction == 1.0 ? -this.kHostDesktopSizeDelta :
+ undefined;
+ var result = this.verifyScroll(expectedTop, expectedLeft);
+ this.moveMouseTo(widthFraction * screen.width,
+ heightFraction * screen.height);
+ return result;
+};
+
+browserTest.Bump_Scroll.prototype.activateFullscreen = function() {
+ return new Promise(function(fulfill, reject) {
+ remoting.fullscreen.activate(true, function() {
+ // The onFullscreen callback is invoked before the window has
+ // resized, so defer fulfilling the promise so that innerWidth
+ // and innerHeight are correct.
+ base.Promise.sleep(1000).then(fulfill);
+ });
+ base.Promise.sleep(5000).then(function(){
+ reject('Timed out waiting for full-screen');
+ });
+ });
+};
+
+browserTest.Bump_Scroll.prototype.moveMouseTo = function(x, y) {
+ var e = {
+ bubbles: true,
+ cancelable: false,
+ view: window,
+ detail: 0,
+ screenX: x,
+ screenY: y,
+ clientX: x,
+ clientY: y,
+ ctrlKey: false,
+ altKey: false,
+ shiftKey: false,
+ metaKey: false,
+ button: 0,
+ relatedTarget: undefined
+ };
+ var event = document.createEvent('MouseEvents');
+ event.initMouseEvent('mousemove',
+ e.bubbles, e.cancelable, e.view, e.detail,
+ e.screenX, e.screenY, e.clientX, e.clientY,
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
+ e.button, document.documentElement);
+ document.documentElement.dispatchEvent(event);
+};
+
+// verifyScroll is complicated enough to warrant a test
+browserTest.Bump_Scroll.prototype.testVerifyScroll = function() {
+ var STARTED = remoting.ClientSession.Events.bumpScrollStarted;
+ var STOPPED = remoting.ClientSession.Events.bumpScrollStopped;
+ var fakeSession = new browserTest.FakeClientSession;
+ var that = this;
+
+ // No events raised (e.g. windowed mode).
+ var result = this.verifyScroll(undefined, undefined, fakeSession)
+
+ .then(function() {
+ // Start and end events raised, but no scrolling (e.g. full-screen mode
+ // with host desktop <= window size).
+ fakeSession = new browserTest.FakeClientSession;
+ var result = that.verifyScroll(undefined, undefined, fakeSession);
+ fakeSession.raiseEvent(STARTED, {});
+ fakeSession.raiseEvent(STOPPED, {});
+ return result;
+
+ }).then(function() {
+ // Start and end events raised, with incorrect scrolling.
+ fakeSession = new browserTest.FakeClientSession;
+ var result = base.Promise.negate(
+ that.verifyScroll(2, 2, fakeSession));
+ fakeSession.raiseEvent(STARTED, {});
+ fakeSession.pluginPosition.top = 1;
+ fakeSession.pluginPosition.left = 1;
+ fakeSession.raiseEvent(STOPPED, {});
+ return result;
+
+ }).then(function() {
+ // Start event raised, but not end event.
+ fakeSession = new browserTest.FakeClientSession;
+ var result = base.Promise.negate(
+ that.verifyScroll(2, 2, fakeSession));
+ fakeSession.raiseEvent(STARTED, {});
+ fakeSession.pluginPosition.top = 2;
+ fakeSession.pluginPosition.left = 2;
+ return result;
+
+ }).then(function() {
+ // Start and end events raised, with correct scrolling.
+ fakeSession = new browserTest.FakeClientSession;
+ var result = that.verifyScroll(2, 2, fakeSession);
+ fakeSession.raiseEvent(STARTED, {});
+ fakeSession.pluginPosition.top = 2;
+ fakeSession.pluginPosition.left = 2;
+ fakeSession.raiseEvent(STOPPED, {});
+ return result;
+ });
+
+ return result;
+};
+
+/**
+ * Verify that a bump scroll operation takes place and that the top-left corner
+ * of the plugin is as expected when it completes.
+ * @param {number|undefined} expectedTop The expected vertical position of the
+ * plugin, or undefined if it is not expected to change.
+ * @param {number|undefined} expectedLeft The expected horizontal position of
+ * the plugin, or undefined if it is not expected to change.
+ * @param {browserTest.FakeClientSession=} opt_clientSession ClientSession-like
+ * fake, for testing.
+ */
+browserTest.Bump_Scroll.prototype.verifyScroll =
+ function (expectedTop, expectedLeft, opt_clientSession) {
+ var clientSession = opt_clientSession || remoting.clientSession;
+ base.debug.assert(clientSession != null);
+ var STARTED = remoting.ClientSession.Events.bumpScrollStarted;
+ var STOPPED = remoting.ClientSession.Events.bumpScrollStopped;
+
+ var initialPosition = clientSession.getPluginPositionForTesting();
+ var initialTop = initialPosition.top;
+ var initialLeft = initialPosition.left;
+
+ var verifyPluginPosition = function() {
+ var position = clientSession.getPluginPositionForTesting();
+ if (expectedLeft === undefined) {
+ expectedLeft = initialLeft;
+ }
+ if (expectedTop === undefined) {
+ expectedTop = initialTop;
+ }
+ if (position.top != expectedTop || position.left != expectedLeft) {
+ return Promise.reject(
+ new Error('No or incorrect scroll detected: (' +
+ position.left + ',' + position.top + ' instead of ' +
+ expectedLeft + ',' + expectedTop + ')'));
+ } else {
+ return Promise.resolve();
+ }
+ };
+
+ var started = browserTest.expectEvent(clientSession, STARTED, 1000);
+ var stopped = browserTest.expectEvent(clientSession, STOPPED, 5000);
+ return started.then(function() {
+ return stopped.then(function() {
+ return verifyPluginPosition();
+ });
+ }, function() {
+ // If no started event is raised, the test might still pass if it asserted
+ // no scrolling.
+ if (expectedTop == undefined && expectedLeft == undefined) {
+ return Promise.resolve();
+ } else {
+ return Promise.reject(
+ new Error('Scroll expected but no start event fired.'));
+ }
+ });
+};
diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js
index d3114aa..3579b0d 100644
--- a/remoting/webapp/client_session.js
+++ b/remoting/webapp/client_session.js
@@ -105,6 +105,14 @@ remoting.ClientSession = function(container, hostDisplayName, accessCode,
/** @type {number?} @private */
this.bumpScrollTimer_ = null;
+ // Bump-scroll test variables. Override to use a fake value for the width
+ // and height of the client plugin so that bump-scrolling can be tested
+ // without relying on the actual size of the host desktop.
+ /** @type {number} @private */
+ this.pluginWidthForBumpScrollTesting = 0;
+ /** @type {number} @private */
+ this.pluginHeightForBumpScrollTesting = 0;
+
/**
* Allow host-offline error reporting to be suppressed in situations where it
* would not be useful, for example, when using a cached host JID.
@@ -175,7 +183,9 @@ base.extend(remoting.ClientSession, base.EventSource);
/** @enum {string} */
remoting.ClientSession.Events = {
stateChanged: 'stateChanged',
- videoChannelStateChanged: 'videoChannelStateChanged'
+ videoChannelStateChanged: 'videoChannelStateChanged',
+ bumpScrollStarted: 'bumpScrollStarted',
+ bumpScrollStopped: 'bumpScrollStopped'
};
/**
@@ -1383,12 +1393,13 @@ remoting.ClientSession.prototype.scroll_ = function(dx, dy) {
var stopX = { stop: false };
var clientArea = this.getClientArea_();
- style.marginLeft = adjustMargin(style.marginLeft, dx,
- clientArea.width, plugin.clientWidth, stopX);
+ style.marginLeft = adjustMargin(style.marginLeft, dx, clientArea.width,
+ this.pluginWidthForBumpScrollTesting || plugin.clientWidth, stopX);
var stopY = { stop: false };
style.marginTop = adjustMargin(
- style.marginTop, dy, clientArea.height, plugin.clientHeight, stopY);
+ style.marginTop, dy, clientArea.height,
+ this.pluginHeightForBumpScrollTesting || plugin.clientHeight, stopY);
return stopX.stop && stopY.stop;
};
@@ -1450,6 +1461,7 @@ remoting.ClientSession.prototype.onMouseMove_ = function(event) {
var dy = computeDelta(event.y, clientArea.height);
if (dx != 0 || dy != 0) {
+ this.raiseEvent(remoting.ClientSession.Events.bumpScrollStarted);
/** @type {remoting.ClientSession} */
var that = this;
/**
@@ -1463,7 +1475,9 @@ remoting.ClientSession.prototype.onMouseMove_ = function(event) {
/** @type {number} */
var timeout = 10;
var lateAdjustment = 1 + (now - expected) / timeout;
- if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) {
+ if (that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) {
+ that.raiseEvent(remoting.ClientSession.Events.bumpScrollStopped);
+ } else {
that.bumpScrollTimer_ = window.setTimeout(
function() { repeatScroll(now + timeout); },
timeout);
@@ -1551,4 +1565,16 @@ remoting.ClientSession.prototype.updateMouseCursorImage_ =
this.mouseCursorOverlay_.style.marginTop = '-' + hotspotY + 'px';
this.mouseCursorOverlay_.src = url;
}
- };
+};
+
+/**
+ * @return {{top: number, left:number}} The top-left corner of the plugin.
+ */
+remoting.ClientSession.prototype.getPluginPositionForTesting = function() {
+ var plugin = this.plugin_.element();
+ var style = plugin.style;
+ return {
+ top: parseFloat(style.marginTop),
+ left: parseFloat(style.marginLeft)
+ };
+};
diff --git a/remoting/webapp/js_proto/dom_proto.js b/remoting/webapp/js_proto/dom_proto.js
index 8538957..d7f475d 100644
--- a/remoting/webapp/js_proto/dom_proto.js
+++ b/remoting/webapp/js_proto/dom_proto.js
@@ -219,3 +219,26 @@ Promise.reject = function (reason) {};
* @return {Promise}
*/
Promise.resolve = function (value) {};
+
+/**
+ * @param {string} type
+ * @param {boolean} canBubble
+ * @param {boolean} cancelable
+ * @param {Window} view
+ * @param {number} detail
+ * @param {number} screenX
+ * @param {number} screenY
+ * @param {number} clientX
+ * @param {number} clientY
+ * @param {boolean} ctrlKey
+ * @param {boolean} altKey
+ * @param {boolean} shiftKey
+ * @param {boolean} metaKey
+ * @param {number} button
+ * @param {EventTarget} relatedTarget
+ */
+Event.prototype.initMouseEvent = function(
+ type, canBubble, cancelable, view, detail,
+ screenX, screenY, clientX, clientY,
+ ctrlKey, altKey, shiftKey, metaKey,
+ button, relatedTarget) {};