зеркало из https://github.com/github/Rebel.git
Add assertions to check we have the blue border
This commit is contained in:
Родитель
6fbb21c28a
Коммит
89eae4bf5d
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче