Permalink
Browse files

Updating example project, some small tweaks

  • Loading branch information...
1 parent 0745c4b commit da68b11a4aaeb0ee92d245d61c33251e6948e0b9 @johnboiles johnboiles committed Oct 27, 2011
Showing with 1,216 additions and 1,003 deletions.
  1. +0 −3 Classes-iOS/GHUnitIOSTestView.m
  2. +22 −1 Classes/GHViewTestCase.h
  3. +26 −7 Classes/GHViewTestCase.m
  4. +0 −25 Classes/RoboEyesKit.h
  5. +0 −25 Classes/RoboEyesKit.m
  6. BIN Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/GHUnitIOS
  7. +52 −44 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHAsyncTestCase.h
  8. +1 −1 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHTest+JUnitXML.h
  9. +100 −13 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHTest.h
  10. +50 −43 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHTestCase.h
  11. +23 −12 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHTestGroup.h
  12. +50 −17 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHTestMacros.h
  13. +5 −4 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHTestOperation.h
  14. +77 −18 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHTestRunner.h
  15. +3 −3 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHTestSuite.h
  16. +58 −9 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHTestViewModel.h
  17. +14 −7 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHTesting.h
  18. +1 −668 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHUnit.h
  19. +3 −0 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSAppDelegate.h
  20. +3 −0 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTableViewDataSource.h
  21. +38 −0 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTestView.h
  22. +6 −2 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSTestViewController.h
  23. +3 −1 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSView.h
  24. +4 −2 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHUnitIOSViewController.h
  25. +57 −0 Examples/MyTestable-iOS/GHUnitIOS.framework/Versions/A/Headers/GHViewTestCase.h
  26. +2 −0 Examples/MyTestable-iOS/Makefile
  27. +59 −7 Examples/MyTestable-iOS/MyTestable.xcodeproj/project.pbxproj
  28. +13 −0 Examples/MyTestable-iOS/MyTestable/iPad/MyTestableViewController_iPad.h
  29. +51 −0 Examples/MyTestable-iOS/MyTestable/iPad/MyTestableViewController_iPad.m
  30. +194 −0 Examples/MyTestable-iOS/MyTestable/iPad/MyTestableViewController_iPad.xib
  31. +13 −0 Examples/MyTestable-iOS/MyTestable/iPhone/MyTestableViewController_iPhone.h
  32. +51 −0 Examples/MyTestable-iOS/MyTestable/iPhone/MyTestableViewController_iPhone.m
  33. +194 −0 Examples/MyTestable-iOS/MyTestable/iPhone/MyTestableViewController_iPhone.xib
  34. +0 −67 Examples/MyTestable-iOS/RunTests_experimental.sh
  35. BIN Examples/MyTestable-iOS/TestImages/MyViewTest-testIPadViewController-0-UIView.png
  36. BIN Examples/MyTestable-iOS/TestImages/MyViewTest-testIPhoneViewController-0-UIView.png
  37. +13 −0 Examples/MyTestable-iOS/Tests/MyViewTest.h
  38. +28 −0 Examples/MyTestable-iOS/Tests/MyViewTest.m
  39. +0 −21 Project-iOS/GHUnitIOS.xcodeproj/project.pbxproj
  40. BIN Resources/checkmark.png
  41. BIN Resources/checkmark@2x.png
  42. 0 Scripts/CombineLibs.sh
  43. +2 −2 Scripts/CopyTestImages.sh
  44. 0 Scripts/RunTests.sh
  45. +0 −1 Scripts/iOSFramework.sh
