Remove measureScrollView helper

This commit is contained in:
Corey Johnson & Nathan Sobo
2014-06-17 16:09:23 -07:00
parent 068c1e6249
commit 4564a39392

View File

@@ -47,19 +47,15 @@ describe "EditorComponent", ->
node.style.height = editor.getLineCount() * lineHeightInPixels + 'px'
node.style.width = '1000px'
measureScrollView()
component.measureScrollView()
afterEach ->
contentNode.style.width = ''
measureScrollView = ->
component.measureScrollView()
component.forceUpdate()
describe "line rendering", ->
it "renders the currently-visible lines plus the overdraw margin", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
measureScrollView()
component.measureScrollView()
linesNode = node.querySelector('.lines')
expect(linesNode.style['-webkit-transform']).toBe "translate3d(0px, 0px, 0px)"
@@ -126,7 +122,7 @@ describe "EditorComponent", ->
it "renders the .lines div at the full height of the editor if there aren't enough lines to scroll vertically", ->
editor.setText('')
node.style.height = '300px'
measureScrollView()
component.measureScrollView()
linesNode = node.querySelector('.lines')
expect(linesNode.offsetHeight).toBe 300
@@ -170,7 +166,7 @@ describe "EditorComponent", ->
editor.setText "a line that wraps "
editor.setSoftWrap(true)
node.style.width = 16 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
it "doesn't show end of line invisibles at the end of wrapped lines", ->
expect(component.lineNodeForScreenRow(0).textContent).toBe "a line that "
@@ -246,7 +242,7 @@ describe "EditorComponent", ->
it "renders the currently-visible line numbers", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
measureScrollView()
component.measureScrollView()
expect(node.querySelectorAll('.line-number').length).toBe 6 + 2 + 1 # line overdraw margin below + dummy line number
expect(component.lineNumberNodeForScreenRow(0).textContent).toBe "#{nbsp}1"
@@ -286,7 +282,7 @@ describe "EditorComponent", ->
editor.setSoftWrap(true)
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = 30 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
expect(node.querySelectorAll('.line-number').length).toBe 6 + lineOverdrawMargin + 1 # 1 dummy line node
expect(component.lineNumberNodeForScreenRow(0).textContent).toBe "#{nbsp}1"
@@ -432,7 +428,7 @@ describe "EditorComponent", ->
describe "when decorations are applied to buffer rows", ->
it "renders line number classes based on the decorations on their buffer row", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
measureScrollView()
component.measureScrollView()
expect(component.lineNumberNodeForScreenRow(9)).not.toBeDefined()
@@ -469,7 +465,7 @@ describe "EditorComponent", ->
editor.setSoftWrap(true)
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = 30 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
expect(lineNumberHasClass(2, 'no-wrap')).toBe true
expect(lineNumberHasClass(2, 'wrap-me')).toBe true
@@ -586,7 +582,7 @@ describe "EditorComponent", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = 20 * lineHeightInPixels + 'px'
measureScrollView()
component.measureScrollView()
cursorNodes = node.querySelectorAll('.cursor')
expect(cursorNodes.length).toBe 1
@@ -785,7 +781,7 @@ describe "EditorComponent", ->
inputNode = node.querySelector('.hidden-input')
node.style.height = 5 * lineHeightInPixels + 'px'
node.style.width = 10 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
expect(editor.getCursorScreenPosition()).toEqual [0, 0]
editor.setScrollTop(3 * lineHeightInPixels)
@@ -831,7 +827,7 @@ describe "EditorComponent", ->
it "moves the cursor to the nearest screen position", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = 10 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
editor.setScrollTop(3.5 * lineHeightInPixels)
editor.setScrollLeft(2 * charWidth)
@@ -956,7 +952,7 @@ describe "EditorComponent", ->
describe "scrolling", ->
it "updates the vertical scrollbar when the scrollTop is changed in the model", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
measureScrollView()
component.measureScrollView()
expect(verticalScrollbarNode.scrollTop).toBe 0
@@ -965,7 +961,7 @@ describe "EditorComponent", ->
it "updates the horizontal scrollbar and the x transform of the lines based on the scrollLeft of the model", ->
node.style.width = 30 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
linesNode = node.querySelector('.lines')
expect(linesNode.style['-webkit-transform']).toBe "translate3d(0px, 0px, 0px)"
@@ -977,7 +973,7 @@ describe "EditorComponent", ->
it "updates the scrollLeft of the model when the scrollLeft of the horizontal scrollbar changes", ->
node.style.width = 30 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
expect(editor.getScrollLeft()).toBe 0
horizontalScrollbarNode.scrollLeft = 100
@@ -988,7 +984,7 @@ describe "EditorComponent", ->
it "does not obscure the last line with the horizontal scrollbar", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = 10 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
editor.setScrollBottom(editor.getScrollHeight())
lastLineNode = component.lineNodeForScreenRow(editor.getLastScreenRow())
bottomOfLastLine = lastLineNode.getBoundingClientRect().bottom
@@ -997,7 +993,7 @@ describe "EditorComponent", ->
# Scroll so there's no space below the last line when the horizontal scrollbar disappears
node.style.width = 100 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
bottomOfLastLine = lastLineNode.getBoundingClientRect().bottom
bottomOfEditor = node.getBoundingClientRect().bottom
expect(bottomOfLastLine).toBe bottomOfEditor
@@ -1005,7 +1001,7 @@ describe "EditorComponent", ->
it "does not obscure the last character of the longest line with the vertical scrollbar", ->
node.style.height = 7 * lineHeightInPixels + 'px'
node.style.width = 10 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
editor.setScrollLeft(Infinity)
@@ -1019,19 +1015,19 @@ describe "EditorComponent", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = '1000px'
measureScrollView()
component.measureScrollView()
expect(verticalScrollbarNode.style.display).toBe ''
expect(horizontalScrollbarNode.style.display).toBe 'none'
node.style.width = 10 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
expect(verticalScrollbarNode.style.display).toBe ''
expect(horizontalScrollbarNode.style.display).toBe ''
node.style.height = 20 * lineHeightInPixels + 'px'
measureScrollView()
component.measureScrollView()
expect(verticalScrollbarNode.style.display).toBe 'none'
expect(horizontalScrollbarNode.style.display).toBe ''
@@ -1039,7 +1035,7 @@ describe "EditorComponent", ->
it "makes the dummy scrollbar divs only as tall/wide as the actual scrollbars", ->
node.style.height = 4 * lineHeightInPixels + 'px'
node.style.width = 10 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
atom.themes.applyStylesheet "test", """
::-webkit-scrollbar {
@@ -1062,19 +1058,19 @@ describe "EditorComponent", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = '1000px'
measureScrollView()
component.measureScrollView()
expect(verticalScrollbarNode.style.bottom).toBe ''
expect(horizontalScrollbarNode.style.right).toBe verticalScrollbarNode.offsetWidth + 'px'
expect(scrollbarCornerNode.style.display).toBe 'none'
node.style.width = 10 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
expect(verticalScrollbarNode.style.bottom).toBe horizontalScrollbarNode.offsetHeight + 'px'
expect(horizontalScrollbarNode.style.right).toBe verticalScrollbarNode.offsetWidth + 'px'
expect(scrollbarCornerNode.style.display).toBe ''
node.style.height = 20 * lineHeightInPixels + 'px'
measureScrollView()
component.measureScrollView()
expect(verticalScrollbarNode.style.bottom).toBe horizontalScrollbarNode.offsetHeight + 'px'
expect(horizontalScrollbarNode.style.right).toBe ''
expect(scrollbarCornerNode.style.display).toBe 'none'
@@ -1082,7 +1078,7 @@ describe "EditorComponent", ->
it "accounts for the width of the gutter in the scrollWidth of the horizontal scrollbar", ->
gutterNode = node.querySelector('.gutter')
node.style.width = 10 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
expect(horizontalScrollbarNode.scrollWidth).toBe gutterNode.offsetWidth + editor.getScrollWidth()
@@ -1094,7 +1090,7 @@ describe "EditorComponent", ->
beforeEach ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = 20 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
it "updates the scrollLeft or scrollTop on mousewheel events depending on which delta is greater (x or y)", ->
expect(verticalScrollbarNode.scrollTop).toBe 0
@@ -1132,7 +1128,7 @@ describe "EditorComponent", ->
it "keeps the line on the DOM if it is scrolled off-screen", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = 20 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
lineNode = node.querySelector('.line')
wheelEvent = new WheelEvent('mousewheel', wheelDeltaX: 0, wheelDeltaY: -500)
@@ -1144,7 +1140,7 @@ describe "EditorComponent", ->
it "does not set the mouseWheelScreenRow if scrolling horizontally", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = 20 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
lineNode = node.querySelector('.line')
wheelEvent = new WheelEvent('mousewheel', wheelDeltaX: 10, wheelDeltaY: 0)
@@ -1188,7 +1184,7 @@ describe "EditorComponent", ->
it "keeps the line number on the DOM if it is scrolled off-screen", ->
node.style.height = 4.5 * lineHeightInPixels + 'px'
node.style.width = 20 * charWidth + 'px'
measureScrollView()
component.measureScrollView()
lineNumberNode = node.querySelectorAll('.line-number')[1]
wheelEvent = new WheelEvent('mousewheel', wheelDeltaX: 0, wheelDeltaY: -500)