Skip to content

Commit

Permalink
automaticallyInflatesResponseImage and imageScale properties are not …
Browse files Browse the repository at this point in the history
…available on MacOS X, using the preprocessor to handle that correctly.
  • Loading branch information
quellish committed Mar 14, 2016
1 parent ca22ad5 commit c297688
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Tests/Tests/AFImageResponseSerializerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ - (void)testImageSerializerCanBeCopied {
XCTAssertNotEqual(copiedSerializer, responseSerializer);
XCTAssertTrue([copiedSerializer.acceptableContentTypes isEqualToSet:responseSerializer.acceptableContentTypes]);
XCTAssertTrue([copiedSerializer.acceptableStatusCodes isEqualToIndexSet:responseSerializer.acceptableStatusCodes]);
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
XCTAssertTrue(copiedSerializer.automaticallyInflatesResponseImage == responseSerializer.automaticallyInflatesResponseImage);
XCTAssertTrue(fabs(copiedSerializer.imageScale - responseSerializer.imageScale) <= 0.001);
#endif

}

Expand All @@ -60,25 +62,34 @@ - (void)testImageSerializerCanBeArchivedAndUnarchived {
XCTAssertNotEqual(unarchivedSerializer, responseSerializer);
XCTAssertTrue([unarchivedSerializer.acceptableContentTypes isEqualToSet:responseSerializer.acceptableContentTypes]);
XCTAssertTrue([unarchivedSerializer.acceptableStatusCodes isEqualToIndexSet:responseSerializer.acceptableStatusCodes]);

#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
XCTAssertTrue(unarchivedSerializer.automaticallyInflatesResponseImage == responseSerializer.automaticallyInflatesResponseImage);
XCTAssertTrue(fabs(unarchivedSerializer.imageScale - responseSerializer.imageScale) <= 0.001);
#endif

}

- (void)testImageSerializerCanBeArchivedAndUnarchivedWithNonDefaultPropertyValues {
AFImageResponseSerializer *responseSerializer = [AFImageResponseSerializer serializer];
NSData *archive = nil;

// Customize the default property values
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
responseSerializer.automaticallyInflatesResponseImage = !responseSerializer.automaticallyInflatesResponseImage;
responseSerializer.imageScale = responseSerializer.imageScale * 2.0f;
#endif

archive = [NSKeyedArchiver archivedDataWithRootObject:responseSerializer];
XCTAssertNotNil(archive);
AFImageResponseSerializer *unarchivedSerializer = [NSKeyedUnarchiver unarchiveObjectWithData:archive];
XCTAssertNotNil(unarchivedSerializer);
XCTAssertNotEqual(unarchivedSerializer, responseSerializer);

#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
XCTAssertTrue(unarchivedSerializer.automaticallyInflatesResponseImage == responseSerializer.automaticallyInflatesResponseImage);
XCTAssertTrue(fabs(unarchivedSerializer.imageScale - responseSerializer.imageScale) <= 0.001);
#endif
}

@end

0 comments on commit c297688

Please sign in to comment.