mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-23 03:09:27 +00:00
Migrated project to XCTest
This commit is contained in:
@@ -6,9 +6,16 @@
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "KPKIconLoading.h"
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "KPKIcon.h"
|
||||
|
||||
@interface KPKIconLoading : XCTestCase {
|
||||
NSImage *_image;
|
||||
NSData *_imageData;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation KPKIconLoading
|
||||
|
||||
- (void)setUp {
|
||||
@@ -26,17 +33,17 @@
|
||||
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
|
||||
NSURL *imageURL = [myBundle URLForImageResource:@"image.png"];
|
||||
KPKIcon *icon = [[KPKIcon alloc] initWithImageAtURL:imageURL];
|
||||
STAssertNotNil(icon, @"Icon should have been loaded");
|
||||
XCTAssertNotNil(icon, @"Icon should have been loaded");
|
||||
NSString *iconString = [icon encodedString];
|
||||
KPKIcon *iconFromString = [[KPKIcon alloc] initWithUUID:[NSUUID UUID] encodedString:iconString];
|
||||
STAssertTrue([iconString isEqualToString:[iconFromString encodedString]], @"Encoding and Decoding should result in the same string");
|
||||
XCTAssertTrue([iconString isEqualToString:[iconFromString encodedString]], @"Encoding and Decoding should result in the same string");
|
||||
Class repClass = [NSBitmapImageRep class];
|
||||
NSImageRep *imageRep = [[icon.image representations] lastObject];
|
||||
STAssertNotNil(imageRep, @"One image rep shoudl be there");
|
||||
STAssertTrue([imageRep isKindOfClass:repClass], @"Representation should be bitmap");
|
||||
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];
|
||||
STAssertTrue([pngData isEqualToData:_imageData], @"Image and PNG data shoudl be identical");
|
||||
XCTAssertTrue([pngData isEqualToData:_imageData], @"Image and PNG data shoudl be identical");
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user