OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 chrome.test.runTests(function() { | 5 chrome.test.runTests(function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 class StubElement { | 8 class StubElement { |
9 constructor() { | 9 constructor() { |
10 this.listeners = new Map([ | 10 this.listeners = new Map([ |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 let pinchUpdateEvent = new MockTouchEvent('touchmove', [ | 206 let pinchUpdateEvent = new MockTouchEvent('touchmove', [ |
207 {clientX: 0, clientY: 0}, | 207 {clientX: 0, clientY: 0}, |
208 {clientX: 0, clientY: 4} | 208 {clientX: 0, clientY: 4} |
209 ]); | 209 ]); |
210 stubElement.sendEvent(pinchUpdateEvent); | 210 stubElement.sendEvent(pinchUpdateEvent); |
211 chrome.test.assertEq('pinchupdate', pinchListener.lastEvent.type); | 211 chrome.test.assertEq('pinchupdate', pinchListener.lastEvent.type); |
212 chrome.test.assertTrue(pinchUpdateEvent.defaultPrevented); | 212 chrome.test.assertTrue(pinchUpdateEvent.defaultPrevented); |
213 | 213 |
214 chrome.test.succeed(); | 214 chrome.test.succeed(); |
215 } | 215 } |
216 | |
217 function testWasTwoFingerTouch() { | |
218 let stubElement = new StubElement(); | |
219 let gestureDetector = new GestureDetector(stubElement); | |
220 | |
221 let touchStartEvent = new MockTouchEvent('touchstart', [ | |
222 {clientX: 0, clientY: 0, touches: []} | |
Kevin McNee
2017/05/03 17:25:43
The array passed to MockTouchEvent's constructor i
dsinclair
2017/05/03 18:13:38
Awesome, thanks. I'd guessed and was going to star
| |
223 ]); | |
224 stubElement.sendEvent(touchStartEvent); | |
225 chrome.test.assertFalse(gestureDetector.wasTwoFingerTouch()); | |
226 | |
227 touchStartEvent = new MockTouchEvent('touchstart', [ | |
228 {clientX: 0, clientY: 0, touches: [1, 2]} | |
229 ]); | |
230 stubElement.sendEvent(touchStartEvent); | |
231 chrome.test.assertTrue(gestureDetector.wasTwoFingerTouch()); | |
232 | |
233 touchStartEvent = new MockTouchEvent('touchstart', [ | |
234 {clientX: 0, clientY: 0, touches: [1, 2, 3]} | |
235 ]); | |
236 stubElement.sendEvent(touchStartEvent); | |
237 chrome.test.assertTrue(gestureDetector.wasTwoFingerTouch()); | |
238 } | |
Kevin McNee
2017/05/03 17:25:43
If you're relying on the value of |wasTwoFingerTou
dsinclair
2017/05/03 18:13:38
Ah, good idea.
| |
216 ]; | 239 ]; |
217 }()); | 240 }()); |
OLD | NEW |