aboutsummaryrefslogtreecommitdiff
path: root/AppKit/GTMFadeTruncatingTextFieldCellTest.m
diff options
context:
space:
mode:
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