|
6 | 6 | </style>
|
7 | 7 | <script src="resources/swipe-test.js"></script>
|
8 | 8 | <script>
|
9 |
| -function startSwipeGesture() |
10 |
| -{ |
11 |
| - eventSender.mouseMoveTo(100, 100); |
12 | 9 |
|
| 10 | +function runTest() |
| 11 | +{ |
13 | 12 | // The first swipe should fail because we're scrolled to the middle of the document
|
14 | 13 | // and this is all a single gesture. We can only start swipes if we *begin*
|
15 | 14 | // pinned to the edge.
|
16 |
| - eventQueue.enqueueSwipeEvent(0, 0, 'maybegin'); |
17 |
| - eventQueue.enqueueScrollEvent(10, 0, 'began'); |
18 |
| - eventQueue.enqueueScrollEvent(10, 0, 'changed'); |
19 |
| - eventQueue.enqueueScrollEvent(10, 0, 'changed'); |
20 |
| - eventQueue.enqueueScrollEvent(10, 0, 'changed'); |
21 |
| - eventQueue.enqueueScrollEvent(10, 0, 'changed'); |
22 |
| - eventQueue.enqueueScrollEvent(10, 0, 'changed'); |
23 |
| - eventQueue.enqueueScrollEvent(10, 0, 'changed'); |
24 |
| - eventQueue.enqueueScrollEvent(10, 0, 'changed'); |
25 |
| - eventQueue.enqueueScrollEvent(10, 0, 'changed'); |
26 |
| - eventQueue.enqueueScrollEvent(10, 0, 'changed'); |
27 |
| - eventQueue.enqueueScrollEvent(10, 0, 'changed'); |
28 |
| - eventQueue.enqueueScrollEvent(0, 0, 'ended'); |
29 |
| - |
30 |
| - eventQueue.callAfterEventDispatch(function () { |
31 |
| - testRunner.clearTestRunnerCallbacks(); |
32 |
| - testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback); |
33 |
| - testRunner.installWillEndSwipeCallback(willEndSwipeCallback); |
34 |
| - testRunner.installDidEndSwipeCallback(didEndSwipeCallback); |
35 |
| - testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback); |
| 15 | + startSwipeGesture(function () { |
| 16 | + completeSwipeGesture(function () { |
| 17 | + testRunner.clearTestRunnerCallbacks(); |
| 18 | + testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback); |
| 19 | + testRunner.installWillEndSwipeCallback(willEndSwipeCallback); |
| 20 | + testRunner.installDidEndSwipeCallback(didEndSwipeCallback); |
| 21 | + testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback); |
36 | 22 |
|
37 |
| - setTimeout(function () { |
38 | 23 | // The second swipe should succeed because we are now scrolled to the left edge.
|
39 |
| - eventQueue.enqueueSwipeEvent(0, 0, 'maybegin'); |
40 |
| - eventQueue.enqueueScrollEvent(1, 0, 'began'); |
41 |
| - eventQueue.enqueueScrollEvent(10, 0, 'changed'); |
42 |
| - }, 0); |
43 |
| - }) |
44 |
| -} |
45 |
| - |
46 |
| -function completeSwipeGesture() |
47 |
| -{ |
48 |
| - eventQueue.enqueueSwipeEvent(1, 0, 'changed'); |
49 |
| - eventQueue.enqueueSwipeEvent(256, 0, 'changed'); |
50 |
| - eventQueue.enqueueSwipeEvent(0, 0, 'ended'); |
| 24 | + startSwipeGesture(function () { completeSwipeGesture(); }); |
| 25 | + }); |
| 26 | + }); |
51 | 27 | }
|
52 | 28 |
|
53 | 29 | function didBeginSwipeNotReachedCallback()
|
|
58 | 34 | function didBeginSwipeCallback()
|
59 | 35 | {
|
60 | 36 | log("didBeginSwipe");
|
61 |
| - |
62 |
| - shouldBe(false, eventQueue.hasPendingEvents(), "Event queue should be empty. Both scroll events should be required to start the swipe because of the swipe-start hysteresis."); |
63 |
| - |
64 |
| - completeSwipeGesture(); |
65 | 37 | }
|
66 | 38 |
|
67 | 39 | function willEndSwipeCallback()
|
|
75 | 47 | {
|
76 | 48 | log("didEndSwipe");
|
77 | 49 |
|
78 |
| - shouldBe(0, eventQueue.hasPendingEvents(), "Event queue should be empty. The swipe isn't complete until we see the end of the gesture."); |
79 | 50 | startMeasuringDuration("snapshotRemoval");
|
80 | 51 | }
|
81 | 52 |
|
|
121 | 92 | }
|
122 | 93 |
|
123 | 94 | // Second page loaded.
|
124 |
| - window.scrollTo(1000, 0); |
125 |
| - startSwipeGesture(); |
| 95 | + window.scrollTo(100, 0); |
| 96 | + |
| 97 | + runTest(); |
126 | 98 | };
|
127 | 99 | </script>
|
128 | 100 | </head>
|
|
0 commit comments