@@ -48,9 +48,6 @@ - (id)initWithFrame:(CGRect)frame
[approveButton_ setTitle:@"Approve this change" forState:UIControlStateNormal];
[approveButton_ setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
approveButton_.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:18];
- // TODO(johnb): Not getting the image from the framework bundle
- UIImage *image = [UIImage imageNamed:@"checkmark.png"];
- [approveButton_ setImage:image forState:UIControlStateNormal];
[self addSubview:approveButton_];
}
return self;
@@ -3,7 +3,28 @@
// GHUnitIOS
//
// Created by John Boiles on 10/20/11.
-// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+// Copyright (c) 2011. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
//
#import "GHTestCase.h"
@@ -3,7 +3,28 @@
// GHUnitIOS
//
// Created by John Boiles on 10/20/11.
-// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
+// Copyright (c) 2011. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
//
#import "GHViewTestCase.h"
@@ -98,9 +119,6 @@ + (BOOL)compareImage:(UIImage *)image withNewImage:(UIImage *)newImage {
if (imagePixels[j] != newImagePixels[j])
{
NSLog(@"imagePixels[%d]: %x newImagePixels[%d]: %x", j, imagePixels[j], j, newImagePixels[j]);
- NSLog(@"Saving image to orig.png and new.png for debugging");
- [self saveToDocumentsWithImage:image filename:@"orig.png"];
- [self saveToDocumentsWithImage:newImage filename:@"new.png"];
return NO;
}
}
@@ -159,9 +177,6 @@ + (BOOL)compareImage2:(UIImage *)image withNewImage:(UIImage *)newImage {
NSLog(@"Image was different at pixel (%d, %d). Old was (r%d, g%d, b%d), new was (r%d, g%d, b%d)", x, y,
imagePixels[pixelIndex].r, imagePixels[pixelIndex].g, imagePixels[pixelIndex].b,
newImagePixels[pixelIndex].r, newImagePixels[pixelIndex].g, newImagePixels[pixelIndex].b);
- NSLog(@"Saving image to orig.png and new.png for debugging");
- [self saveToDocumentsWithImage:image filename:@"orig.png"];
- [self saveToDocumentsWithImage:newImage filename:@"new.png"];
CGContextRelease(imageContext);
CGContextRelease(newImageContext);
free(imagePixels);
@@ -191,6 +206,10 @@ - (BOOL)isCLIDisabled {
}
- (void)verifyView:(UIView *)view inFilename:(NSString *)filename atLineNumber:(int)lineNumber {
+ // Fail if the view is nil
+ if (!view) [[NSException ghu_failureInFile:filename atLine:lineNumber withDescription:@"View cannot be nil in GHVerifyView"] raise];
+ // Fail if the view has CGSizeZero
+ if (CGSizeEqualToSize(view.frame.size, CGSizeZero)) [[NSException ghu_failureInFile:filename atLine:lineNumber withDescription:@"View must have a nonzero size in GHVerifyView"] raise];
// View testing file names have the format [test class name]-[test selector name]-[# of verify in selector]-[view class name]
NSString *imageFilename = [NSString stringWithFormat:@"%@-%@-%d-%@.png", NSStringFromClass([self class]), NSStringFromSelector(currentSelector_), imageVerifyCount_, NSStringFromClass([view class])];
UIImage *originalViewImage = [[self class] readImageWithFilename:imageFilename];
View
@@ -1,25 +0,0 @@
-//
-// RoboEyesKit.h
-// RoboEyesExample
-//
-// Created by John Boiles on 8/3/11.
-// Copyright 2011 __MyCompanyName__. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-#import <UIKit/UIKit.h>
-#import <QuartzCore/QuartzCore.h>
-
-@interface RoboEyesKit : NSObject
-
-+ (UIImage *)imageWithView:(UIView *)view;
-
-- (void)saveToPhotoAlbumWithImage:(UIImage *)image;
-
-+ (void)saveToDocumentsWithImage:(UIImage *)image name:(NSString *)name;
-
-+ (UIImage *)readImageWithName:(NSString *)name;
-
-+ (BOOL)compareImage:(UIImage *)image withNewImage:(UIImage *)newImage;
-
-@end
View
@@ -1,25 +0,0 @@
-//
-// RoboEyesKit.m
-// RoboEyesExample
-//
-// Created by John Boiles on 8/3/11.
-// Copyright 2011 __MyCompanyName__. All rights reserved.
-//
-
-#import "RoboEyesKit.h"
-
-@implementation RoboEyesKit
-
-- (id)init
-{
- self = [super init];
- if (self) {
- // Initialization code here.
- }
-
- return self;
-}
-
-
-
-@end
@@ -29,12 +29,14 @@
#import "GHTestCase.h"
-// Some default statuses to use; Or define and use your own
+/*!
+ Common wait statuses to use with waitForStatus:timeout:.
+ */
enum {
- kGHUnitWaitStatusUnknown = 0, //!< Unknown wait status
- kGHUnitWaitStatusSuccess, //!< Wait status success
- kGHUnitWaitStatusFailure, //!< Wait status failure
- kGHUnitWaitStatusCancelled //!< Wait status cancelled
+ kGHUnitWaitStatusUnknown = 0, // Unknown wait status
+ kGHUnitWaitStatusSuccess, // Wait status success
+ kGHUnitWaitStatusFailure, // Wait status failure
+ kGHUnitWaitStatusCancelled // Wait status cancelled
};
/*!
@@ -45,31 +47,31 @@ enum {
Be sure to call prepare before the asynchronous method (otherwise an exception will raise).
- @code
-
- @interface MyAsyncTest : GHAsyncTestCase { }
- @end
-
- @implementation MyAsyncTest
-
- - (void)testSuccess {
- [self prepare];
-
- // Do asynchronous task here
- [self performSelector:@selector(_succeed) withObject:nil afterDelay:0.1];
-
- [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
- }
-
- - (void)_succeed {
- // Notice the forSelector points to the test above. This is so that
- // stray notifies don't error or falsely succeed other tests.
- // To ignore the check, forSelector can be NULL.
- [self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testSuccess)];
- }
-
- @end
- @endcode
+ @interface MyAsyncTest : GHAsyncTestCase { }
+ @end
+
+ @implementation MyAsyncTest
+
+ - (void)testSuccess {
+ // Prepare for asynchronous call
+ [self prepare];
+
+ // Do asynchronous task here
+ [self performSelector:@selector(_succeed) withObject:nil afterDelay:0.1];
+
+ // Wait for notify
+ [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
+ }
+
+ - (void)_succeed {
+ // Notify the wait. Notice the forSelector points to the test above.
+ // This is so that stray notifies don't error or falsely succeed other tests.
+ // To ignore the check, forSelector can be NULL.
+ [self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testSuccess)];
+ }
+
+ @end
+
*/
@interface GHAsyncTestCase : GHTestCase {
@@ -96,7 +98,8 @@ enum {
/*!
Prepare and specify the selector we will use in notify.
- @param selector
+
+ @param selector Selector
*/
- (void)prepare:(SEL)selector;
@@ -106,48 +109,53 @@ enum {
Be sure to prepare before calling your asynchronous method.
For example,
- @code
- - (void)testFoo {
- [self prepare];
- // Do asynchronous task here
- [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
- }
- @endcode
+ - (void)testFoo {
+ [self prepare];
+
+ // Do asynchronous task here
+
+ [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
+ }
@param status kGHUnitWaitStatusSuccess, kGHUnitWaitStatusFailure or custom status
@param timeout Timeout in seconds
*/
- (void)waitForStatus:(NSInteger)status timeout:(NSTimeInterval)timeout;
/*!
- @deprecated
+ @param status kGHUnitWaitStatusSuccess, kGHUnitWaitStatusFailure or custom status
+ @param timeout Timeout in seconds
+ @deprecated Use waitForTimeout:
*/
- (void)waitFor:(NSInteger)status timeout:(NSTimeInterval)timeout;
/*!
Wait for timeout to occur.
Fails if we did _NOT_ timeout.
- @param timeout
+
+ @param timeout Timeout
*/
- (void)waitForTimeout:(NSTimeInterval)timeout;
/*!
Notify waiting of status for test selector.
+
@param status Status, for example, kGHUnitWaitStatusSuccess
- @param selector If not NULL, then will verify this selector is where we are waiting.
- This prevents stray asynchronous callbacks to fail a later test
+ @param selector If not NULL, then will verify this selector is where we are waiting. This prevents stray asynchronous callbacks to fail a later test.
*/
- (void)notify:(NSInteger)status forSelector:(SEL)selector;
/*!
Notify waiting of status for any selector.
+
@param status Status, for example, kGHUnitWaitStatusSuccess
*/
- (void)notify:(NSInteger)status;
/*!
- Run the run loops for the specified interval.
- @param interval
+ Run the run loops for the specified interval.
+
+ @param interval Interval
@author Adapted from Robert Palmer, pauseForTimeout
*/
- (void)runForInterval:(NSTimeInterval)interval;
@@ -35,7 +35,7 @@
/*!
Return test results in JUnit XML format for external parsing use
- (such as a Continuous Integration system like Hudson)
+ (such as a Continuous Integration system like Jenkins).
*/
- (NSString *)JUnitXML;
Oops, something went wrong.

0 comments on commit da68b11

Please sign in to comment.