From bdd7510c2f4c69c577c91aa98e2bc5ed9baa33a6 Mon Sep 17 00:00:00 2001 From: Chris Dzombak Date: Tue, 8 Mar 2016 10:26:40 -0500 Subject: [PATCH] Remove `ANIMATED_GIF_SUPPORT` preprocessor conditionals from unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we added Carthage support ( https://github.com/NYTimes/NYTPhotoViewer/pull/164 ), we created two NYTPhotoViewer targets: the “normal” one which includes animated gif support (via `ANIMATED_GIF_SUPPORT=1`, and requires linking with FLAnimatedImage); and the “-Core” target which does not include animated GIF support. For brevity I will refer to the library version with animated gif support as “-Normal” even though it doesn’t have that suffix (the “-Core” target _does_ have that suffix). The unit tests are configured to run against the “-Normal” target, but they weren’t compiled with `ANIMATED_GIF_SUPPORT=1`, so we were running unit tests intended for “-Core” against the “-Normal” target. This resulted in some test failures. I’ve fixed them by removing the `ANIMATED_GIF_SUPPORT` conditionals from the test target, leaving in the code that should be run against “-Normal”. I am unsure whether it’s worth making a new “-Core” test target just to include the three assertions (removed in this commit) which were intended to apply to “-Core”. Feedback is welcome. --- .../NYTScalingImageViewTests.m | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/NYTPhotoViewerTests/NYTScalingImageViewTests.m b/NYTPhotoViewerTests/NYTScalingImageViewTests.m index 475e4b4e..162518b7 100644 --- a/NYTPhotoViewerTests/NYTScalingImageViewTests.m +++ b/NYTPhotoViewerTests/NYTScalingImageViewTests.m @@ -10,10 +10,7 @@ @import XCTest; #import - -#ifdef ANIMATED_GIF_SUPPORT #import -#endif @interface NYTScalingImageViewTests : XCTestCase @@ -70,11 +67,7 @@ - (void)testImageInitializationSetsImage { - (void)testDataInitializationSetsImage { NYTScalingImageView *scalingImageView = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero]; -#ifdef ANIMATED_GIF_SUPPORT - XCTAssertEqual(self.imageData, scalingImageView.imageView.animatedImage.data); -#else - XCTAssertNotNil(scalingImageView.imageView.image); -#endif + XCTAssertEqual(self.imageData, ((FLAnimatedImageView *)scalingImageView.imageView).animatedImage.data); } - (void)testUpdateImageUpdatesImage { @@ -90,21 +83,14 @@ - (void)testUpdateImageDataUpdatesImage { NYTScalingImageView *scalingImageView = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero]; [scalingImageView updateImageData:image2]; - -#ifdef ANIMATED_GIF_SUPPORT - XCTAssertEqual(image2, scalingImageView.imageView.animatedImage.data); -#else - XCTAssertNotNil(scalingImageView.imageView.image); -#endif + + XCTAssertEqual(image2, ((FLAnimatedImageView *)scalingImageView.imageView).animatedImage.data); } - (void)testImageViewIsOfCorrectKindAfterInitialization { NYTScalingImageView *scalingImageViewer = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero]; -#ifdef ANIMATED_GIF_SUPPORT + XCTAssertTrue([scalingImageViewer.imageView isKindOfClass:FLAnimatedImageView.class]); -#else - XCTAssertTrue([scalingImageViewer.imageView isKindOfClass:UIImageView.class]); -#endif } @end