Skip to content

Commit

Permalink
Begin making tests pass again
Browse files Browse the repository at this point in the history
  • Loading branch information
gnachman committed Jun 10, 2015
1 parent dbdf3af commit 3b5ca72
Show file tree
Hide file tree
Showing 9 changed files with 442 additions and 1,189 deletions.
972 changes: 138 additions & 834 deletions Interfaces/GlobalSearch.xib

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion sources/VT100Grid.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#import "DebugLogging.h"
#import "LineBuffer.h"
#import "NSDictionary+iTerm.h"
#import "RegexKitLite.h"
#import "VT100GridTypes.h"
#import "VT100LineInfo.h"
#import "VT100Terminal.h"
Expand Down
7 changes: 7 additions & 0 deletions sources/iTermTests/IntervalTreeTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ @interface ITObject : NSObject <IntervalTreeObject>
@end

@implementation ITObject
- (id)initWithDictionary:(NSDictionary *)dict {
return [self init];
}
- (NSDictionary *)dictionaryValue {
return @{};
}

@synthesize entry;
@end

Expand Down
7 changes: 4 additions & 3 deletions sources/iTermTests/PTYSessionTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ @implementation FakePasteHelper
- (void)pasteString:(NSString *)theString
slowly:(BOOL)slowly
escapeShellChars:(BOOL)escapeShellChars
commands:(BOOL)commands
tabTransform:(iTermTabTransformTags)tabTransform
spacesPerTab:(int)spacesPerTab {
self.string = theString;
Expand Down Expand Up @@ -108,7 +109,7 @@ - (void)testEscapeSpecialChars {
- (void)testEmbeddedTabsConvertToSpaces {
NSString *theString = @"a\tb";
_warningBlock = ^NSModalResponse(NSAlert *alert, NSString *identifier) {
assert([identifier isEqualToString:@"AboutToPasteTabs"]);
assert([identifier isEqualToString:@"AboutToPasteTabsWithCancel"]);
BOOL found = NO;
for (NSView *subview in alert.accessoryView.subviews) {
if ([subview isKindOfClass:[NSTextField class]] &&
Expand All @@ -121,10 +122,10 @@ - (void)testEmbeddedTabsConvertToSpaces {
}
}
assert(found);
return NSAlertAlternateReturn;
return NSAlertOtherReturn;
};
[_session pasteString:theString flags:0];
assert([_warningIdentifiers containsObject:@"AboutToPasteTabs"]);
assert([_warningIdentifiers containsObject:@"AboutToPasteTabsWithCancel"]);

assert([_fakePasteHelper.string isEqualToString:theString]);
assert(_fakePasteHelper.tabTransform == kTabTransformConvertToSpaces);
Expand Down
14 changes: 14 additions & 0 deletions sources/iTermTests/PTYTextViewTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ - (NSIndexSet *)dirtyIndexesOnLine:(int)line {
return nil;
}

- (BOOL)isRestartable {
return NO;
}

- (void)setRangeOfCharsAnimated:(NSRange)range onLine:(int)line {
}

- (NSIndexSet *)animatedLines {
return nil;
}

- (void)resetAnimatedLines {
}

- (void)resetDirty {
}

Expand Down
42 changes: 0 additions & 42 deletions sources/iTermTests/VT100GridTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -1550,48 +1550,6 @@ - (VT100Grid *)coverageForRuns:(NSArray *)runs inGrid:(VT100Grid *)grid {
return coverage;
}

- (void)testRunsMatchingRegex {
NSString *cl =
// 0123456789ab
@"george !\n" // 0
@" geo+\n" // 1
@"rge !\n" // 2
@" geo!\n" // 3
@"rge !\n" // 4
@"georgegeorge!\n" // 5
@" georgeo+\n" // 6
@"rge !"; // 7
VT100Grid *grid = [self gridFromCompactLinesWithContinuationMarks:cl];
NSArray *runs = [grid runsMatchingRegex:@"george"];

NSString *expectedCoverage =
@"xxxxxx......\n" // 0
@".........xxx\n" // 1
@"xxx.........\n" // 2
@"............\n" // 3
@"............\n" // 4
@"xxxxxxxxxxxx\n" // 5
@".....xxxxxx.\n" // 6
@"............"; // 7
VT100Grid *coverage = [self coverageForRuns:runs inGrid:grid];
assert([[coverage compactLineDump] isEqualToString:expectedCoverage]);

// Now test with combining marks.
screen_char_t *line = [grid screenCharsAtLineNumber:0];
BeginComplexChar(line + 1, 0x20dd, NO); // e + combining enclosing circle
line[1].complexChar = YES;
runs = [grid runsMatchingRegex:@"ge.?orge"]; // the regex lib doesn't handle combining marks well
coverage = [self coverageForRuns:runs inGrid:grid];
assert([[coverage compactLineDump] isEqualToString:expectedCoverage]);

// Test with double-width char.
line[1].code = 0xff25; // fullwidth e
line[1].complexChar = NO;
runs = [grid runsMatchingRegex:@"g.orge"];
coverage = [self coverageForRuns:runs inGrid:grid];
assert([[coverage compactLineDump] isEqualToString:expectedCoverage]);
}

// - is a DWC_RIGHT
// . is null
// All other chars are taken literally
Expand Down
51 changes: 0 additions & 51 deletions sources/iTermTests/VT100ScreenTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -2025,57 +2025,6 @@ - (void)testSetTmuxState {
assert(screen.cursorX == 9);
}

- (void)testHighlightTextMatchingRegex {
NSArray *lines = @[@"rerex", @"xrere", @"xxrerexxxx", @"xxrererere"];
VT100Screen *screen = [self screenWithWidth:5 height:7];
screen.delegate = (id<VT100ScreenDelegate>)self;
[self appendLines:lines toScreen:screen];
[screen highlightTextMatchingRegex:@"re" colors:@{ kHighlightForegroundColor: [NSColor blueColor],
kHighlightBackgroundColor: [NSColor redColor] }];
NSArray *expectedHighlights =
@[ @"hhhh.",
@".hhhh",
@"..hhh",
@"h....",
@"..hhh",
@"hhhhh",
@"....." ];
int blue = 16 + 5;
int red = 16 + 5 * 36;
[self assertScreen:screen
matchesHighlights:expectedHighlights
highlightFg:blue
highlightFgMode:ColorModeNormal
highlightBg:red
highlightBgMode:ColorModeNormal];

// Leave fg unaffected
screen = [self screenWithWidth:5 height:7];
screen.delegate = (id<VT100ScreenDelegate>)self;
[self appendLines:lines toScreen:screen];
[screen highlightTextMatchingRegex:@"re" colors:@{ kHighlightBackgroundColor: [NSColor redColor] }];
int defaultFg = [terminal_ foregroundColorCode].foregroundColor;
[self assertScreen:screen
matchesHighlights:expectedHighlights
highlightFg:defaultFg
highlightFgMode:ColorModeAlternate
highlightBg:red
highlightBgMode:ColorModeNormal];

// Leave bg unaffected
screen = [self screenWithWidth:5 height:7];
screen.delegate = (id<VT100ScreenDelegate>)self;
[self appendLines:lines toScreen:screen];
[screen highlightTextMatchingRegex:@"re" colors:@{ kHighlightForegroundColor: [NSColor blueColor] }];
int defaultBg = [terminal_ foregroundColorCode].backgroundColor;
[self assertScreen:screen
matchesHighlights:expectedHighlights
highlightFg:blue
highlightFgMode:ColorModeNormal
highlightBg:defaultBg
highlightBgMode:ColorModeAlternate];
}

- (void)testSetFromFrame {
VT100Screen *source = [self fiveByFourScreenWithThreeLinesOneWrapped];
NSMutableData *data = [NSMutableData data];
Expand Down
Loading

0 comments on commit 3b5ca72

Please sign in to comment.