Skip to content

Commit

Permalink
when 4x textures is requested, but not availble, 2x is now tried befo…
Browse files Browse the repository at this point in the history
…re 1x.
  • Loading branch information
PrimaryFeather committed Mar 22, 2012
1 parent 91c2e8c commit fe7a6e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sparrow/src/Classes/SPUtils.m
Expand Up @@ -67,8 +67,8 @@ + (NSString *)absolutePathToFile:(NSString *)path withScaleFactor:(float)factor
return absolutePathWithIdiom;
else if ([SPUtils fileExistsAtPath:absolutePath])
return absolutePath;
else if (factor != 1.0f)
return [SPUtils absolutePathToFile:originalPath withScaleFactor:1.0f idiom:idiom];
else if (factor >= 2.0f)
return [SPUtils absolutePathToFile:originalPath withScaleFactor:factor/2.0f idiom:idiom];
else
return nil;
}
Expand Down
9 changes: 9 additions & 0 deletions sparrow/src/UnitTests/SPUtilsTest.m
Expand Up @@ -126,6 +126,15 @@ - (void)testGetSdTextureFallback
STAssertTrue([absolutePath hasSuffix:filename], @"1x fallback resource not found");
}

- (void)testGetHdTextureFallback
{
NSString *filename = @"image_only_hd.png";

// @4x is not available -> @2x should be returned as a fallback
NSString *absolutePath = [SPUtils absolutePathToFile:filename withScaleFactor:4.0f];
STAssertEquals(2.0f, [absolutePath contentScaleFactor], @"2x fallback not found");
}

- (void)testOnlyHdTextureAvailable
{
NSString *filename = @"image_only_hd.png";
Expand Down

0 comments on commit fe7a6e1

Please sign in to comment.