Index: remoting/webapp/browser_test/bump_scroll_browser_test.js |
diff --git a/remoting/webapp/browser_test/bump_scroll_browser_test.js b/remoting/webapp/browser_test/bump_scroll_browser_test.js |
index 0dddf31273f49cfa2c9d67662c8ae8bee6050b0a..76b5211b77beede8dd779210a802d7944a89213e 100644 |
--- a/remoting/webapp/browser_test/bump_scroll_browser_test.js |
+++ b/remoting/webapp/browser_test/bump_scroll_browser_test.js |
@@ -12,26 +12,48 @@ |
'use strict'; |
-/** |
- * @constructor |
- * @extends {base.EventSourceImpl} |
- */ |
-browserTest.FakeDesktopConnectedView = function() { |
- this.pluginPosition = { |
+/** @constructor */ |
+browserTest.FakeDesktopViewport = function() { |
+ /** @private */ |
+ this.pluginPosition_ = { |
top: 0, |
left: 0 |
}; |
- this.defineEvents(Object.keys(remoting.DesktopConnectedView.Events)); |
+ /** @private */ |
+ this.bumpScroller_ = new base.EventSourceImpl(); |
+ this.bumpScroller_.defineEvents(Object.keys(remoting.BumpScroller.Events)); |
}; |
-base.extend(browserTest.FakeDesktopConnectedView, base.EventSourceImpl); |
+/** |
+ * @param {number} top |
+ * @param {number} left |
+ * @return {void} nothing. |
+ */ |
+browserTest.FakeDesktopViewport.prototype.setPluginPositionForTesting = |
+ function(top, left) { |
+ this.pluginPosition_ = { |
+ top: top, |
+ left: left |
+ }; |
+}; |
/** |
* @return {{top: number, left:number}} The top-left corner of the plugin. |
*/ |
-browserTest.FakeDesktopConnectedView.prototype.getPluginPositionForTesting = |
+browserTest.FakeDesktopViewport.prototype.getPluginPositionForTesting = |
function() { |
- return this.pluginPosition; |
+ return this.pluginPosition_; |
+}; |
+ |
+/** @return {base.EventSource} */ |
+browserTest.FakeDesktopViewport.prototype.getBumpScrollerForTesting = |
+ function() { |
+ return this.bumpScroller_; |
+}; |
+ |
+browserTest.FakeDesktopViewport.prototype.raiseEvent = |
+ function() { |
+ return this.bumpScroller_.raiseEvent.apply(this.bumpScroller_, arguments); |
}; |
@@ -92,7 +114,8 @@ browserTest.Bump_Scroll.prototype.run = function(data) { |
* @return {Promise} |
*/ |
browserTest.Bump_Scroll.prototype.noScrollWindowed = function() { |
- remoting.desktopConnectedView.setPluginSizeForBumpScrollTesting( |
+ var viewport = remoting.desktopConnectedView.getViewportForTesting(); |
+ viewport.setPluginSizeForBumpScrollTesting( |
window.innerWidth + this.kHostDesktopSizeDelta, |
window.innerHeight + this.kHostDesktopSizeDelta); |
this.moveMouseTo(0, 0); |
@@ -103,7 +126,8 @@ browserTest.Bump_Scroll.prototype.noScrollWindowed = function() { |
* @return {Promise} |
*/ |
browserTest.Bump_Scroll.prototype.noScrollSmaller = function() { |
- remoting.desktopConnectedView.setPluginSizeForBumpScrollTesting( |
+ var viewport = remoting.desktopConnectedView.getViewportForTesting(); |
+ viewport.setPluginSizeForBumpScrollTesting( |
window.innerWidth - this.kHostDesktopSizeDelta, |
window.innerHeight - this.kHostDesktopSizeDelta); |
this.moveMouseTo(0, 0); |
@@ -117,16 +141,17 @@ browserTest.Bump_Scroll.prototype.noScrollSmaller = function() { |
*/ |
browserTest.Bump_Scroll.prototype.scrollDirection = |
function(widthFraction, heightFraction) { |
- remoting.desktopConnectedView.setPluginSizeForBumpScrollTesting( |
+ var viewport = remoting.desktopConnectedView.getViewportForTesting(); |
+ viewport.setPluginSizeForBumpScrollTesting( |
screen.width + this.kHostDesktopSizeDelta, |
screen.height + this.kHostDesktopSizeDelta); |
/** @type {number} */ |
- var expectedTop = heightFraction == 0.0 ? 0 : |
+ var expectedTop = heightFraction === 0.0 ? 0 : |
heightFraction == 1.0 ? -this.kHostDesktopSizeDelta : |
undefined; |
/** @type {number} */ |
- var expectedLeft = widthFraction == 0.0 ? 0 : |
- widthFraction == 1.0 ? -this.kHostDesktopSizeDelta : |
+ var expectedLeft = widthFraction === 0.0 ? 0 : |
+ widthFraction === 1.0 ? -this.kHostDesktopSizeDelta : |
undefined; |
var result = this.verifyScroll(expectedTop, expectedLeft); |
this.moveMouseTo(widthFraction * screen.width, |
@@ -186,52 +211,49 @@ browserTest.Bump_Scroll.prototype.moveMouseTo = function(x, y) { |
* @return {Promise} |
*/ |
browserTest.Bump_Scroll.prototype.testVerifyScroll = function() { |
- var STARTED = remoting.DesktopConnectedView.Events.bumpScrollStarted; |
- var STOPPED = remoting.DesktopConnectedView.Events.bumpScrollStopped; |
- var fakeSession = new browserTest.FakeDesktopConnectedView; |
+ var STARTED = remoting.BumpScroller.Events.bumpScrollStarted; |
+ var STOPPED = remoting.BumpScroller.Events.bumpScrollStopped; |
+ var fakeViewport = new browserTest.FakeDesktopViewport; |
var that = this; |
// No events raised (e.g. windowed mode). |
- var result = this.verifyScroll(undefined, undefined, fakeSession) |
+ var result = this.verifyScroll(undefined, undefined, fakeViewport) |
.then(function() { |
// Start and end events raised, but no scrolling (e.g. full-screen mode |
// with host desktop <= window size). |
- fakeSession = new browserTest.FakeDesktopConnectedView; |
- var result = that.verifyScroll(undefined, undefined, fakeSession); |
- fakeSession.raiseEvent(STARTED, {}); |
- fakeSession.raiseEvent(STOPPED, {}); |
+ fakeViewport = new browserTest.FakeDesktopViewport; |
+ var result = that.verifyScroll(undefined, undefined, fakeViewport); |
+ fakeViewport.raiseEvent(STARTED, {}); |
+ fakeViewport.raiseEvent(STOPPED, {}); |
return result; |
}).then(function() { |
// Start and end events raised, with incorrect scrolling. |
- fakeSession = new browserTest.FakeDesktopConnectedView; |
+ fakeViewport = new browserTest.FakeDesktopViewport; |
var result = base.Promise.negate( |
- that.verifyScroll(2, 2, fakeSession)); |
- fakeSession.raiseEvent(STARTED, {}); |
- fakeSession.pluginPosition.top = 1; |
- fakeSession.pluginPosition.left = 1; |
- fakeSession.raiseEvent(STOPPED, {}); |
+ that.verifyScroll(2, 2, fakeViewport)); |
+ fakeViewport.raiseEvent(STARTED, {}); |
+ fakeViewport.setPluginPositionForTesting(1, 1); |
+ fakeViewport.raiseEvent(STOPPED, {}); |
return result; |
}).then(function() { |
// Start event raised, but not end event. |
- fakeSession = new browserTest.FakeDesktopConnectedView; |
+ fakeViewport = new browserTest.FakeDesktopViewport; |
var result = base.Promise.negate( |
- that.verifyScroll(2, 2, fakeSession)); |
- fakeSession.raiseEvent(STARTED, {}); |
- fakeSession.pluginPosition.top = 2; |
- fakeSession.pluginPosition.left = 2; |
+ that.verifyScroll(2, 2, fakeViewport)); |
+ fakeViewport.raiseEvent(STARTED, {}); |
+ fakeViewport.setPluginPositionForTesting(2, 2); |
return result; |
}).then(function() { |
// Start and end events raised, with correct scrolling. |
- fakeSession = new browserTest.FakeDesktopConnectedView; |
- var result = that.verifyScroll(2, 2, fakeSession); |
- fakeSession.raiseEvent(STARTED, {}); |
- fakeSession.pluginPosition.top = 2; |
- fakeSession.pluginPosition.left = 2; |
- fakeSession.raiseEvent(STOPPED, {}); |
+ fakeViewport = new browserTest.FakeDesktopViewport; |
+ var result = that.verifyScroll(2, 2, fakeViewport); |
+ fakeViewport.raiseEvent(STARTED, {}); |
+ fakeViewport.setPluginPositionForTesting(2, 2); |
+ fakeViewport.raiseEvent(STOPPED, {}); |
return result; |
}); |
@@ -245,26 +267,25 @@ browserTest.Bump_Scroll.prototype.testVerifyScroll = function() { |
* 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.FakeDesktopConnectedView=} opt_desktopConnectedView |
- * DesktopConnectedView fake, for testing. |
+ * @param {browserTest.FakeDesktopViewport=} opt_desktopViewport |
+ * DesktopViewport fake, for testing. |
* @return {Promise} |
*/ |
browserTest.Bump_Scroll.prototype.verifyScroll = |
- function (expectedTop, expectedLeft, opt_desktopConnectedView) { |
- /** @type {browserTest.FakeDesktopConnectedView} */ |
- var desktopConnectedView = opt_desktopConnectedView || |
- remoting.desktopConnectedView; |
- base.debug.assert(desktopConnectedView != null); |
- var STARTED = remoting.DesktopConnectedView.Events.bumpScrollStarted; |
- var STOPPED = remoting.DesktopConnectedView.Events.bumpScrollStopped; |
+ function (expectedTop, expectedLeft, opt_desktopViewport) { |
+ var desktopViewport = opt_desktopViewport || |
+ remoting.desktopConnectedView.getViewportForTesting(); |
+ base.debug.assert(desktopViewport != null); |
+ var STARTED = remoting.BumpScroller.Events.bumpScrollStarted; |
+ var STOPPED = remoting.BumpScroller.Events.bumpScrollStopped; |
- var initialPosition = desktopConnectedView.getPluginPositionForTesting(); |
+ var initialPosition = desktopViewport.getPluginPositionForTesting(); |
var initialTop = initialPosition.top; |
var initialLeft = initialPosition.left; |
/** @return {Promise} */ |
var verifyPluginPosition = function() { |
- var position = desktopConnectedView.getPluginPositionForTesting(); |
+ var position = desktopViewport.getPluginPositionForTesting(); |
if (expectedLeft === undefined) { |
expectedLeft = initialLeft; |
} |
@@ -281,20 +302,21 @@ browserTest.Bump_Scroll.prototype.verifyScroll = |
} |
}; |
- var started = browserTest.expectEvent(desktopConnectedView, STARTED, 1000); |
- var stopped = browserTest.expectEvent(desktopConnectedView, STOPPED, 5000); |
+ var bumpScroller = desktopViewport.getBumpScrollerForTesting(); |
+ var started = browserTest.expectEvent(bumpScroller, STARTED, 1000); |
+ var stopped = browserTest.expectEvent(bumpScroller, STOPPED, 5000); |
return started.then(function() { |
- return stopped.then(function() { |
- return verifyPluginPosition(); |
- }); |
+ return stopped; |
}, function() { |
// If no started event is raised, the test might still pass if it asserted |
// no scrolling. |
- if (expectedTop == undefined && expectedLeft == undefined) { |
+ if (expectedTop === undefined && expectedLeft === undefined) { |
return Promise.resolve(); |
} else { |
return Promise.reject( |
new Error('Scroll expected but no start event fired.')); |
} |
+ }).then(function() { |
+ return verifyPluginPosition(); |
}); |
}; |