Skip to content

Commit

Permalink
add DPI for canvas tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Feb 7, 2015
1 parent 6e5a18e commit eae5ae6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ realOffsetLeft = (o) ->
transform = new WebKitCSSMatrix window.getComputedStyle(o).transform
o.offsetLeft + transform.m41

devicePixelRatio = window.devicePixelRatio || 1

sleep = (duration) ->
t = new Date
waitsFor -> new Date - t > duration
Expand Down Expand Up @@ -119,8 +121,8 @@ describe 'MinimapElement', ->
expect(minimapElement.offsetWidth).toBeCloseTo(editorElement.clientWidth / 11, 0)

it 'resizes the canvas to fit the minimap', ->
expect(canvas.offsetHeight).toEqual(minimapElement.offsetHeight + minimap.getLineHeight())
expect(canvas.offsetWidth).toEqual(minimapElement.offsetWidth)
expect(canvas.offsetHeight / devicePixelRatio).toEqual(minimapElement.offsetHeight + minimap.getLineHeight())
expect(canvas.offsetWidth / devicePixelRatio).toEqual(minimapElement.offsetWidth)

it 'requests an update', ->
expect(minimapElement.frameRequested).toBeTruthy()
Expand Down Expand Up @@ -202,8 +204,8 @@ describe 'MinimapElement', ->
expect(minimapElement.offsetWidth).toBeCloseTo(editorElement.offsetWidth / 11, 0)
expect(minimapElement.offsetHeight).toEqual(editorElement.offsetHeight)

expect(canvas.offsetWidth).toEqual(minimapElement.offsetWidth)
expect(canvas.offsetHeight).toEqual(minimapElement.offsetHeight + minimap.getLineHeight())
expect(canvas.offsetWidth / devicePixelRatio).toEqual(minimapElement.offsetWidth)
expect(canvas.offsetHeight / devicePixelRatio).toEqual(minimapElement.offsetHeight + minimap.getLineHeight())

describe 'when the editor visible content is changed', ->
beforeEach ->
Expand Down Expand Up @@ -500,7 +502,7 @@ describe 'MinimapElement', ->
nextAnimationFrame()

it 'adjusts the width of the minimap canvas', ->
expect(minimapElement.canvas.width).toEqual(4)
expect(minimapElement.canvas.width / devicePixelRatio).toEqual(4)

it 'offsets the minimap by the difference', ->
expect(realOffsetLeft(minimapElement)).toBeCloseTo(editorElement.clientWidth - 4, -1)
Expand All @@ -511,7 +513,7 @@ describe 'MinimapElement', ->
sleep(150)
runs ->
nextAnimationFrame()
expect(minimapElement.canvas.width).toEqual(4)
expect(minimapElement.canvas.width / devicePixelRatio).toEqual(4)

describe 'when the editor is resized', ->
beforeEach ->
Expand Down

0 comments on commit eae5ae6

Please sign in to comment.