diff --git a/src/MacVim/MacVimTests/MacVimTests.m b/src/MacVim/MacVimTests/MacVimTests.m index 823839652c..492f354cc9 100644 --- a/src/MacVim/MacVimTests/MacVimTests.m +++ b/src/MacVim/MacVimTests/MacVimTests.m @@ -44,7 +44,7 @@ @interface MacVimTests : XCTestCase @implementation MacVimTests -/// Wait for Vim window to open and is ready to go +/// Wait for Vim window to open - (void)waitForVimOpen { XCTestExpectation *expectation = [self expectationWithDescription:@"VimOpen"]; @@ -61,7 +61,11 @@ - (void)waitForVimOpen { method_setImplementation(method, newIMP); [self waitForExpectations:@[expectation] timeout:10]; method_setImplementation(method, origIMP); +} +/// Wait for Vim window to open and is ready to go +- (void)waitForVimOpenAndWait { + [self waitForVimOpen]; [self waitForEventHandlingAndVimProcess]; } @@ -259,7 +263,7 @@ - (void)testVimTutor { // Adding a new window is necessary for the vimtutor menu to show up as it's // not part of the global menu [app openNewWindow:NewWindowClean activate:YES]; - [self waitForVimOpen]; + [self waitForVimOpenAndWait]; // Find the vimtutor menu and run it. NSMenu *mainMenu = [NSApp mainMenu]; @@ -278,7 +282,7 @@ - (void)testVimTutor { // Note that `vimtutor` opens Vim twice. Once to copy the file. Another time to // actually open the copied file. [self waitForVimOpen]; - [self waitForVimOpen]; + [self waitForVimOpenAndWait]; NSString *bufname = [[app keyVimController] evaluateVimExpression:@"bufname()"]; XCTAssertTrue([bufname containsString:@"tutor"]); @@ -302,7 +306,7 @@ - (void)testHelpMenuDocumentationTag { // Test help menu when no window is shown [app performActionForItem:@[@"", @"m'"]]; - [self waitForVimOpen]; + [self waitForVimOpenAndWait]; MMVimController *vim = [app keyVimController]; XCTAssertEqualObjects(@"help", [vim evaluateVimExpression:@"&buftype"]); @@ -314,7 +318,7 @@ - (void)testHelpMenuDocumentationTag { // Test help menu when there's already a Vim window [app openNewWindow:NewWindowClean activate:YES]; - [self waitForVimOpen]; + [self waitForVimOpenAndWait]; vim = [app keyVimController]; #define ASSERT_HELP_PATTERN(pattern) \ @@ -358,7 +362,7 @@ - (void) testCmdlineRowCalculation { MMAppController *app = MMAppController.sharedInstance; [app openNewWindow:NewWindowClean activate:YES]; - [self waitForVimOpen]; + [self waitForVimOpenAndWait]; MMTextView *textView = [[[[app keyVimController] windowController] vimView] textView]; const int numLines = [textView maxRows];