Fix some best app icon finding issues

In some cases the algorithm didn't find any icon, even if they are there
This commit is contained in:
Andreas Linde
2014-07-08 21:03:26 +02:00
parent 0181e8c724
commit 53edf21c5d
4 changed files with 40 additions and 26 deletions

View File

@@ -93,8 +93,9 @@
- (void)testValidAppIconFilename {
NSString *resultString = nil;
NSBundle *mockBundle = mock([NSBundle class]);
NSString *validIconPath = [[NSBundle bundleForClass:self.class] pathForResource:@"AppIcon" ofType:@"png"];
NSString *validIconPath2x = [[NSBundle bundleForClass:self.class] pathForResource:@"AppIcon@2x" ofType:@"png"];
NSBundle *resourceBundle = [NSBundle bundleForClass:self.class];
NSString *validIconPath = @"AppIcon";
NSString *validIconPath2x = @"AppIcon@2x";
// No valid icons defined at all
[given([mockBundle objectForInfoDictionaryKey:@"CFBundleIconFiles"]) willReturn:nil];
@@ -102,7 +103,7 @@
[given([mockBundle objectForInfoDictionaryKey:@"CFBundleIcons~ipad"]) willReturn:nil];
[given([mockBundle objectForInfoDictionaryKey:@"CFBundleIconFile"]) willReturn:@"invalidFilename.png"];
resultString = bit_validAppIconFilename(mockBundle);
resultString = bit_validAppIconFilename(mockBundle, resourceBundle);
assertThat(resultString, nilValue());
// CFBundleIconFiles contains valid filenames
@@ -111,7 +112,7 @@
[given([mockBundle objectForInfoDictionaryKey:@"CFBundleIcons~ipad"]) willReturn:nil];
[given([mockBundle objectForInfoDictionaryKey:@"CFBundleIconFile"]) willReturn:nil];
resultString = bit_validAppIconFilename(mockBundle);
resultString = bit_validAppIconFilename(mockBundle, resourceBundle);
assertThat(resultString, notNilValue());
// CFBundleIcons contains valid dictionary filenames
@@ -126,7 +127,7 @@
[given([mockBundle objectForInfoDictionaryKey:@"CFBundleIcons~ipad"]) willReturn:@{@"CFBundlePrimaryIcon":@{@"CFBundleIconFiles":@[validIconPath, validIconPath2x]}}];
[given([mockBundle objectForInfoDictionaryKey:@"CFBundleIconFile"]) willReturn:nil];
resultString = bit_validAppIconFilename(mockBundle);
resultString = bit_validAppIconFilename(mockBundle, resourceBundle);
assertThat(resultString, notNilValue());
// CFBundleIcons contains valid filenames
@@ -135,7 +136,7 @@
[given([mockBundle objectForInfoDictionaryKey:@"CFBundleIcons~ipad"]) willReturn:nil];
[given([mockBundle objectForInfoDictionaryKey:@"CFBundleIconFile"]) willReturn:nil];
resultString = bit_validAppIconFilename(mockBundle);
resultString = bit_validAppIconFilename(mockBundle, resourceBundle);
assertThat(resultString, notNilValue());
// CFBundleIcon contains valid filename
@@ -144,7 +145,7 @@
[given([mockBundle objectForInfoDictionaryKey:@"CFBundleIcons~ipad"]) willReturn:nil];
[given([mockBundle objectForInfoDictionaryKey:@"CFBundleIconFile"]) willReturn:validIconPath];
resultString = bit_validAppIconFilename(mockBundle);
resultString = bit_validAppIconFilename(mockBundle, resourceBundle);
assertThat(resultString, notNilValue());
}