aboutsummaryrefslogtreecommitdiff
path: root/AppKit/GTMFadeTruncatingTextFieldCellTest.m
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2011-03-18 21:00:21 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2011-03-18 21:00:21 +0000
commitfb696efd169db17e8169d0d0cfd1caf0728c0722 (patch)
treec5e617df9d40b77132892abb3d0264dca3a8e56a /AppKit/GTMFadeTruncatingTextFieldCellTest.m
parent72bd0c479793ffcd5a78696da9ba27e8b26c8e3e (diff)
[Author: sail]
Currently GTMFadeTruncatingTextFieldCell only supports truncating the tail of a string. It should also allow the head of a string to be truncated. I'd like to use this in Chromium. See http://crbug.com/69304 R=thomasvl APPROVED=thomasvl DELTA=238 (197 added, 17 deleted, 24 changed)
Diffstat (limited to 'AppKit/GTMFadeTruncatingTextFieldCellTest.m')
-rw-r--r--AppKit/GTMFadeTruncatingTextFieldCellTest.m36
1 files changed, 35 insertions, 1 deletions
diff --git a/AppKit/GTMFadeTruncatingTextFieldCellTest.m b/AppKit/GTMFadeTruncatingTextFieldCellTest.m
index a42e22e..a1bf937 100644
--- a/AppKit/GTMFadeTruncatingTextFieldCellTest.m
+++ b/AppKit/GTMFadeTruncatingTextFieldCellTest.m
@@ -28,7 +28,7 @@
@implementation GTMFadeTruncatingTextFieldCellTest
-- (void)testFadeCell {
+- (void)testFadeCellRight {
NSTextField *field = [[[NSTextField alloc] initWithFrame:
NSMakeRect(0, 0, 100, 16)] autorelease];
[field setCell:[[[GTMFadeTruncatingTextFieldCell alloc] initTextCell:@""]
@@ -38,6 +38,7 @@
GTMAssertObjectImageEqualToImageNamed(field,
@"GTMFadeTruncatingTextFieldCellTest1",
nil);
+
[field setStringValue:@"A short string"];
GTMAssertObjectImageEqualToImageNamed(field,
@"GTMFadeTruncatingTextFieldCellTest2",
@@ -60,6 +61,39 @@
nil);
}
+- (void)testFadeCellLeftAndRight {
+ NSTextField *field = [[[NSTextField alloc] initWithFrame:
+ NSMakeRect(0, 0, 100, 16)] autorelease];
+ GTMFadeTruncatingTextFieldCell *cell =
+ [[[GTMFadeTruncatingTextFieldCell alloc] initTextCell:@""] autorelease];
+ [cell setTruncateMode:GTMFadeTruncatingHeadAndTail];
+ [cell setDesiredCharactersToTruncateFromHead:5];
+ [field setCell:cell];
+
+ [field setStringValue:@"Fade on both left and right AAAA"];
+ GTMAssertObjectImageEqualToImageNamed(field,
+ @"GTMFadeTruncatingTextFieldCellTest5",
+ nil);
+
+ [field setStringValue:@"Fade on left only AA"];
+ GTMAssertObjectImageEqualToImageNamed(field,
+ @"GTMFadeTruncatingTextFieldCellTest6",
+ nil);
+
+ [field setStringValue:@"A short string"];
+ GTMAssertObjectImageEqualToImageNamed(field,
+ @"GTMFadeTruncatingTextFieldCellTest2",
+ nil);
+
+ // Test the case where the number of characters to truncate from head is not
+ // specified. This should cause the string to be drawn centered.
+ [cell setDesiredCharactersToTruncateFromHead:0];
+ [field setStringValue:@"Fade on both left and right AAAA"];
+ GTMAssertObjectImageEqualToImageNamed(field,
+ @"GTMFadeTruncatingTextFieldCellTest7",
+ nil);
+}
+
@end
#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5