From 0ec107abd39b40d5156cd90108c6a6b0f6e286d7 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Tue, 7 Nov 2023 14:34:52 -0800 Subject: [PATCH] [macOS] Bail out of tests if engine not running In engine tests where we require a running engine to proceed with the test, immediately fail if the engine isn't running rather than carrying on with the test. In most cases, the fixture test proceeds to block the main thread on a latch until it's released from the UI thread, so this results in quicker test failures. --- .../darwin/macos/framework/Source/FlutterEngineTest.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm index 4aa073de93506..90177509f0eb9 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm @@ -122,7 +122,7 @@ + (void)registerWithRegistrar:(id)registrar { TEST_F(FlutterEngineTest, CanLaunch) { FlutterEngine* engine = GetFlutterEngine(); EXPECT_TRUE([engine runWithEntrypoint:@"main"]); - EXPECT_TRUE(engine.running); + ASSERT_TRUE(engine.running); } TEST_F(FlutterEngineTest, HasNonNullExecutableName) { @@ -196,7 +196,7 @@ + (void)registerWithRegistrar:(id)registrar { // Launch the test entrypoint. FlutterEngine* engine = GetFlutterEngine(); EXPECT_TRUE([engine runWithEntrypoint:@"canLogToStdout"]); - EXPECT_TRUE(engine.running); + ASSERT_TRUE(engine.running); latch.Wait(); @@ -227,7 +227,7 @@ + (void)registerWithRegistrar:(id)registrar { // Launch the test entrypoint. EXPECT_TRUE([engine runWithEntrypoint:@"backgroundTest"]); - EXPECT_TRUE(engine.running); + ASSERT_TRUE(engine.running); FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine nibName:nil @@ -257,7 +257,7 @@ + (void)registerWithRegistrar:(id)registrar { // Launch the test entrypoint. EXPECT_TRUE([engine runWithEntrypoint:@"backgroundTest"]); - EXPECT_TRUE(engine.running); + ASSERT_TRUE(engine.running); FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine nibName:nil @@ -479,7 +479,7 @@ + (void)registerWithRegistrar:(id)registrar { FlutterEngine* engine = GetFlutterEngine(); EXPECT_TRUE([engine runWithEntrypoint:@"nativeCallback"]); - EXPECT_TRUE(engine.running); + ASSERT_TRUE(engine.running); latch.Wait(); ASSERT_TRUE(latch_called);