aboutsummaryrefslogtreecommitdiff
path: root/AppKit/GTMUILocalizerAndLayoutTweakerTest.m
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-03-09 20:36:55 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-03-09 20:36:55 +0000
commitf736aed5642b3c7f19533653e1ddfd4599f1ee7d (patch)
tree22b044ba2b807e5903853958c2bb9d6de9561751 /AppKit/GTMUILocalizerAndLayoutTweakerTest.m
parent0f6b25f7efe11c2a4102b2d74c5f57ddfab341c1 (diff)
[Author: thomasvl]
Add an api for forcing a NSTextField to a fixed height but what ever width is needed. R=dmaclach DELTA=634 (631 added, 0 deleted, 3 changed)
Diffstat (limited to 'AppKit/GTMUILocalizerAndLayoutTweakerTest.m')
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweakerTest.m57
1 files changed, 57 insertions, 0 deletions
diff --git a/AppKit/GTMUILocalizerAndLayoutTweakerTest.m b/AppKit/GTMUILocalizerAndLayoutTweakerTest.m
index fed8359..d5b111c 100644
--- a/AppKit/GTMUILocalizerAndLayoutTweakerTest.m
+++ b/AppKit/GTMUILocalizerAndLayoutTweakerTest.m
@@ -211,6 +211,63 @@ static NSUInteger gTestPass = 0;
}
}
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+- (void)testSizeToFitFixedHeightTextField {
+ struct {
+ const char *name;
+ NSUInteger minWidth;
+ } kTestModes[] = {
+ { "NoMin", 0 },
+ { "Min", 450 },
+ };
+ NSString *kTestStrings[] = {
+ @"The fox jumps the dog.",
+ @"The quick brown fox jumps over the lazy dog.",
+ @"The quick brown fox jumps over the lazy dog. The quick brown fox jumps "
+ @"over the lazy dog. The quick brown fox jumps over the lazy dog. "
+ @"The quick brown fox jumps over the lazy dog. The quick brown fox "
+ @"jumps over the lazy dog.",
+ @"The quick brown fox jumps over the lazy dog. The quick brown fox jumps "
+ @"over the lazy dog. The quick brown fox jumps over the lazy dog. "
+ @"The quick brown fox jumps over the lazy dog. The quick brown fox "
+ @"jumps over the lazy dog. The quick brown fox jumps over the lazy "
+ @"dog. The quick brown fox jumps over the lazy dog. The End.",
+ };
+ for (size_t modeLoop = 0;
+ modeLoop < (sizeof(kTestModes) / sizeof(kTestModes[0]));
+ ++modeLoop) {
+ for (size_t lp = 0;
+ lp < (sizeof(kTestStrings) / sizeof(kTestStrings[0]));
+ ++lp) {
+ GTMUILocalizerAndLayoutTweakerTestWindowController *controller =
+ [[GTMUILocalizerAndLayoutTweakerTestWindowController alloc]
+ initWithWindowNibName:@"GTMUILocalizerAndLayoutTweakerTest7"];
+ NSWindow *window = [controller window];
+ STAssertNotNil(window, @"Pass %zu", lp);
+ NSTextField *field;
+ GTM_FOREACH_OBJECT(field, [[window contentView] subviews]) {
+ STAssertTrue([field isMemberOfClass:[NSTextField class]],
+ @"Pass %zu", lp);
+ [field setStringValue:kTestStrings[lp]];
+ NSUInteger minWidth = kTestModes[modeLoop].minWidth;
+ if (minWidth) {
+ [GTMUILocalizerAndLayoutTweaker sizeToFitFixedHeightTextField:field
+ minWidth:minWidth];
+ } else {
+ [GTMUILocalizerAndLayoutTweaker sizeToFitFixedHeightTextField:field];
+ }
+ }
+ NSString *imageName =
+ [NSString stringWithFormat:@"GTMUILocalizerAndLayoutTweakerTest7-%s-%ld",
+ kTestModes[modeLoop].name, (long)lp];
+ GTMAssertObjectImageEqualToImageNamed(window, imageName,
+ @"Pass %zu-%zu", modeLoop, lp);
+ [controller release];
+ }
+ }
+}
+#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+
@end
@implementation GTMUILocalizerAndLayoutTweakerTestWindowController