Permalink
Browse files

Fixing view exception assert crash if image was nil.

  • Loading branch information...
1 parent 25dedb1 commit de2cbbd72cb7d109544bc63ccdbdb38996de6f33 @gabriel gabriel committed Jun 29, 2012
Showing with 8 additions and 17 deletions.
  1. +3 −12 Classes/GHViewTestCase.m
  2. +4 −4 Project-iOS/GHUnitIOS.xcodeproj/project.pbxproj
  3. +1 −1 XcodeConfig/Shared.xcconfig
View
@@ -35,15 +35,6 @@
unsigned char r, g, b, a;
} GHPixel;
-@interface GHViewTestCase ()
-+ (NSString *)imagesDirectory;
-+ (NSString *)pathForFilename:(NSString *)filename;
-+ (void)createImagesDirectory;
-+ (UIImage *)imageWithView:(UIView *)view;
-+ (UIImage *)readImageWithFilename:(NSString *)name;
-+ (BOOL)compareImage:(UIImage *)image withRenderedImage:(UIImage *)renderedImage;
-@end
-
@implementation GHViewTestCase
+ (NSString *)imagesDirectory {
@@ -82,7 +73,7 @@ + (void)saveToDocumentsWithImage:(UIImage *)image filename:(NSString *)filename
}
+ (UIImage *)readImageWithFilename:(NSString *)filename {
- NSString* filePath = [self pathForFilename:filename];
+ NSString *filePath = [self pathForFilename:filename];
GHUDebug(@"Trying to load image at path %@", filePath);
// First look in the documents directory for the image
UIImage *image = [UIImage imageWithContentsOfFile:filePath];
@@ -240,8 +231,8 @@ - (void)verifyView:(UIView *)view filename:(NSString *)filename lineNumber:(int)
[[NSException exceptionWithName:@"GHViewUnavailableException" reason:@"No image saved for view" userInfo:exceptionDictionary] raise];
} else if (![[self class] compareImage:originalViewImage withRenderedImage:newViewImage]) {
UIImage *diffImage = [[self class] diffWithImage:originalViewImage renderedImage:newViewImage];
- [exceptionDictionary setObject:diffImage forKey:@"DiffImage"];
- [exceptionDictionary setObject:originalViewImage forKey:@"SavedImage"];
+ if (diffImage) [exceptionDictionary setObject:diffImage forKey:@"DiffImage"];
+ if (originalViewImage) [exceptionDictionary setObject:originalViewImage forKey:@"SavedImage"];
[[NSException exceptionWithName:@"GHViewChangeException" reason:@"View has changed" userInfo:exceptionDictionary] raise];
}
imageVerifyCount_++;
@@ -381,14 +381,14 @@
0041C62013BA7C9A0015FC22 /* Classes */ = {
isa = PBXGroup;
children = (
- 4228630F1458BC1200BF3ED2 /* GHViewTestCase.h */,
- 422863101458BC1200BF3ED2 /* GHViewTestCase.m */,
- 0041C62113BA7C9A0015FC22 /* GHAsyncTestCase.h */,
- 0041C62213BA7C9A0015FC22 /* GHAsyncTestCase.m */,
0041C62313BA7C9A0015FC22 /* GHTest */,
0041C63813BA7C9A0015FC22 /* GHTestCase.h */,
0041C63913BA7C9A0015FC22 /* GHTestCase.m */,
0041C63A13BA7C9A0015FC22 /* GHTestMacros.h */,
+ 4228630F1458BC1200BF3ED2 /* GHViewTestCase.h */,
+ 422863101458BC1200BF3ED2 /* GHViewTestCase.m */,
+ 0041C62113BA7C9A0015FC22 /* GHAsyncTestCase.h */,
+ 0041C62213BA7C9A0015FC22 /* GHAsyncTestCase.m */,
0041C63B13BA7C9A0015FC22 /* GHUnit.h */,
0041C63C13BA7C9A0015FC22 /* Mock */,
0041C64513BA7C9A0015FC22 /* SharedUI */,
@@ -1,4 +1,4 @@
-GHUNIT_VERSION = 0.5.1
+GHUNIT_VERSION = 0.5.3
GHUNIT_GENERAL_OTHER_CFLAGS = -Wdiv-by-zero -Wbad-function-cast -Wnested-externs -Wold-style-definition

0 comments on commit de2cbbd

Please sign in to comment.