Skip to content

Commit

Permalink
Fix tests for higher density screens.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Oct 15, 2016
1 parent f58e519 commit 299a66d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions test/bitmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ test('Get a bitmap of a specific size.', function(t)
var size = 10;
t.plan(2);
var img = robot.screen.capture(0, 0, size, size);


// Support for higher density screens.
if (img.width == (size*2)) size = img.width;
t.equals(img.height, size, 'make sure image is expected height.');
t.equals(img.width, size, 'make sure image is expected width.');
});
Expand All @@ -47,25 +49,30 @@ test('Get a bitmap and make sure the colorAt works as expected.', function(t)
t.ok(/^[0-9A-F]{6}$/i.test(hex), "colorAt returned valid hex.");

var screenSize = robot.getScreenSize();

var width = screenSize.width;
var height = screenSize.height;

// Support for higher density screens.
if (img.width === (width*2)) width = img.width; height = img.height;

t.throws(function()
{
img.colorAt(0, screenSize.height);
img.colorAt(0, height);
}, /are outside the bitmap/, 'colorAt (0, screen.height) threw an error.');

t.doesNotThrow(function()
{
img.colorAt(0, screenSize.height-1);
img.colorAt(0, height-1);
}, /are outside the bitmap/, 'colorAt (0, screen.height-1) did not throw an error.');

t.throws(function()
{
img.colorAt(screenSize.width, 0);
img.colorAt(width, 0);
}, /are outside the bitmap/, 'colorAt (screen.width, 0) threw an error.');

t.doesNotThrow(function()
{
img.colorAt(screenSize.width-1, 0);
img.colorAt(width-1, 0);
}, /are outside the bitmap/, 'colorAt (screen.width-1, 0) did not throw an error.');

t.throws(function()
Expand Down

0 comments on commit 299a66d

Please sign in to comment.