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 this.scrollElement.scrollLeft = {x: testCase.endX, behavior: "instant"}; | 39 this.scrollElement.scrollTo({left: testCase.endX, top: testCase.endY, be
havior: "instant"}); |
40 this.scrollElement.scrollTop = {y: testCase.endY, behavior: "instant"}; | |
41 this.testCaseComplete(); | 40 this.testCaseComplete(); |
42 } | 41 } |
43 }; | 42 }; |
44 | 43 |
45 ScrollBehaviorTest.prototype.startNextTestCase = function() { | 44 ScrollBehaviorTest.prototype.startNextTestCase = function() { |
46 if (this.currentTestCase >= this.testCases.length) { | 45 if (this.currentTestCase >= this.testCases.length) { |
47 this.allTestCasesComplete(); | 46 this.allTestCasesComplete(); |
48 return; | 47 return; |
49 } | 48 } |
50 var testCase = this.testCases[this.currentTestCase]; | 49 var testCase = this.testCases[this.currentTestCase]; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 123 |
125 ScrollBehaviorTestCase.prototype.setStartPosition = function(startPosition) { | 124 ScrollBehaviorTestCase.prototype.setStartPosition = function(startPosition) { |
126 this.startX = startPosition.x; | 125 this.startX = startPosition.x; |
127 this.startY = startPosition.y; | 126 this.startY = startPosition.y; |
128 } | 127 } |
129 | 128 |
130 ScrollBehaviorTestCase.prototype.setEndPosition = function(endPosition) { | 129 ScrollBehaviorTestCase.prototype.setEndPosition = function(endPosition) { |
131 this.endX = endPosition.x; | 130 this.endX = endPosition.x; |
132 this.endY = endPosition.y; | 131 this.endY = endPosition.y; |
133 } | 132 } |
OLD | NEW |