OLD | NEW |
1 // A ScrollBehaviorTest runs a set of ScrollBehaviorTestCases. The only | 1 // A ScrollBehaviorTest runs a set of ScrollBehaviorTestCases. The only |
2 // ScrollBehaviorTest method that should be called by external code is run(). | 2 // ScrollBehaviorTest method that should be called by external code is run(). |
3 | 3 |
4 // Creates a ScrollBehaviorTest with arguments: | 4 // Creates a ScrollBehaviorTest with arguments: |
5 // scrollElement - Element being scrolled. | 5 // scrollElement - Element being scrolled. |
6 // scrollEventTarget - Target for scroll events for |scrollElement|. | 6 // scrollEventTarget - Target for scroll events for |scrollElement|. |
7 // testsCases - Array of ScrollBehaviorTestCases. | 7 // testsCases - Array of ScrollBehaviorTestCases. |
8 // getEndPosition - Callback that takes a test case and start position, and | 8 // getEndPosition - Callback that takes a test case and start position, and |
9 // returns the corresponding end position (where positions | 9 // returns the corresponding end position (where positions |
10 // are dictionaries with x and y fields). | 10 // are dictionaries with x and y fields). |
(...skipping 18 matching lines...) Expand all Loading... |
29 ScrollBehaviorTest.prototype.scrollListener = function(testCase) { | 29 ScrollBehaviorTest.prototype.scrollListener = function(testCase) { |
30 if (testCase.waitForEnd) { | 30 if (testCase.waitForEnd) { |
31 if (this.scrollElement.scrollLeft == testCase.endX && this.scrollElement
.scrollTop == testCase.endY) | 31 if (this.scrollElement.scrollLeft == testCase.endX && this.scrollElement
.scrollTop == testCase.endY) |
32 this.testCaseComplete(); | 32 this.testCaseComplete(); |
33 return; | 33 return; |
34 } | 34 } |
35 | 35 |
36 // Wait for an intermediate frame, then instant-scroll to the end state. | 36 // Wait for an intermediate frame, then instant-scroll to the end state. |
37 if ((this.scrollElement.scrollLeft != testCase.startX || this.scrollElement.
scrollTop != testCase.startY) && | 37 if ((this.scrollElement.scrollLeft != testCase.startX || this.scrollElement.
scrollTop != testCase.startY) && |
38 (this.scrollElement.scrollLeft != testCase.endX || this.scrollElement.sc
rollTop != testCase.endY)) { | 38 (this.scrollElement.scrollLeft != testCase.endX || this.scrollElement.sc
rollTop != testCase.endY)) { |
| 39 // Instant scroll, and then wait for the next scroll event. This allows |
| 40 // the instant scroll to propagate to the compositor (when using |
| 41 // composited scrolling) so that the next smooth scroll starts at this |
| 42 // position (the compositor always starts smooth scrolls at the current |
| 43 // scroll position on the compositor thread). |
39 this.scrollElement.scrollTo({left: testCase.endX, top: testCase.endY, be
havior: "instant"}); | 44 this.scrollElement.scrollTo({left: testCase.endX, top: testCase.endY, be
havior: "instant"}); |
40 this.testCaseComplete(); | 45 testCase.waitForEnd = true; |
41 } | 46 } |
42 }; | 47 }; |
43 | 48 |
44 ScrollBehaviorTest.prototype.startNextTestCase = function() { | 49 ScrollBehaviorTest.prototype.startNextTestCase = function() { |
45 if (this.currentTestCase >= this.testCases.length) { | 50 if (this.currentTestCase >= this.testCases.length) { |
46 this.allTestCasesComplete(); | 51 this.allTestCasesComplete(); |
47 return; | 52 return; |
48 } | 53 } |
49 var testCase = this.testCases[this.currentTestCase]; | 54 var testCase = this.testCases[this.currentTestCase]; |
50 var isSmoothTest = (testCase.js == "smooth" || (testCase.css == "smooth" &&
testCase.js != "instant")); | 55 var isSmoothTest = (testCase.js == "smooth" || (testCase.css == "smooth" &&
testCase.js != "instant")); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 if (currentScrollListener) { | 93 if (currentScrollListener) { |
89 this.scrollEventTarget.removeEventListener("scroll", currentScrollListen
er); | 94 this.scrollEventTarget.removeEventListener("scroll", currentScrollListen
er); |
90 } | 95 } |
91 this.asyncTest.done(); | 96 this.asyncTest.done(); |
92 | 97 |
93 this.currentTestCase++; | 98 this.currentTestCase++; |
94 this.startNextTestCase(); | 99 this.startNextTestCase(); |
95 } | 100 } |
96 | 101 |
97 ScrollBehaviorTest.prototype.run = function() { | 102 ScrollBehaviorTest.prototype.run = function() { |
98 setup({explicit_done: true}); | 103 setup({explicit_done: true, explicit_timeout: true}); |
99 this.startNextTestCase(); | 104 this.startNextTestCase(); |
100 } | 105 } |
101 | 106 |
102 ScrollBehaviorTest.prototype.allTestCasesComplete = function() { | 107 ScrollBehaviorTest.prototype.allTestCasesComplete = function() { |
103 done(); | 108 done(); |
104 } | 109 } |
105 | 110 |
106 | 111 |
107 // A ScrollBehaviorTestCase represents a single scroll. | 112 // A ScrollBehaviorTestCase represents a single scroll. |
108 // | 113 // |
(...skipping 14 matching lines...) Expand all Loading... |
123 | 128 |
124 ScrollBehaviorTestCase.prototype.setStartPosition = function(startPosition) { | 129 ScrollBehaviorTestCase.prototype.setStartPosition = function(startPosition) { |
125 this.startX = startPosition.x; | 130 this.startX = startPosition.x; |
126 this.startY = startPosition.y; | 131 this.startY = startPosition.y; |
127 } | 132 } |
128 | 133 |
129 ScrollBehaviorTestCase.prototype.setEndPosition = function(endPosition) { | 134 ScrollBehaviorTestCase.prototype.setEndPosition = function(endPosition) { |
130 this.endX = endPosition.x; | 135 this.endX = endPosition.x; |
131 this.endY = endPosition.y; | 136 this.endY = endPosition.y; |
132 } | 137 } |
OLD | NEW |