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 * @suppress {checkTypes} | 7 * @suppress {checkTypes} |
8 * Browser test for the scenario below: | 8 * Browser test for the scenario below: |
9 * 1. Enter full-screen mode | 9 * 1. Enter full-screen mode |
10 * 2. Move the mouse to each edge; verify that the desktop bump-scrolls. | 10 * 2. Move the mouse to each edge; verify that the desktop bump-scrolls. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 browserTest.FakeDesktopViewport.prototype.getBumpScrollerForTesting = | 49 browserTest.FakeDesktopViewport.prototype.getBumpScrollerForTesting = |
50 function() { | 50 function() { |
51 return this.bumpScroller_; | 51 return this.bumpScroller_; |
52 }; | 52 }; |
53 | 53 |
54 browserTest.FakeDesktopViewport.prototype.raiseEvent = | 54 browserTest.FakeDesktopViewport.prototype.raiseEvent = |
55 function() { | 55 function() { |
56 return this.bumpScroller_.raiseEvent.apply(this.bumpScroller_, arguments); | 56 return this.bumpScroller_.raiseEvent.apply(this.bumpScroller_, arguments); |
57 }; | 57 }; |
58 | 58 |
| 59 /** @return {remoting.DesktopViewport} */ |
| 60 function getViewportForTesting() { |
| 61 var view = remoting.desktopDelegateForTesting.getConnectedViewForTesting(); |
| 62 if (view) { |
| 63 return view.getViewportForTesting(); |
| 64 } |
| 65 return null; |
| 66 } |
59 | 67 |
60 /** @constructor */ | 68 /** @constructor */ |
61 browserTest.Bump_Scroll = function() { | 69 browserTest.Bump_Scroll = function() { |
62 // To avoid dependencies on the actual host desktop size, we simulate a | 70 // To avoid dependencies on the actual host desktop size, we simulate a |
63 // desktop larger or smaller than the client window. The exact value is | 71 // desktop larger or smaller than the client window. The exact value is |
64 // arbitrary, but must be positive. | 72 // arbitrary, but must be positive. |
65 /** @type {number} */ | 73 /** @type {number} */ |
66 this.kHostDesktopSizeDelta = 10; | 74 this.kHostDesktopSizeDelta = 10; |
67 }; | 75 }; |
68 | 76 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 browserTest.disconnect(); | 115 browserTest.disconnect(); |
108 return browserTest.fail(error); | 116 return browserTest.fail(error); |
109 } | 117 } |
110 ); | 118 ); |
111 }; | 119 }; |
112 | 120 |
113 /** | 121 /** |
114 * @return {Promise} | 122 * @return {Promise} |
115 */ | 123 */ |
116 browserTest.Bump_Scroll.prototype.noScrollWindowed = function() { | 124 browserTest.Bump_Scroll.prototype.noScrollWindowed = function() { |
117 var viewport = remoting.desktopConnectedView.getViewportForTesting(); | 125 var viewport = getViewportForTesting(); |
118 viewport.setPluginSizeForBumpScrollTesting( | 126 viewport.setPluginSizeForBumpScrollTesting( |
119 window.innerWidth + this.kHostDesktopSizeDelta, | 127 window.innerWidth + this.kHostDesktopSizeDelta, |
120 window.innerHeight + this.kHostDesktopSizeDelta); | 128 window.innerHeight + this.kHostDesktopSizeDelta); |
121 this.moveMouseTo(0, 0); | 129 this.moveMouseTo(0, 0); |
122 return this.verifyNoScroll(); | 130 return this.verifyNoScroll(); |
123 }; | 131 }; |
124 | 132 |
125 /** | 133 /** |
126 * @return {Promise} | 134 * @return {Promise} |
127 */ | 135 */ |
128 browserTest.Bump_Scroll.prototype.noScrollSmaller = function() { | 136 browserTest.Bump_Scroll.prototype.noScrollSmaller = function() { |
129 var viewport = remoting.desktopConnectedView.getViewportForTesting(); | 137 var viewport = getViewportForTesting(); |
130 viewport.setPluginSizeForBumpScrollTesting( | 138 viewport.setPluginSizeForBumpScrollTesting( |
131 window.innerWidth - this.kHostDesktopSizeDelta, | 139 window.innerWidth - this.kHostDesktopSizeDelta, |
132 window.innerHeight - this.kHostDesktopSizeDelta); | 140 window.innerHeight - this.kHostDesktopSizeDelta); |
133 this.moveMouseTo(0, 0); | 141 this.moveMouseTo(0, 0); |
134 return this.verifyNoScroll(); | 142 return this.verifyNoScroll(); |
135 }; | 143 }; |
136 | 144 |
137 /** | 145 /** |
138 * @param {number} widthFraction | 146 * @param {number} widthFraction |
139 * @param {number} heightFraction | 147 * @param {number} heightFraction |
140 * @return {Promise} | 148 * @return {Promise} |
141 */ | 149 */ |
142 browserTest.Bump_Scroll.prototype.scrollDirection = | 150 browserTest.Bump_Scroll.prototype.scrollDirection = |
143 function(widthFraction, heightFraction) { | 151 function(widthFraction, heightFraction) { |
144 var viewport = remoting.desktopConnectedView.getViewportForTesting(); | 152 var viewport = getViewportForTesting(); |
145 viewport.setPluginSizeForBumpScrollTesting( | 153 viewport.setPluginSizeForBumpScrollTesting( |
146 screen.width + this.kHostDesktopSizeDelta, | 154 screen.width + this.kHostDesktopSizeDelta, |
147 screen.height + this.kHostDesktopSizeDelta); | 155 screen.height + this.kHostDesktopSizeDelta); |
148 /** @type {number} */ | 156 /** @type {number} */ |
149 var expectedTop = heightFraction === 0.0 ? 0 : | 157 var expectedTop = heightFraction === 0.0 ? 0 : |
150 heightFraction == 1.0 ? -this.kHostDesktopSizeDelta : | 158 heightFraction == 1.0 ? -this.kHostDesktopSizeDelta : |
151 undefined; | 159 undefined; |
152 /** @type {number} */ | 160 /** @type {number} */ |
153 var expectedLeft = widthFraction === 0.0 ? 0 : | 161 var expectedLeft = widthFraction === 0.0 ? 0 : |
154 widthFraction === 1.0 ? -this.kHostDesktopSizeDelta : | 162 widthFraction === 1.0 ? -this.kHostDesktopSizeDelta : |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 * @param {number|undefined} expectedTop The expected vertical position of the | 274 * @param {number|undefined} expectedTop The expected vertical position of the |
267 * plugin, or undefined if it is not expected to change. | 275 * plugin, or undefined if it is not expected to change. |
268 * @param {number|undefined} expectedLeft The expected horizontal position of | 276 * @param {number|undefined} expectedLeft The expected horizontal position of |
269 * the plugin, or undefined if it is not expected to change. | 277 * the plugin, or undefined if it is not expected to change. |
270 * @param {browserTest.FakeDesktopViewport=} opt_desktopViewport | 278 * @param {browserTest.FakeDesktopViewport=} opt_desktopViewport |
271 * DesktopViewport fake, for testing. | 279 * DesktopViewport fake, for testing. |
272 * @return {Promise} | 280 * @return {Promise} |
273 */ | 281 */ |
274 browserTest.Bump_Scroll.prototype.verifyScroll = | 282 browserTest.Bump_Scroll.prototype.verifyScroll = |
275 function (expectedTop, expectedLeft, opt_desktopViewport) { | 283 function (expectedTop, expectedLeft, opt_desktopViewport) { |
276 var desktopViewport = opt_desktopViewport || | 284 var desktopViewport = opt_desktopViewport || getViewportForTesting(); |
277 remoting.desktopConnectedView.getViewportForTesting(); | |
278 base.debug.assert(desktopViewport != null); | 285 base.debug.assert(desktopViewport != null); |
279 var STARTED = remoting.BumpScroller.Events.bumpScrollStarted; | 286 var STARTED = remoting.BumpScroller.Events.bumpScrollStarted; |
280 var STOPPED = remoting.BumpScroller.Events.bumpScrollStopped; | 287 var STOPPED = remoting.BumpScroller.Events.bumpScrollStopped; |
281 | 288 |
282 var initialPosition = desktopViewport.getPluginPositionForTesting(); | 289 var initialPosition = desktopViewport.getPluginPositionForTesting(); |
283 var initialTop = initialPosition.top; | 290 var initialTop = initialPosition.top; |
284 var initialLeft = initialPosition.left; | 291 var initialLeft = initialPosition.left; |
285 | 292 |
286 /** @return {Promise} */ | 293 /** @return {Promise} */ |
287 var verifyPluginPosition = function() { | 294 var verifyPluginPosition = function() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 330 |
324 /** | 331 /** |
325 * @param {browserTest.FakeDesktopViewport=} opt_desktopViewport | 332 * @param {browserTest.FakeDesktopViewport=} opt_desktopViewport |
326 * DesktopViewport fake, for testing. | 333 * DesktopViewport fake, for testing. |
327 * | 334 * |
328 * @return {Promise<boolean>} A promise that resolves to true if no scrolling | 335 * @return {Promise<boolean>} A promise that resolves to true if no scrolling |
329 * occurs within a timeout. | 336 * occurs within a timeout. |
330 */ | 337 */ |
331 browserTest.Bump_Scroll.prototype.verifyNoScroll = | 338 browserTest.Bump_Scroll.prototype.verifyNoScroll = |
332 function(opt_desktopViewport) { | 339 function(opt_desktopViewport) { |
333 var desktopViewport = opt_desktopViewport || | 340 var desktopViewport = opt_desktopViewport || getViewportForTesting(); |
334 remoting.desktopConnectedView.getViewportForTesting(); | |
335 var bumpScroller = desktopViewport.getBumpScrollerForTesting(); | 341 var bumpScroller = desktopViewport.getBumpScrollerForTesting(); |
336 if (!bumpScroller) { | 342 if (!bumpScroller) { |
337 Promise.resolve(true); | 343 Promise.resolve(true); |
338 } | 344 } |
339 return this.verifyScroll(undefined, undefined, desktopViewport); | 345 return this.verifyScroll(undefined, undefined, desktopViewport); |
340 }; | 346 }; |
OLD | NEW |