aboutsummaryrefslogtreecommitdiff
path: root/UnitTesting
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-09-02 20:30:38 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-09-02 20:30:38 +0000
commit4ee3b1359f5407ad4bb552bcc1c563970d355017 (patch)
tree7a32b511367746f60b003ad9cec7811dbec56d95 /UnitTesting
parenta8ff4e805f875b8d565df63ad1e9fd56e699b3e1 (diff)
[Author: thomasvl]
Add another window to the UILocalizer unittest that puts a bunch of items into boxes, splitters, and scroll views to make sure they are working. Support some NSBox attributes in AppKit+UnitTesting. Update the size to fit code to only special case regular push buttons and not other types of buttons. Update the expectations due to this change. Add a new unittest to test all button styles and sizes. Update how we decided to do vertical or horizontal layout on a width box because left aligning things is visual and doesn't actually align their frames, so instead we do a rect intersection instead. Added in the CompilerSDK on Mac OS builds to the paths searches. Update the comments on how paths are searched to be correct. R=dmaclach,stuartmorgan DELTA=2709 (2643 added, 8 deleted, 58 changed)
Diffstat (limited to 'UnitTesting')
-rw-r--r--UnitTesting/GTMAppKit+UnitTesting.m20
-rw-r--r--UnitTesting/GTMNSObject+UnitTesting.h32
-rw-r--r--UnitTesting/GTMNSObject+UnitTesting.m83
3 files changed, 98 insertions, 37 deletions
diff --git a/UnitTesting/GTMAppKit+UnitTesting.m b/UnitTesting/GTMAppKit+UnitTesting.m
index e5e35e5..d5aa70d 100644
--- a/UnitTesting/GTMAppKit+UnitTesting.m
+++ b/UnitTesting/GTMAppKit+UnitTesting.m
@@ -360,6 +360,26 @@ GTM_METHOD_CHECK(NSObject, gtm_unitTestEncodeState:);
@end
+@implementation NSBox (GTMUnitTestingAdditions)
+
+// Encodes the state of an object in a manner suitable for comparing
+// against a master state file so we can determine whether the
+// object is in a suitable state.
+//
+// Arguments:
+// inCoder - the coder to encode our state into
+- (void)gtm_unitTestEncodeState:(NSCoder*)inCoder {
+ [super gtm_unitTestEncodeState:inCoder];
+
+ [inCoder encodeObject:[self title] forKey:@"BoxTitle"];
+ ENCODE_NSINTEGER(inCoder, [self titlePosition], @"BoxTitlePosition");
+ ENCODE_NSINTEGER(inCoder, [self boxType], @"BoxType");
+ ENCODE_NSINTEGER(inCoder, [self borderType], @"BoxBorderType");
+ // 10.5+ [inCoder encodeBool:[self isTransparent] forKey:@"BoxIsTransparent"];
+}
+
+@end
+
@implementation NSView (GTMUnitTestingAdditions)
// Returns an image containing a representation of the object
diff --git a/UnitTesting/GTMNSObject+UnitTesting.h b/UnitTesting/GTMNSObject+UnitTesting.h
index 37eae5b..4f11cc2 100644
--- a/UnitTesting/GTMNSObject+UnitTesting.h
+++ b/UnitTesting/GTMNSObject+UnitTesting.h
@@ -252,15 +252,20 @@ CGContextRef GTMCreateUnitTestBitmapContextOfSizeWithData(CGSize size,
// Find the path for a image by name in your bundle.
// Searches for the following:
-// "name.arch.OSVersionMajor.OSVersionMinor.OSVersionBugfix.extension"
-// "name.OSVersionMajor.OSVersionMinor.OSVersionBugfix.arch.extension"
-// "name.arch.OSVersionMajor.OSVersionMinor.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.OSVersionBugFix.arch.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.arch.extension"
+// "name.CompilerSDK.OSVersionMajor.arch.extension"
+// "name.CompilerSDK.arch.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.OSVersionBugFix.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.extension"
+// "name.CompilerSDK.OSVersionMajor.extension"
+// "name.CompilerSDK.extension"
+// "name.OSVersionMajor.OSVersionMinor.OSVersionBugFix.arch.extension"
// "name.OSVersionMajor.OSVersionMinor.arch.extension"
-// "name.arch.OSVersionMajor.extension"
// "name.OSVersionMajor.arch.extension"
// "name.arch.extension"
-// "name.OSVersionMajor.OSVersionMinor.OSVersionBugfix.extension"
-// "name.OSVersionMajor.OSVersionMinorextension"
+// "name.OSVersionMajor.OSVersionMinor.OSVersionBugFix.extension"
+// "name.OSVersionMajor.OSVersionMinor.extension"
// "name.OSVersionMajor.extension"
// "name.extension"
// Do not include the extension on your name.
@@ -344,14 +349,19 @@ CGContextRef GTMCreateUnitTestBitmapContextOfSizeWithData(CGSize size,
// Find the path for a state by name in your bundle.
// Searches for:
-// "name.arch.OSVersionMajor.OSVersionMinor.OSVersionBugfix.extension"
-// "name.OSVersionMajor.OSVersionMinor.OSVersionBugfix.arch.extension"
-// "name.arch.OSVersionMajor.OSVersionMinor.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.OSVersionBugFix.arch.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.arch.extension"
+// "name.CompilerSDK.OSVersionMajor.arch.extension"
+// "name.CompilerSDK.arch.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.OSVersionBugFix.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.extension"
+// "name.CompilerSDK.OSVersionMajor.extension"
+// "name.CompilerSDK.extension"
+// "name.OSVersionMajor.OSVersionMinor.OSVersionBugFix.arch.extension"
// "name.OSVersionMajor.OSVersionMinor.arch.extension"
-// "name.arch.OSVersionMajor.extension"
// "name.OSVersionMajor.arch.extension"
// "name.arch.extension"
-// "name.OSVersionMajor.OSVersionMinor.OSVersionBugfix.extension"
+// "name.OSVersionMajor.OSVersionMinor.OSVersionBugFix.extension"
// "name.OSVersionMajor.OSVersionMinor.extension"
// "name.OSVersionMajor.extension"
// "name.extension"
diff --git a/UnitTesting/GTMNSObject+UnitTesting.m b/UnitTesting/GTMNSObject+UnitTesting.m
index cc6a7ea..03a5e6a 100644
--- a/UnitTesting/GTMNSObject+UnitTesting.m
+++ b/UnitTesting/GTMNSObject+UnitTesting.m
@@ -480,18 +480,22 @@ static NSString *gGTMUnitTestSaveToDirectory = nil;
/// Find the path for a file named name.extension in your bundle.
// Searches for the following:
-// "name.extension",
-// "name.arch.extension",
-// "name.arch.OSVersionMajor.extension"
-// "name.arch.OSVersionMajor.OSVersionMinor.extension"
-// "name.arch.OSVersionMajor.OSVersionMinor.OSVersion.bugfix.extension"
-// "name.arch.OSVersionMajor.extension"
-// "name.OSVersionMajor.arch.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.OSVersionBugFix.arch.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.arch.extension"
+// "name.CompilerSDK.OSVersionMajor.arch.extension"
+// "name.CompilerSDK.arch.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.OSVersionBugFix.extension"
+// "name.CompilerSDK.OSVersionMajor.OSVersionMinor.extension"
+// "name.CompilerSDK.OSVersionMajor.extension"
+// "name.CompilerSDK.extension"
+// "name.OSVersionMajor.OSVersionMinor.OSVersionBugFix.arch.extension"
// "name.OSVersionMajor.OSVersionMinor.arch.extension"
-// "name.OSVersionMajor.OSVersionMinor.OSVersion.bugfix.arch.extension"
-// "name.OSVersionMajor.extension"
+// "name.OSVersionMajor.arch.extension"
+// "name.arch.extension"
+// "name.OSVersionMajor.OSVersionMinor.OSVersionBugFix.extension"
// "name.OSVersionMajor.OSVersionMinor.extension"
-// "name.OSVersionMajor.OSVersionMinor.OSVersion.bugfix.extension"
+// "name.OSVersionMajor.extension"
+// "name.extension"
// Do not include the ".extension" extension on your name.
//
// Args:
@@ -519,27 +523,52 @@ static NSString *gGTMUnitTestSaveToDirectory = nil;
systemVersions[1] = [NSString stringWithFormat:@".%d.%d", major, minor];
systemVersions[2] = [NSString stringWithFormat:@".%d", major];
systemVersions[3] = @"";
- NSString *extensions[2];
- extensions[0]
+ // Architecture
+ NSString *architecture[2];
+ architecture[0]
= [NSString stringWithFormat:@".%@",
[GTMSystemVersion runtimeArchitecture]];
- extensions[1] = @"";
+ architecture[1] = @"";
+ // Compiler SDK
+#if GTM_MACOS_SDK
+ // Some times Apple changes how things work based on the SDK built against.
+ NSString *sdks[2];
+# if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
+ sdks[0] = @".10_6_SDK";
+# elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+ sdks[0] = @".10_5_SDK";
+# elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
+ sdks[0] = @".10_4_SDK";
+# elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
+ sdks[0] = @".10_3_SDK";
+# elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2
+ sdks[0] = @".10_2_SDK";
+# elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1
+ sdks[0] = @".10_1_SDK";
+# else
+ sdks[0] = @".10_0_SDK";
+# endif
+ sdks[1] = @"";
+#else // !GTM_MACOS_SDK
+ // iPhone doesn't current support SDK specific images (hopefully it won't
+ // be needed.
+ NSString *sdks[] = { @"" };
+#endif // GTM_MACOS_SDK
- size_t i, j;
// Note that we are searching for the most exact match first.
- for (i = 0;
- !thePath && i < sizeof(extensions) / sizeof(*extensions);
+ for (size_t i = 0;
+ !thePath && i < sizeof(sdks) / sizeof(*sdks);
++i) {
- for (j = 0;
- !thePath && j < sizeof(systemVersions) / sizeof(*systemVersions);
+ for (size_t j = 0;
+ !thePath && j < sizeof(architecture) / sizeof(*architecture);
j++) {
- NSString *fullName = [NSString stringWithFormat:@"%@%@%@",
- name, extensions[i], systemVersions[j]];
- thePath = [myBundle pathForResource:fullName ofType:extension];
- if (thePath) break;
- fullName = [NSString stringWithFormat:@"%@%@%@",
- name, systemVersions[j], extensions[i]];
- thePath = [myBundle pathForResource:fullName ofType:extension];
+ for (size_t k = 0;
+ !thePath && k < sizeof(systemVersions) / sizeof(*systemVersions);
+ k++) {
+ NSString *fullName = [NSString stringWithFormat:@"%@%@%@%@",
+ name, sdks[i], systemVersions[k], architecture[j]];
+ thePath = [myBundle pathForResource:fullName ofType:extension];
+ }
}
}
@@ -553,8 +582,10 @@ static NSString *gGTMUnitTestSaveToDirectory = nil;
SInt32 major, minor, bugFix;
[GTMSystemVersion getMajor:&major minor:&minor bugFix:&bugFix];
+ // We don't include the CompilerSDK in here because it is not something that
+ // that is commonly needed.
NSString *fullName = [NSString stringWithFormat:@"%@.%@.%d.%d.%d",
- name, systemArchitecture, major, minor, bugFix];
+ name, major, minor, bugFix, systemArchitecture];
NSString *basePath = [[self class] gtm_getUnitTestSaveToDirectory];
return [[basePath stringByAppendingPathComponent:fullName]