Add assertions to check we have the blue border

This commit is contained in:
Alan Rogers 2013-04-23 11:51:14 +10:00
Родитель 6fbb21c28a
Коммит 89eae4bf5d
1 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -11,6 +11,7 @@
SpecBegin(RBLResizableImage)
__block RBLResizableImage *testImage = nil;
__block void(^expectBlueBorder)(NSBitmapImageRep* imageRep, NSSize size) = nil;
beforeEach(^{
NSURL *testImageURL = [[NSBundle bundleForClass:self.class] URLForResource:@"<RBLResizableImageSpec>_testimage" withExtension:@"tiff"];
@ -20,6 +21,35 @@ beforeEach(^{
testImage = [[RBLResizableImage alloc] initByReferencingURL:testImageURL];
expect(testImage).toNot.beNil();
expectBlueBorder = ^(NSBitmapImageRep *imageRep, NSSize size) {
NSUInteger topLeft[4], bottomRight[4];
// confirm we have the borders
[imageRep getPixel:&topLeft[0] atX:0 y:0];
NSUInteger red = topLeft[0];
NSUInteger green = topLeft[1];
NSUInteger blue = topLeft[2];
NSUInteger alpha = topLeft[3];
expect(red).to.equal(0);
expect(green).to.equal(0);
expect(blue).to.equal(255);
expect(alpha).to.equal(255);
[imageRep getPixel:&bottomRight[0] atX:(NSUInteger)(size.width - 1) y:(NSUInteger)(size.height - 1)];
red = bottomRight[0];
green = bottomRight[1];
blue = bottomRight[2];
alpha = bottomRight[3];
expect(red).to.equal(0);
expect(green).to.equal(0);
expect(blue).to.equal(255);
expect(alpha).to.equal(255);
};
});
it(@"should use @1x asset in @1x context", ^{
@ -49,6 +79,8 @@ it(@"should use @1x asset in @1x context", ^{
expect(green).to.equal(0);
expect(blue).to.equal(0);
expect(alpha).to.equal(255);
expectBlueBorder(bitmapImageRep, targetSize);
});
it(@"should use @2x asset in @2x context", ^{
@ -78,6 +110,8 @@ it(@"should use @2x asset in @2x context", ^{
expect(green).to.equal(255);
expect(blue).to.equal(0);
expect(alpha).to.equal(255);
expectBlueBorder(bitmapImageRep, targetSize);
});
SpecEnd