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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 /** | 113 /** |
114 * @return {Promise} | 114 * @return {Promise} |
115 */ | 115 */ |
116 browserTest.Bump_Scroll.prototype.noScrollWindowed = function() { | 116 browserTest.Bump_Scroll.prototype.noScrollWindowed = function() { |
117 var viewport = remoting.desktopConnectedView.getViewportForTesting(); | 117 var viewport = remoting.desktopConnectedView.getViewportForTesting(); |
118 viewport.setPluginSizeForBumpScrollTesting( | 118 viewport.setPluginSizeForBumpScrollTesting( |
119 window.innerWidth + this.kHostDesktopSizeDelta, | 119 window.innerWidth + this.kHostDesktopSizeDelta, |
120 window.innerHeight + this.kHostDesktopSizeDelta); | 120 window.innerHeight + this.kHostDesktopSizeDelta); |
121 this.moveMouseTo(0, 0); | 121 this.moveMouseTo(0, 0); |
122 return this.verifyScroll(undefined, undefined); | 122 return this.verifyNoScroll(); |
123 }; | 123 }; |
124 | 124 |
125 /** | 125 /** |
126 * @return {Promise} | 126 * @return {Promise} |
127 */ | 127 */ |
128 browserTest.Bump_Scroll.prototype.noScrollSmaller = function() { | 128 browserTest.Bump_Scroll.prototype.noScrollSmaller = function() { |
129 var viewport = remoting.desktopConnectedView.getViewportForTesting(); | 129 var viewport = remoting.desktopConnectedView.getViewportForTesting(); |
130 viewport.setPluginSizeForBumpScrollTesting( | 130 viewport.setPluginSizeForBumpScrollTesting( |
131 window.innerWidth - this.kHostDesktopSizeDelta, | 131 window.innerWidth - this.kHostDesktopSizeDelta, |
132 window.innerHeight - this.kHostDesktopSizeDelta); | 132 window.innerHeight - this.kHostDesktopSizeDelta); |
133 this.moveMouseTo(0, 0); | 133 this.moveMouseTo(0, 0); |
134 return this.verifyScroll(undefined, undefined); | 134 return this.verifyNoScroll(); |
135 }; | 135 }; |
136 | 136 |
137 /** | 137 /** |
138 * @param {number} widthFraction | 138 * @param {number} widthFraction |
139 * @param {number} heightFraction | 139 * @param {number} heightFraction |
140 * @return {Promise} | 140 * @return {Promise} |
141 */ | 141 */ |
142 browserTest.Bump_Scroll.prototype.scrollDirection = | 142 browserTest.Bump_Scroll.prototype.scrollDirection = |
143 function(widthFraction, heightFraction) { | 143 function(widthFraction, heightFraction) { |
144 var viewport = remoting.desktopConnectedView.getViewportForTesting(); | 144 var viewport = remoting.desktopConnectedView.getViewportForTesting(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 * verifyScroll() is complicated enough to warrant a test. | 210 * verifyScroll() is complicated enough to warrant a test. |
211 * @return {Promise} | 211 * @return {Promise} |
212 */ | 212 */ |
213 browserTest.Bump_Scroll.prototype.testVerifyScroll = function() { | 213 browserTest.Bump_Scroll.prototype.testVerifyScroll = function() { |
214 var STARTED = remoting.BumpScroller.Events.bumpScrollStarted; | 214 var STARTED = remoting.BumpScroller.Events.bumpScrollStarted; |
215 var STOPPED = remoting.BumpScroller.Events.bumpScrollStopped; | 215 var STOPPED = remoting.BumpScroller.Events.bumpScrollStopped; |
216 var fakeViewport = new browserTest.FakeDesktopViewport; | 216 var fakeViewport = new browserTest.FakeDesktopViewport; |
217 var that = this; | 217 var that = this; |
218 | 218 |
219 // No events raised (e.g. windowed mode). | 219 // No events raised (e.g. windowed mode). |
220 var result = this.verifyScroll(undefined, undefined, fakeViewport) | 220 var result = this.verifyNoScroll(fakeViewport) |
221 | 221 |
222 .then(function() { | 222 .then(function() { |
223 // Start and end events raised, but no scrolling (e.g. full-screen mode | 223 // Start and end events raised, but no scrolling (e.g. full-screen mode |
224 // with host desktop <= window size). | 224 // with host desktop <= window size). |
225 fakeViewport = new browserTest.FakeDesktopViewport; | 225 fakeViewport = new browserTest.FakeDesktopViewport; |
226 var result = that.verifyScroll(undefined, undefined, fakeViewport); | 226 var result = that.verifyNoScroll(fakeViewport); |
227 fakeViewport.raiseEvent(STARTED, {}); | 227 fakeViewport.raiseEvent(STARTED, {}); |
228 fakeViewport.raiseEvent(STOPPED, {}); | 228 fakeViewport.raiseEvent(STOPPED, {}); |
229 return result; | 229 return result; |
230 | 230 |
231 }).then(function() { | 231 }).then(function() { |
232 // Start and end events raised, with incorrect scrolling. | 232 // Start and end events raised, with incorrect scrolling. |
233 fakeViewport = new browserTest.FakeDesktopViewport; | 233 fakeViewport = new browserTest.FakeDesktopViewport; |
234 var result = base.Promise.negate( | 234 var result = base.Promise.negate( |
235 that.verifyScroll(2, 2, fakeViewport)); | 235 that.verifyScroll(2, 2, fakeViewport)); |
236 fakeViewport.raiseEvent(STARTED, {}); | 236 fakeViewport.raiseEvent(STARTED, {}); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if (expectedTop === undefined && expectedLeft === undefined) { | 313 if (expectedTop === undefined && expectedLeft === undefined) { |
314 return Promise.resolve(); | 314 return Promise.resolve(); |
315 } else { | 315 } else { |
316 return Promise.reject( | 316 return Promise.reject( |
317 new Error('Scroll expected but no start event fired.')); | 317 new Error('Scroll expected but no start event fired.')); |
318 } | 318 } |
319 }).then(function() { | 319 }).then(function() { |
320 return verifyPluginPosition(); | 320 return verifyPluginPosition(); |
321 }); | 321 }); |
322 }; | 322 }; |
| 323 |
| 324 /** |
| 325 * @param {browserTest.FakeDesktopViewport=} opt_desktopViewport |
| 326 * DesktopViewport fake, for testing. |
| 327 * |
| 328 * @return {Promise<boolean>} A promise that resolves to true if no scrolling |
| 329 * occurs within a timeout. |
| 330 */ |
| 331 browserTest.Bump_Scroll.prototype.verifyNoScroll = |
| 332 function(opt_desktopViewport) { |
| 333 var desktopViewport = opt_desktopViewport || |
| 334 remoting.desktopConnectedView.getViewportForTesting(); |
| 335 var bumpScroller = desktopViewport.getBumpScrollerForTesting(); |
| 336 if (!bumpScroller) { |
| 337 Promise.resolve(true); |
| 338 } |
| 339 return this.verifyScroll(undefined, undefined, desktopViewport); |
| 340 }; |
OLD | NEW |