Skip to content

Commit 299a66d

Browse files
committed
Fix tests for higher density screens.
1 parent f58e519 commit 299a66d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

test/bitmap.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ test('Get a bitmap of a specific size.', function(t)
3333
var size = 10;
3434
t.plan(2);
3535
var img = robot.screen.capture(0, 0, size, size);
36-
36+
37+
// Support for higher density screens.
38+
if (img.width == (size*2)) size = img.width;
3739
t.equals(img.height, size, 'make sure image is expected height.');
3840
t.equals(img.width, size, 'make sure image is expected width.');
3941
});
@@ -47,25 +49,30 @@ test('Get a bitmap and make sure the colorAt works as expected.', function(t)
4749
t.ok(/^[0-9A-F]{6}$/i.test(hex), "colorAt returned valid hex.");
4850

4951
var screenSize = robot.getScreenSize();
50-
52+
var width = screenSize.width;
53+
var height = screenSize.height;
54+
55+
// Support for higher density screens.
56+
if (img.width === (width*2)) width = img.width; height = img.height;
57+
5158
t.throws(function()
5259
{
53-
img.colorAt(0, screenSize.height);
60+
img.colorAt(0, height);
5461
}, /are outside the bitmap/, 'colorAt (0, screen.height) threw an error.');
5562

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

6168
t.throws(function()
6269
{
63-
img.colorAt(screenSize.width, 0);
70+
img.colorAt(width, 0);
6471
}, /are outside the bitmap/, 'colorAt (screen.width, 0) threw an error.');
6572

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

7178
t.throws(function()

0 commit comments

Comments
 (0)