mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 11:42:30 +00:00
Adopted new KPKIcon API
This commit is contained in:
Submodule KeePassKit updated: 8decbd4909...da76d93bb3
@@ -21,7 +21,8 @@
|
|||||||
- (void)setUp {
|
- (void)setUp {
|
||||||
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
|
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
|
||||||
_image = [myBundle imageForResource:@"image.png"];
|
_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 {
|
- (void)tearDown {
|
||||||
@@ -34,16 +35,16 @@
|
|||||||
NSURL *imageURL = [myBundle URLForImageResource:@"image.png"];
|
NSURL *imageURL = [myBundle URLForImageResource:@"image.png"];
|
||||||
KPKIcon *icon = [[KPKIcon alloc] initWithImageAtURL:imageURL];
|
KPKIcon *icon = [[KPKIcon alloc] initWithImageAtURL:imageURL];
|
||||||
XCTAssertNotNil(icon, @"Icon should have been loaded");
|
XCTAssertNotNil(icon, @"Icon should have been loaded");
|
||||||
NSString *iconString = [icon encodedString];
|
NSString *iconString = icon.encodedString;
|
||||||
KPKIcon *iconFromString = [[KPKIcon alloc] initWithUUID:[NSUUID UUID] encodedString:iconString];
|
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];
|
Class repClass = [NSBitmapImageRep class];
|
||||||
NSImageRep *imageRep = [[icon.image representations] lastObject];
|
NSImageRep *imageRep = icon.image.representations.lastObject;
|
||||||
XCTAssertNotNil(imageRep, @"One image rep shoudl be there");
|
XCTAssertNotNil(imageRep, @"One image rep shoudl be there");
|
||||||
XCTAssertTrue([imageRep isKindOfClass:repClass], @"Representation should be bitmap");
|
XCTAssertTrue([imageRep isKindOfClass:repClass], @"Representation should be bitmap");
|
||||||
NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)imageRep;
|
NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)imageRep;
|
||||||
NSData *pngData = [bitmapRep representationUsingType:NSPNGFileType properties:nil];
|
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
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user