Skip to content

Commit

Permalink
Fixing image loading and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Mroczkowski committed Nov 27, 2013
1 parent b4a3877 commit 6cc303b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 6 additions & 2 deletions Zinc/Private/UIImage+Zinc.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ + (UIImage *)zinc_imageNamed:(NSString *)name inBundle:(id)bundle

// if the image is still nil, try to load without the cache
if (image == nil) {
image = [UIImage imageWithContentsOfFile:
[bundlePath stringByAppendingPathComponent:name]];
for (NSString* imageName in imageNames) {
image = [UIImage imageWithContentsOfFile:
[bundlePath stringByAppendingPathComponent:imageName]];
if (image != nil)
break;
}
}

return image;
Expand Down
13 changes: 4 additions & 9 deletions ZincFunctionalTests/ImageLoadingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ - (void)tearDown
- (void) testBundleImageLoading
{
// NOTE: this should be a unit test, but they don't execute in the same
// evironment so I'm adding a little something here
// environment so I'm adding a little something here

NSError* error = nil;

Expand All @@ -52,17 +52,12 @@ - (void) testBundleImageLoading
UIImage* image1 = [UIImage zinc_imageNamed:@"sphalerite.jpg" inBundle:bundle];
NSAssert(image1, @"image1 is nil");
NSLog(@"image1: %@", NSStringFromCGSize(image1.size));
NSAssert(image1.scale == [UIScreen mainScreen].scale, @"image1 scale wrong");

UIImage* image2 = [UIImage zinc_imageNamed:@"sphalerite@2x.jpg" inBundle:bundle];
NSAssert(image2, @"image1 is nil");
NSAssert(image2, @"image2 is nil");
NSLog(@"image2: %@", NSStringFromCGSize(image2.size));

if ([UIScreen mainScreen].scale == 2.0f) {
NSAssert(image1.size.width == image2.size.width, @"retina wrong");

} else {
NSAssert(image1.size.width*2 == image2.size.width, @"non-retina wrong");
}
NSAssert(image2.scale == [UIScreen mainScreen].scale, @"image2 scale wrong");
}


Expand Down

0 comments on commit 6cc303b

Please sign in to comment.