iut 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/bin/iut +2 -0
- data/iut.gemspec +24 -0
- data/lib/iut.rb +17 -0
- data/lib/iut/generator.rb +28 -0
- data/lib/iut/version.rb +4 -0
- data/template/project/iUnitTest/iUnitTest.xcodeproj/project.pbxproj +480 -0
- data/template/project/iUnitTest/iUnitTest/Classes/.do_not_remove_this_directory +0 -0
- data/template/project/iUnitTest/iUnitTest/Tests/.do_not_remove_this_directory +0 -0
- data/template/project/iUnitTest/iUnitTest/en.lproj/InfoPlist.strings +2 -0
- data/template/project/iUnitTest/iUnitTest/iUnitTest-Info.plist +44 -0
- data/template/project/iUnitTest/iUnitTest/iUnitTest-Prefix.pch +14 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/Default.png +0 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/IUTAppDelegate.h +20 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/IUTAppDelegate.m +38 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/IUTDetailView.xib +184 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/IUTMainWindow.xib +732 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/IUTTestView.xib +432 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/Settings.bundle/Japanese.lproj/Root.strings +0 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/Settings.bundle/Root.plist +39 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/Settings.bundle/en.lproj/Root.strings +0 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/AppAgent.h +33 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/AppAgent.m +135 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/AppAgentHelper.h +63 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UINavigationBarBasedTest.h +25 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UINavigationBarBasedTest.m +49 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITabBarAndNavigationBarBasedTest.h +23 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITabBarAndNavigationBarBasedTest.m +42 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITabBarBasedTest.h +25 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITabBarBasedTest.m +50 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITableViewBasedTest.h +23 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITableViewBasedTest.m +57 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITableViewControllerTest.h +22 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITableViewControllerTest.m +44 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UIViewBasedTest.h +21 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UIViewBasedTest.m +52 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UIViewControllerTest.h +63 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UIViewControllerTest.m +162 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/GTMSenTestCase.h +17 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/GTMSenTestCase.m +15 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTAssertion.h +135 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTAssertion.m +216 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTAssertionInfo.h +60 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTAssertionInfo.m +104 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTDetailViewController.h +24 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTDetailViewController.m +81 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTLog.h +14 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTPreference.h +34 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTPreference.m +125 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTResultTableViewCell.h +27 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTResultTableViewCell.m +83 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTResultTableViewController.h +26 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTResultTableViewController.m +193 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTest.h +74 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTest.m +127 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTestRunner.h +66 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTestRunner.m +449 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTestRunnerViewController.h +59 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTestRunnerViewController.m +163 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/NSExceptionExtension.h +21 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/NSExceptionExtension.m +52 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/SenTestAssertion.h +82 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/SourceCodeOpener.h +65 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/SourceCodeOpener.m +176 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/UITableViewControllerTestHelper.h +35 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/isd_logo_60x40.png +0 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/isd_logo_60x40_w.png +0 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/iunittest_icon.png +0 -0
- data/template/project/iUnitTest/iUnitTest/main.m +18 -0
- data/template/project/iUnitTest/script/sync_source.rb +27 -0
- metadata +119 -0
@@ -0,0 +1,104 @@
|
|
1
|
+
//
|
2
|
+
// AssertionInfo.m
|
3
|
+
// iUnitTest
|
4
|
+
//
|
5
|
+
// Created by Katsuyoshi Ito on 09/01/16.
|
6
|
+
// Copyright 2009 ITO SOFT DESIGN Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "IUTAssertionInfo.h"
|
10
|
+
|
11
|
+
|
12
|
+
@implementation IUTAssertionInfo
|
13
|
+
|
14
|
+
@synthesize className, methodName, message, filePath, line;
|
15
|
+
@synthesize expected, actual, delta;
|
16
|
+
@synthesize negativeCase;
|
17
|
+
|
18
|
+
|
19
|
+
+ (id)assertionInfoWithClass:(Class)klass selector:(SEL)selector message:(NSString *)message filePath:(NSString *)path line:(NSInteger)line
|
20
|
+
{
|
21
|
+
return [[[self alloc] initWithWithClass:klass selector:selector message:message filePath:path line:line] autorelease];
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
- (id)initWithWithClass:(Class)klass selector:(SEL)aSelector message:(NSString *)aMessage filePath:(NSString *)path line:(NSInteger)aLine
|
26
|
+
{
|
27
|
+
self = [super init];
|
28
|
+
if (self) {
|
29
|
+
className = [NSStringFromClass(klass) retain];
|
30
|
+
methodName = [NSStringFromSelector(aSelector) retain];
|
31
|
+
message = [aMessage retain];
|
32
|
+
filePath = [path retain];
|
33
|
+
line = aLine;
|
34
|
+
}
|
35
|
+
return self;
|
36
|
+
}
|
37
|
+
|
38
|
+
|
39
|
+
- (NSString *)fileName
|
40
|
+
{
|
41
|
+
if (filePath) {
|
42
|
+
return [filePath lastPathComponent];
|
43
|
+
}
|
44
|
+
return nil;
|
45
|
+
}
|
46
|
+
|
47
|
+
- (NSString *)message
|
48
|
+
{
|
49
|
+
if (message) {
|
50
|
+
return message;
|
51
|
+
} else {
|
52
|
+
if (self.delta) {
|
53
|
+
if (self.negativeCase) {
|
54
|
+
return [NSString stringWithFormat:@"expected:not %@ but was:%@ delta:%@", self.expected, self.actual, self.delta];
|
55
|
+
} else {
|
56
|
+
return [NSString stringWithFormat:@"expected:%@ but was:%@ delta:%@", self.expected, self.actual, self.delta];
|
57
|
+
}
|
58
|
+
} else {
|
59
|
+
if (self.negativeCase) {
|
60
|
+
return [NSString stringWithFormat:@"expected:not %@ but was:%@", self.expected, self.actual];
|
61
|
+
} else {
|
62
|
+
return [NSString stringWithFormat:@"expected:%@ but was:%@", self.expected, self.actual];
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
- (NSString *)reason
|
69
|
+
{
|
70
|
+
if (self.line > 0) {
|
71
|
+
return [NSString stringWithFormat:@"%@:%d\n-[%@ %@]\n%@", self.fileName, self.line, self.className, self.methodName, self.message];
|
72
|
+
} else {
|
73
|
+
return [NSString stringWithFormat:@"maybe %@\n-[%@ %@]\n%@", self.fileName, self.className, self.methodName, self.message];
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
- (void)dealloc
|
78
|
+
{
|
79
|
+
[className release];
|
80
|
+
[methodName release];
|
81
|
+
[message release];
|
82
|
+
[filePath release];
|
83
|
+
[expected release];
|
84
|
+
[actual release];
|
85
|
+
[delta release];
|
86
|
+
[super dealloc];
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
@end
|
91
|
+
|
92
|
+
|
93
|
+
#if TARGET_IPHONE_SIMULATOR
|
94
|
+
|
95
|
+
@implementation SourceCodeOpener(IUTAssertionInfo)
|
96
|
+
|
97
|
+
- (void)open:(IUTAssertionInfo *)info
|
98
|
+
{
|
99
|
+
[self open:info.filePath line:info.line];
|
100
|
+
}
|
101
|
+
|
102
|
+
@end
|
103
|
+
|
104
|
+
#endif
|
@@ -0,0 +1,24 @@
|
|
1
|
+
//
|
2
|
+
// IUTDetailViewController.h
|
3
|
+
// iUnitTest
|
4
|
+
//
|
5
|
+
// Created by Katsuyoshi Ito on 09/01/22.
|
6
|
+
// Copyright 2009 ITO SOFT DESIGN Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import <UIKit/UIKit.h>
|
10
|
+
|
11
|
+
|
12
|
+
@interface IUTDetailViewController : UIViewController {
|
13
|
+
|
14
|
+
IBOutlet UITextView *textView;
|
15
|
+
|
16
|
+
NSException *exception;
|
17
|
+
|
18
|
+
}
|
19
|
+
|
20
|
+
@property (retain) IBOutlet UITextView *textView;
|
21
|
+
|
22
|
+
@property (retain) NSException *exception;
|
23
|
+
|
24
|
+
@end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
//
|
2
|
+
// IUTDetailViewController.m
|
3
|
+
// iUnitTest
|
4
|
+
//
|
5
|
+
// Created by Katsuyoshi Ito on 09/01/22.
|
6
|
+
// Copyright 2009 ITO SOFT DESIGN Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "IUTDetailViewController.h"
|
10
|
+
#import "IUTAssertion.h"
|
11
|
+
#import "IUTTestRunner.h"
|
12
|
+
#import "NSExceptionExtension.h"
|
13
|
+
|
14
|
+
|
15
|
+
@implementation IUTDetailViewController
|
16
|
+
|
17
|
+
@synthesize textView, exception;
|
18
|
+
|
19
|
+
/*
|
20
|
+
// The designated initializer. Override to perform setup that is required before the view is loaded.
|
21
|
+
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
22
|
+
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
|
23
|
+
// Custom initialization
|
24
|
+
}
|
25
|
+
return self;
|
26
|
+
}
|
27
|
+
*/
|
28
|
+
|
29
|
+
/*
|
30
|
+
// Implement loadView to create a view hierarchy programmatically, without using a nib.
|
31
|
+
- (void)loadView {
|
32
|
+
}
|
33
|
+
*/
|
34
|
+
|
35
|
+
/*
|
36
|
+
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
|
37
|
+
- (void)viewDidLoad {
|
38
|
+
[super viewDidLoad];
|
39
|
+
}
|
40
|
+
*/
|
41
|
+
|
42
|
+
/*
|
43
|
+
// Override to allow orientations other than the default portrait orientation.
|
44
|
+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
45
|
+
// Return YES for supported orientations
|
46
|
+
return (interfaceOrientation == UIInterfaceOrientationPortrait);
|
47
|
+
}
|
48
|
+
*/
|
49
|
+
|
50
|
+
- (void)didReceiveMemoryWarning {
|
51
|
+
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
|
52
|
+
// Release anything that's not essential, such as cached data
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
- (void)dealloc {
|
57
|
+
[exception release];
|
58
|
+
[textView release];
|
59
|
+
[super dealloc];
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
- (void)setException:(NSException *)anException
|
64
|
+
{
|
65
|
+
if (exception != anException) {
|
66
|
+
[exception release];
|
67
|
+
exception = [anException retain];
|
68
|
+
|
69
|
+
IUTAssertionInfo *info = exception.assertionInfo;
|
70
|
+
if (info) {
|
71
|
+
self.view.backgroundColor = ([exception.name isEqualToString:IUTAssertionExceptionName]) ? [IUTTestRunner failureColor] : [IUTTestRunner errorColor];
|
72
|
+
self.textView.text = info.reason;
|
73
|
+
} else {
|
74
|
+
self.view.backgroundColor = [IUTTestRunner errorColor];
|
75
|
+
self.textView.text = exception.reason;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
@end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/*
|
2
|
+
* IUTLog.h
|
3
|
+
* iUnitTest
|
4
|
+
*
|
5
|
+
* Created by Katsuyoshi Ito on 09/02/05.
|
6
|
+
* Copyright 2009 ITO SOFT DESIGN Inc. All rights reserved.
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
#if TARGET_IPHONE_SIMULATOR
|
11
|
+
#define IUTLog(format, ...) NSLog(format, ##__VA_ARGS__)
|
12
|
+
#else
|
13
|
+
#define IUTLog(format, ...)
|
14
|
+
#endif
|
@@ -0,0 +1,34 @@
|
|
1
|
+
//
|
2
|
+
// IUTPreference.h
|
3
|
+
// iUnitTestTest
|
4
|
+
//
|
5
|
+
// Created by Katsuyoshi Ito on 09/02/26.
|
6
|
+
// Copyright 2009 ITO SOFT DESIGN Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import <Foundation/Foundation.h>
|
10
|
+
|
11
|
+
|
12
|
+
@interface IUTPreference : NSObject {
|
13
|
+
NSUserDefaults *userDefaults;
|
14
|
+
NSMutableDictionary *passedTests;
|
15
|
+
}
|
16
|
+
|
17
|
+
+ (id)sharedPreference;
|
18
|
+
|
19
|
+
@property (retain, readonly) NSUserDefaults *userDefaults;
|
20
|
+
|
21
|
+
@property (readonly) BOOL isAutoRun;
|
22
|
+
@property (readonly) BOOL isRunFailuresOnly;
|
23
|
+
|
24
|
+
@property (retain, readonly) NSMutableDictionary *passedTests;
|
25
|
+
|
26
|
+
@property (readonly) BOOL canClear;
|
27
|
+
|
28
|
+
- (void)clearPassedTests;
|
29
|
+
- (void)addPassedTest:(NSString *)className methodName:(NSString *)methodName;
|
30
|
+
- (BOOL)needsTest:(NSString *)className methodName:(NSString *)methodName;
|
31
|
+
|
32
|
+
- (void)synchronize;
|
33
|
+
|
34
|
+
@end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
//
|
2
|
+
// IUTPreference.m
|
3
|
+
// iUnitTestTest
|
4
|
+
//
|
5
|
+
// Created by Katsuyoshi Ito on 09/02/26.
|
6
|
+
// Copyright 2009 ITO SOFT DESIGN Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "IUTPreference.h"
|
10
|
+
#import "IUTTest.h"
|
11
|
+
|
12
|
+
#define AUTO_RUN_KEY @"AUTO_RUN"
|
13
|
+
#define RUN_FAILURES_ONLY_KEY @"RUN_FAILURES_ONLY"
|
14
|
+
#define PASSED_TESTS_KEY @"PASSED_TESTS"
|
15
|
+
|
16
|
+
|
17
|
+
@implementation IUTPreference
|
18
|
+
|
19
|
+
|
20
|
+
+ (id)sharedPreference
|
21
|
+
{
|
22
|
+
static id preference = nil;
|
23
|
+
if (preference == nil) {
|
24
|
+
preference = [self new];
|
25
|
+
}
|
26
|
+
return preference;
|
27
|
+
}
|
28
|
+
|
29
|
+
- (id)init
|
30
|
+
{
|
31
|
+
self = [super init];
|
32
|
+
if (self) {
|
33
|
+
NSDictionary *defaults = [NSDictionary dictionaryWithObjectsAndKeys:
|
34
|
+
[NSNumber numberWithBool:YES], AUTO_RUN_KEY,
|
35
|
+
[NSNumber numberWithBool:YES], RUN_FAILURES_ONLY_KEY,
|
36
|
+
nil];
|
37
|
+
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
|
38
|
+
}
|
39
|
+
return self;
|
40
|
+
}
|
41
|
+
|
42
|
+
- (void)dealloc
|
43
|
+
{
|
44
|
+
[self synchronize];
|
45
|
+
[passedTests release];
|
46
|
+
[userDefaults release];
|
47
|
+
[super dealloc];
|
48
|
+
}
|
49
|
+
|
50
|
+
- (NSUserDefaults *)userDefaults
|
51
|
+
{
|
52
|
+
if (userDefaults == nil) {
|
53
|
+
userDefaults = [NSUserDefaults standardUserDefaults];
|
54
|
+
}
|
55
|
+
return userDefaults;
|
56
|
+
}
|
57
|
+
|
58
|
+
|
59
|
+
- (BOOL)isAutoRun
|
60
|
+
{
|
61
|
+
return [self.userDefaults boolForKey:AUTO_RUN_KEY];
|
62
|
+
}
|
63
|
+
|
64
|
+
- (BOOL)isRunFailuresOnly
|
65
|
+
{
|
66
|
+
return [self.userDefaults boolForKey:RUN_FAILURES_ONLY_KEY];
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
- (NSMutableDictionary *)passedTests
|
72
|
+
{
|
73
|
+
if (passedTests == nil) {
|
74
|
+
passedTests = [[self.userDefaults dictionaryForKey:PASSED_TESTS_KEY] mutableCopy];
|
75
|
+
if (passedTests == nil) {
|
76
|
+
passedTests = [NSMutableDictionary new];
|
77
|
+
}
|
78
|
+
}
|
79
|
+
return passedTests;
|
80
|
+
}
|
81
|
+
|
82
|
+
- (BOOL)canClear
|
83
|
+
{
|
84
|
+
return [passedTests count] && self.isRunFailuresOnly;
|
85
|
+
}
|
86
|
+
|
87
|
+
- (void)clearPassedTests
|
88
|
+
{
|
89
|
+
[self.passedTests removeAllObjects];
|
90
|
+
}
|
91
|
+
|
92
|
+
- (void)addPassedTest:(NSString *)className methodName:(NSString *)methodName
|
93
|
+
{
|
94
|
+
NSMutableArray *methods = [self.passedTests objectForKey:className];
|
95
|
+
if (methods == nil) {
|
96
|
+
methods = [NSMutableArray array];
|
97
|
+
[self.passedTests setObject:methods forKey:className];
|
98
|
+
}
|
99
|
+
if (![methods containsObject:methodName]) {
|
100
|
+
[methods addObject:methodName];
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
- (BOOL)needsTest:(NSString *)className methodName:(NSString *)methodName
|
105
|
+
{
|
106
|
+
if (self.isRunFailuresOnly) {
|
107
|
+
if ([NSClassFromString(className) forceTestsAnyway]) {
|
108
|
+
return YES;
|
109
|
+
}
|
110
|
+
NSMutableArray *methods = [self.passedTests objectForKey:className];
|
111
|
+
return (methods && [methods containsObject:methodName]) ? NO : YES;
|
112
|
+
} else {
|
113
|
+
return YES;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
- (void)synchronize
|
120
|
+
{
|
121
|
+
[self.userDefaults setObject:self.passedTests forKey:PASSED_TESTS_KEY];
|
122
|
+
}
|
123
|
+
|
124
|
+
|
125
|
+
@end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
//
|
2
|
+
// IUTResultTableViewCell.h
|
3
|
+
// iUnitTest
|
4
|
+
//
|
5
|
+
// Created by Katsuyoshi Ito on 09/01/17.
|
6
|
+
// Copyright 2009 ITO SOFT DESIGN Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import <UIKit/UIKit.h>
|
10
|
+
#import "IUTAssertionInfo.h"
|
11
|
+
|
12
|
+
|
13
|
+
@interface IUTResultTableViewCell : UITableViewCell {
|
14
|
+
|
15
|
+
UILabel *resultLabel;
|
16
|
+
UIView *bgView;
|
17
|
+
|
18
|
+
NSException *exception;
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
@property (retain, readonly) UILabel *resultLabel;
|
23
|
+
@property (retain, readonly) UIView *bgView;
|
24
|
+
|
25
|
+
@property (retain) NSException *exception;
|
26
|
+
|
27
|
+
@end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
//
|
2
|
+
// IUTResultTableViewCell.m
|
3
|
+
// iUnitTest
|
4
|
+
//
|
5
|
+
// Created by Katsuyoshi Ito on 09/01/17.
|
6
|
+
// Copyright 2009 ITO SOFT DESIGN Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "IUTResultTableViewCell.h"
|
10
|
+
#import "IUTAssertion.h"
|
11
|
+
#import "IUTTestRunner.h"
|
12
|
+
#import "NSExceptionExtension.h"
|
13
|
+
|
14
|
+
|
15
|
+
@implementation IUTResultTableViewCell
|
16
|
+
|
17
|
+
|
18
|
+
@synthesize resultLabel, bgView;
|
19
|
+
@synthesize exception;
|
20
|
+
|
21
|
+
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
22
|
+
{
|
23
|
+
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
24
|
+
if (self) {
|
25
|
+
resultLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
26
|
+
resultLabel.font = [UIFont fontWithName:resultLabel.font.fontName size:14];
|
27
|
+
resultLabel.numberOfLines = 0;
|
28
|
+
[self addSubview:resultLabel];
|
29
|
+
|
30
|
+
bgView = [UIView new];
|
31
|
+
[self addSubview:bgView];
|
32
|
+
[self sendSubviewToBack:bgView];
|
33
|
+
|
34
|
+
}
|
35
|
+
return self;
|
36
|
+
}
|
37
|
+
|
38
|
+
- (void)setException:(NSException *)anException
|
39
|
+
{
|
40
|
+
if (exception != anException) {
|
41
|
+
[exception release];
|
42
|
+
exception = [anException retain];
|
43
|
+
|
44
|
+
IUTAssertionInfo *info = exception.assertionInfo;
|
45
|
+
if (info) {
|
46
|
+
self.resultLabel.backgroundColor = [exception color];
|
47
|
+
self.resultLabel.text = info.reason;
|
48
|
+
} else {
|
49
|
+
self.resultLabel.backgroundColor = [IUTTestRunner errorColor];
|
50
|
+
self.resultLabel.text = exception.reason;
|
51
|
+
}
|
52
|
+
self.bgView.backgroundColor = self.resultLabel.backgroundColor;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
57
|
+
|
58
|
+
[super setSelected:selected animated:animated];
|
59
|
+
self.resultLabel.textColor = (selected) ? [UIColor whiteColor] : [UIColor blackColor];
|
60
|
+
}
|
61
|
+
|
62
|
+
- (void)layoutSubviews {
|
63
|
+
[super layoutSubviews];
|
64
|
+
|
65
|
+
CGRect rect = self.bounds;
|
66
|
+
rect.size.height -= 1;
|
67
|
+
bgView.frame = rect;
|
68
|
+
|
69
|
+
CGRect baseRect = CGRectInset(self.contentView.bounds, 10, 10);
|
70
|
+
rect = baseRect;
|
71
|
+
|
72
|
+
resultLabel.frame = rect;
|
73
|
+
}
|
74
|
+
|
75
|
+
- (void)dealloc {
|
76
|
+
[exception release];
|
77
|
+
[resultLabel release];
|
78
|
+
[bgView release];
|
79
|
+
[super dealloc];
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
@end
|