From fa4f21c122f949b87dabe69b4eb43b1c1d56ea50 Mon Sep 17 00:00:00 2001 From: Yee Cheng Chin Date: Thu, 13 Feb 2025 20:50:31 -0800 Subject: [PATCH] Fix MacVim dark mode test being a little flaky We need to make sure to wait for Vim to handle the system appearance change message before querying it or it would be subject to timing issues. --- src/MacVim/MacVimTests/MacVimTests.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/MacVim/MacVimTests/MacVimTests.m b/src/MacVim/MacVimTests/MacVimTests.m index d1ce195925..dca00c29f1 100644 --- a/src/MacVim/MacVimTests/MacVimTests.m +++ b/src/MacVim/MacVimTests/MacVimTests.m @@ -661,6 +661,7 @@ - (void) testDarkMode { // Manual Light / Dark mode setting [self setDefault:MMAppearanceModeSelectionKey toValue:[NSNumber numberWithInt:MMAppearanceModeSelectionLight]]; [app refreshAllAppearances]; + [self waitForVimProcess]; XCTAssertEqualObjects(vimView.effectiveAppearance, [NSAppearance appearanceNamed: NSAppearanceNameAqua]); XCTAssertEqualObjects([[app keyVimController] evaluateVimExpression:@"v:os_appearance"], @"0"); @@ -672,6 +673,7 @@ - (void) testDarkMode { [self setDefault:MMAppearanceModeSelectionKey toValue:[NSNumber numberWithInt:MMAppearanceModeSelectionDark]]; [app refreshAllAppearances]; + [self waitForVimProcess]; XCTAssertEqualObjects(vimView.effectiveAppearance, [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua]); XCTAssertEqualObjects([[app keyVimController] evaluateVimExpression:@"v:os_appearance"], @"1"); XCTAssertEqualObjects([[app keyVimController] evaluateVimExpression:@"g:os_appearance_changed_called"], @"1"); @@ -682,6 +684,7 @@ - (void) testDarkMode { [self setDefault:MMAppearanceModeSelectionKey toValue:[NSNumber numberWithInt:MMAppearanceModeSelectionBackgroundOption]]; [app refreshAllAppearances]; + [self waitForVimProcess]; XCTAssertEqualObjects(vimView.effectiveAppearance, [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua]); XCTAssertEqualObjects([[app keyVimController] evaluateVimExpression:@"v:os_appearance"], @"1"); XCTAssertEqualObjects([[app keyVimController] evaluateVimExpression:@"g:os_appearance_changed_called"], @"1"); // we stayed in dark mode, so OSAppearnceChanged didn't trigger