| 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 29 matching lines...) Expand all Loading... |
| 40 this.scrollElement.scrollTop = {y: testCase.endY, behavior: "instant"}; | 40 this.scrollElement.scrollTop = {y: testCase.endY, behavior: "instant"}; |
| 41 this.testCaseComplete(); | 41 this.testCaseComplete(); |
| 42 } | 42 } |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 ScrollBehaviorTest.prototype.startNextTestCase = function() { | 45 ScrollBehaviorTest.prototype.startNextTestCase = function() { |
| 46 if (this.currentTestCase >= this.testCases.length) { | 46 if (this.currentTestCase >= this.testCases.length) { |
| 47 this.allTestCasesComplete(); | 47 this.allTestCasesComplete(); |
| 48 return; | 48 return; |
| 49 } | 49 } |
| 50 | |
| 51 var testCase = this.testCases[this.currentTestCase]; | 50 var testCase = this.testCases[this.currentTestCase]; |
| 52 var isSmoothTest = (testCase.js == "smooth" || (testCase.css == "smooth" &&
testCase.js != "instant")); | 51 var isSmoothTest = (testCase.js == "smooth" || (testCase.css == "smooth" &&
testCase.js != "instant")); |
| 53 | 52 |
| 54 this.asyncTest = async_test("Scroll x:" + testCase.x + ", y:" + testCase.y +
", smooth:" + isSmoothTest); | 53 this.asyncTest = async_test("Scroll x:" + testCase.x + ", y:" + testCase.y +
", smooth:" + isSmoothTest); |
| 55 | 54 |
| 56 var currentPosition = {}; | 55 var currentPosition = {}; |
| 57 currentPosition.x = this.scrollElement.scrollLeft; | 56 currentPosition.x = this.scrollElement.scrollLeft; |
| 58 currentPosition.y = this.scrollElement.scrollTop; | 57 currentPosition.y = this.scrollElement.scrollTop; |
| 59 var endPosition = this.getEndPosition(testCase, currentPosition); | 58 var endPosition = this.getEndPosition(testCase, currentPosition); |
| 60 testCase.setStartPosition(currentPosition); | 59 testCase.setStartPosition(currentPosition); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 124 |
| 126 ScrollBehaviorTestCase.prototype.setStartPosition = function(startPosition) { | 125 ScrollBehaviorTestCase.prototype.setStartPosition = function(startPosition) { |
| 127 this.startX = startPosition.x; | 126 this.startX = startPosition.x; |
| 128 this.startY = startPosition.y; | 127 this.startY = startPosition.y; |
| 129 } | 128 } |
| 130 | 129 |
| 131 ScrollBehaviorTestCase.prototype.setEndPosition = function(endPosition) { | 130 ScrollBehaviorTestCase.prototype.setEndPosition = function(endPosition) { |
| 132 this.endX = endPosition.x; | 131 this.endX = endPosition.x; |
| 133 this.endY = endPosition.y; | 132 this.endY = endPosition.y; |
| 134 } | 133 } |
| OLD | NEW |