forked from core-plot/core-plot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPTImageTests.m
More file actions
38 lines (26 loc) · 1 KB
/
CPTImageTests.m
File metadata and controls
38 lines (26 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#import "CPTImageTests.h"
#import "CPTImage.h"
@implementation CPTImageTests
#pragma mark -
#pragma mark NSCoding Methods
-(void)testKeyedArchivingRoundTrip
{
const size_t width = 100;
const size_t height = 100;
size_t bytesPerRow = (4 * width + 15) & ~15ul;
#if TARGET_OS_SIMULATOR || TARGET_OS_IPHONE
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
#else
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
#endif
CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, bytesPerRow, colorSpace, (CGBitmapInfo)kCGImageAlphaNoneSkipLast);
CGImageRef cgImage = CGBitmapContextCreateImage(context);
CPTImage *image = [CPTImage imageWithCGImage:cgImage];
image.tiled = YES;
image.tileAnchoredToContext = YES;
CGColorSpaceRelease(colorSpace);
CGImageRelease(cgImage);
CPTImage *newImage = [self archiveRoundTrip:image];
XCTAssertEqualObjects(image, newImage, @"Images not equal");
}
@end