From 299a66d9ed4fe2d293d5c2b1a5186f3e1956ea47 Mon Sep 17 00:00:00 2001 From: Jason Stallings Date: Sat, 15 Oct 2016 18:42:51 -0500 Subject: [PATCH] Fix tests for higher density screens. --- test/bitmap.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/bitmap.js b/test/bitmap.js index 0cac4d7b..4f688861 100644 --- a/test/bitmap.js +++ b/test/bitmap.js @@ -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.'); }); @@ -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()