diff options
author | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2011-11-29 21:00:23 +0000 |
---|---|---|
committer | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2011-11-29 21:00:23 +0000 |
commit | c571385c00031d740b67317cb677cf193300f614 (patch) | |
tree | c6341b44aca37ddf037354f52ae81350352c8a19 /iPhone | |
parent | 5b52a35992f6bbd427eca4d419721e5354b0262d (diff) |
[Author: thomasvl]
Move a bunch of tests over onto the GTM test base class.
Fetch some test images from the bundle the test is compiled into instead
of assuming main app.
Change the default iOS logging directory to just be the documents directory
since it should work for all iOS versions.
Add initial support for using SenTestingKit instead of our custom version
to allow the Xcode 4 UI for unittesting.
Add a target for using SenTestingKit.
Add a shell app for the TEST_HOST for SenTestingKit usage (since there are
UI tests, we need to use a real app and not the octest binary).
R=dmaclach
DELTA=517 (482 added, 9 deleted, 26 changed)
Diffstat (limited to 'iPhone')
-rw-r--r-- | iPhone/GTMUIImage+ResizeTest.m | 30 | ||||
-rw-r--r-- | iPhone/GTMUIView+SubtreeDescriptionTest.m | 4 |
2 files changed, 18 insertions, 16 deletions
diff --git a/iPhone/GTMUIImage+ResizeTest.m b/iPhone/GTMUIImage+ResizeTest.m index 8318104..458daa7 100644 --- a/iPhone/GTMUIImage+ResizeTest.m +++ b/iPhone/GTMUIImage+ResizeTest.m @@ -16,8 +16,8 @@ // the License. // -#import "GTMNSObject+UnitTesting.h" #import "GTMSenTestCase.h" +#import "GTMNSObject+UnitTesting.h" #import "GTMUIImage+Resize.h" #define GTMUIImageResizeAssertImageEqual(imageObject, imageSuffix) \ @@ -25,11 +25,19 @@ @"GTMUIImage+Resize_" imageSuffix,\ @"Resized image mismatched.") -@interface GTMUIImage_ResizeTest : SenTestCase +@interface GTMUIImage_ResizeTest : GTMTestCase +- (UIImage *)testImageNamed:(NSString *)imageName; @end @implementation GTMUIImage_ResizeTest +- (UIImage *)testImageNamed:(NSString *)imageName { + NSBundle *myBundle = [NSBundle bundleForClass:[self class]]; + NSString *imagePath = [myBundle pathForResource:imageName ofType:@"png"]; + UIImage *result = [UIImage imageWithContentsOfFile:imagePath]; + return result; +} + - (void)testNilImage { UIImage *image = [[UIImage alloc] init]; UIImage *actual = [image gtm_imageByResizingToSize:CGSizeMake(100, 100) @@ -61,8 +69,7 @@ - (void)testImageByResizingWithoutPreservingAspectRatio { UIImage *actual = nil; // Square image. - UIImage *originalImage - = [UIImage imageNamed:@"GTMUIImage+Resize_100x100.png"]; + UIImage *originalImage = [self testImageNamed:@"GTMUIImage+Resize_100x100"]; STAssertNotNil(originalImage, @"Unable to read image."); // Resize with same aspect ratio. @@ -100,8 +107,7 @@ - (void)testImageByResizingPreservingAspectRatioWithoutClip { UIImage *actual = nil; - UIImage *landscapeImage = - [UIImage imageNamed:@"GTMUIImage+Resize_100x50.png"]; + UIImage *landscapeImage = [self testImageNamed:@"GTMUIImage+Resize_100x50"]; STAssertNotNil(landscapeImage, @"Unable to read image."); // Landscape resize to 50x50, but clipped to 50x25. @@ -142,8 +148,7 @@ GTMUIImageResizeAssertImageEqual(actual, @"100x50_to_40x60_noclip"); // Portrait Image - UIImage *portraitImage = - [UIImage imageNamed:@"GTMUIImage+Resize_50x100.png"]; + UIImage *portraitImage = [self testImageNamed:@"GTMUIImage+Resize_50x100"]; // Portrait resize to 50x50, but clipped to 25x50. CGSize expected25x50 = CGSizeMake(25, 50); @@ -181,8 +186,7 @@ - (void)testImageByResizingPreservingAspectRatioWithClip { UIImage *actual = nil; - UIImage *landscapeImage = - [UIImage imageNamed:@"GTMUIImage+Resize_100x50.png"]; + UIImage *landscapeImage = [self testImageNamed:@"GTMUIImage+Resize_100x50"]; STAssertNotNil(landscapeImage, @"Unable to read image."); // Landscape resize to 50x50 @@ -219,8 +223,7 @@ GTMUIImageResizeAssertImageEqual(actual, @"100x50_to_40x60_clip"); // Portrait Image. - UIImage *portraitImage = - [UIImage imageNamed:@"GTMUIImage+Resize_50x100.png"]; + UIImage *portraitImage = [self testImageNamed:@"GTMUIImage+Resize_50x100"]; // Portrait resize to 50x50 actual = [portraitImage gtm_imageByResizingToSize:size50x50 @@ -255,8 +258,7 @@ - (void)testImageByRotating { UIImage *actual = nil; - UIImage *landscapeImage = - [UIImage imageNamed:@"GTMUIImage+Resize_100x50.png"]; + UIImage *landscapeImage = [self testImageNamed:@"GTMUIImage+Resize_100x50"]; STAssertNotNil(landscapeImage, @"Unable to read image."); // Rotate 90 degrees. diff --git a/iPhone/GTMUIView+SubtreeDescriptionTest.m b/iPhone/GTMUIView+SubtreeDescriptionTest.m index 4459952..db4b2fc 100644 --- a/iPhone/GTMUIView+SubtreeDescriptionTest.m +++ b/iPhone/GTMUIView+SubtreeDescriptionTest.m @@ -22,7 +22,7 @@ #if !NDEBUG -@interface GTMUIView_SubtreeDescriptionTest : SenTestCase +@interface GTMUIView_SubtreeDescriptionTest : GTMTestCase @end @implementation GTMUIView_SubtreeDescriptionTest @@ -125,7 +125,7 @@ } @end -@interface GTMUIView_SubtreeSubClassDescriptionTest : SenTestCase +@interface GTMUIView_SubtreeSubClassDescriptionTest : GTMTestCase @end @implementation GTMUIView_SubtreeSubClassDescriptionTest |