Skip to content

Commit

Permalink
Remove ANIMATED_GIF_SUPPORT preprocessor conditionals from unit tests
Browse files Browse the repository at this point in the history
When we added Carthage support ( #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.
  • Loading branch information
cdzombak committed Mar 8, 2016
1 parent 65a5cfb commit bdd7510
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions NYTPhotoViewerTests/NYTScalingImageViewTests.m
Expand Up @@ -10,10 +10,7 @@
@import XCTest; @import XCTest;


#import <NYTPhotoViewer/NYTScalingImageView.h> #import <NYTPhotoViewer/NYTScalingImageView.h>

#ifdef ANIMATED_GIF_SUPPORT
#import <FLAnimatedImage/FLAnimatedImage.h> #import <FLAnimatedImage/FLAnimatedImage.h>
#endif


@interface NYTScalingImageViewTests : XCTestCase @interface NYTScalingImageViewTests : XCTestCase


Expand Down Expand Up @@ -70,11 +67,7 @@ - (void)testImageInitializationSetsImage {
- (void)testDataInitializationSetsImage { - (void)testDataInitializationSetsImage {
NYTScalingImageView *scalingImageView = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero]; NYTScalingImageView *scalingImageView = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero];


#ifdef ANIMATED_GIF_SUPPORT XCTAssertEqual(self.imageData, ((FLAnimatedImageView *)scalingImageView.imageView).animatedImage.data);
XCTAssertEqual(self.imageData, scalingImageView.imageView.animatedImage.data);
#else
XCTAssertNotNil(scalingImageView.imageView.image);
#endif
} }


- (void)testUpdateImageUpdatesImage { - (void)testUpdateImageUpdatesImage {
Expand All @@ -90,21 +83,14 @@ - (void)testUpdateImageDataUpdatesImage {


NYTScalingImageView *scalingImageView = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero]; NYTScalingImageView *scalingImageView = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero];
[scalingImageView updateImageData:image2]; [scalingImageView updateImageData:image2];


#ifdef ANIMATED_GIF_SUPPORT XCTAssertEqual(image2, ((FLAnimatedImageView *)scalingImageView.imageView).animatedImage.data);
XCTAssertEqual(image2, scalingImageView.imageView.animatedImage.data);
#else
XCTAssertNotNil(scalingImageView.imageView.image);
#endif
} }


- (void)testImageViewIsOfCorrectKindAfterInitialization { - (void)testImageViewIsOfCorrectKindAfterInitialization {
NYTScalingImageView *scalingImageViewer = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero]; NYTScalingImageView *scalingImageViewer = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero];
#ifdef ANIMATED_GIF_SUPPORT
XCTAssertTrue([scalingImageViewer.imageView isKindOfClass:FLAnimatedImageView.class]); XCTAssertTrue([scalingImageViewer.imageView isKindOfClass:FLAnimatedImageView.class]);
#else
XCTAssertTrue([scalingImageViewer.imageView isKindOfClass:UIImageView.class]);
#endif
} }


@end @end

0 comments on commit bdd7510

Please sign in to comment.