1#import "CPTFillTests.h" 2#import "CPTFill.h" 3#import "_CPTFillColor.h" 4#import "_CPTFillGradient.h" 5#import "_CPTFillImage.h" 6#import "CPTColor.h" 7#import "CPTGradient.h" 8#import "CPTImage.h" 9 10@interface _CPTFillColor() 11 12@property (nonatomic, readwrite, copy) CPTColor *fillColor; 13 14@end 15 16#pragma mark - 17 18@interface _CPTFillGradient() 19 20@property (nonatomic, readwrite, copy) CPTGradient *fillGradient; 21 22@end 23 24#pragma mark - 25 26@interface _CPTFillImage() 27 28@property (nonatomic, readwrite, copy) CPTImage *fillImage; 29 30@end 31 32#pragma mark - 33 34@implementation CPTFillTests 35 36#pragma mark - 37#pragma mark NSCoding 38 39-(void)testKeyedArchivingRoundTripColor 40{ 41 _CPTFillColor *fill = (_CPTFillColor *)[CPTFill fillWithColor:[CPTColor redColor]]; 42 43 _CPTFillColor *newFill = [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:fill]]; 44 45 STAssertEqualObjects(fill.fillColor, newFill.fillColor, @"Fill with color not equal"); 46} 47 48-(void)testKeyedArchivingRoundTripGradient 49{ 50 _CPTFillGradient *fill = (_CPTFillGradient *)[CPTFill fillWithGradient:[CPTGradient rainbowGradient]]; 51 52 _CPTFillGradient *newFill = [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:fill]]; 53 54 STAssertEqualObjects(fill.fillGradient, newFill.fillGradient, @"Fill with gradient not equal"); 55} 56 57-(void)testKeyedArchivingRoundTripImage 58{ 59 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 60 CGImageRef cgImage = CGImageCreate(100, 100, 8, 32, 400, colorSpace, kCGBitmapAlphaInfoMask, NULL, NULL, YES, kCGRenderingIntentDefault); 61 62 CPTImage *image = [CPTImage imageWithCGImage:cgImage]; 63 image.tiled = YES; 64 image.tileAnchoredToContext = YES; 65 66 CGColorSpaceRelease(colorSpace); 67 CGImageRelease(cgImage); 68 69 _CPTFillImage *fill = (_CPTFillImage *)[CPTFill fillWithImage:image]; 70 71 _CPTFillImage *newFill = [NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:fill]]; 72 73 STAssertEqualObjects(fill.fillImage, newFill.fillImage, @"Fill with image not equal"); 74} 75 76@end 77