Adopted new KPKIcon API

This commit is contained in:
michael starke
2015-07-23 12:55:53 +02:00
parent 3753ba4128
commit 3301259417
2 changed files with 7 additions and 6 deletions

View File

@@ -21,7 +21,8 @@
- (void)setUp {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
_image = [myBundle imageForResource:@"image.png"];
_imageData = [[[_image representations] lastObject] representationUsingType:NSPNGFileType properties:nil];
_imageData = [_image TIFFRepresentation];
//_imageData = [_image.representations.lastObject representationUsingType:NSPNGFileType properties:nil];
}
- (void)tearDown {
@@ -34,16 +35,16 @@
NSURL *imageURL = [myBundle URLForImageResource:@"image.png"];
KPKIcon *icon = [[KPKIcon alloc] initWithImageAtURL:imageURL];
XCTAssertNotNil(icon, @"Icon should have been loaded");
NSString *iconString = [icon encodedString];
NSString *iconString = icon.encodedString;
KPKIcon *iconFromString = [[KPKIcon alloc] initWithUUID:[NSUUID UUID] encodedString:iconString];
XCTAssertTrue([iconString isEqualToString:[iconFromString encodedString]], @"Encoding and Decoding should result in the same string");
XCTAssertEqualObjects(iconString, iconFromString.encodedString, @"Encoding and Decoding should result in the same string");
Class repClass = [NSBitmapImageRep class];
NSImageRep *imageRep = [[icon.image representations] lastObject];
NSImageRep *imageRep = icon.image.representations.lastObject;
XCTAssertNotNil(imageRep, @"One image rep shoudl be there");
XCTAssertTrue([imageRep isKindOfClass:repClass], @"Representation should be bitmap");
NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)imageRep;
NSData *pngData = [bitmapRep representationUsingType:NSPNGFileType properties:nil];
XCTAssertTrue([pngData isEqualToData:_imageData], @"Image and PNG data shoudl be identical");
XCTAssertEqualObjects(pngData, _imageData, @"Image and PNG data shoudl be identical");
}
@end