Skip to content
Browse files

Support for retina view tests

  • Loading branch information...
1 parent 8ed3a76 commit 861b7e5308410ba899cb17621a226d02a37f585e @x2on x2on committed Oct 25, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 Classes/GHViewTestCase.m
View
9 Classes/GHViewTestCase.m
@@ -85,11 +85,14 @@ + (UIImage *)readSavedTestImageWithFilename:(NSString *)filename {
NSString *filePath = [self approvedTestImagePathForFilename:filename];
GHUDebug(@"Trying to load image at path %@", filePath);
// First look in the documents directory for the image
- UIImage *image = [UIImage imageWithContentsOfFile:filePath];
+ UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfFile:filePath] scale:[UIScreen mainScreen].scale];
// Otherwise look in the app bundle
if (image) GHUDebug(@"Found image in documents directory");
if (!image) {
- image = [UIImage imageNamed:filename];
+ NSString* fileName = [[filename lastPathComponent] stringByDeletingPathExtension];
+ NSString* extension = [filename pathExtension];
+ filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:extension];
+ image = [UIImage imageWithData:[NSData dataWithContentsOfFile:filePath] scale:[UIScreen mainScreen].scale];
if (image) GHUDebug(@"Found image in app bundle");
}
return image;
@@ -115,7 +118,7 @@ + (void)clearTestImages {
+ (UIImage *)imageWithView:(UIView *)view {
[view setNeedsDisplay];
- UIGraphicsBeginImageContext(view.frame.size);
+ UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, [[UIScreen mainScreen] scale]);
CALayer *layer = view.layer;
CGContextRef context = UIGraphicsGetCurrentContext();
[layer renderInContext:context];

0 comments on commit 861b7e5

Please sign in to comment.
Something went wrong with that request. Please try again.