@@ -4243,34 +4243,40 @@ TEST_F(ShellTest, PrintsErrorWhenPlatformMessageSentFromWrongThread) {
4243
4243
task_runner);
4244
4244
auto shell = CreateShell (settings, task_runners);
4245
4245
4246
- auto stream = std::make_shared<std::ostringstream>();
4247
- fml::CaptureNextLog (stream.get ());
4248
-
4249
- // The next call will result in a thread checker violation.
4250
- fml::ThreadChecker::DisableNextThreadCheckFailure ();
4251
- SendPlatformMessage (shell.get (), std::make_unique<PlatformMessage>(
4252
- " com.test.plugin" , nullptr ));
4253
-
4254
- EXPECT_THAT (stream->str (),
4255
- ::testing::EndsWith (
4256
- " The 'com.test.plugin' channel sent a message from native to "
4257
- " Flutter on a non-platform thread. Platform channel messages "
4258
- " must be sent on the platform thread. Failure to do so may "
4259
- " result in data loss or crashes, and must be fixed in the "
4260
- " plugin or application code creating that channel.\n See "
4261
- " https://docs.flutter.dev/platform-integration/"
4262
- " platform-channels#channels-and-platform-threading for more "
4263
- " information.\n " ));
4264
-
4265
- stream = std::make_shared<std::ostringstream>();
4266
- fml::CaptureNextLog (stream.get ());
4267
-
4268
- // The next call will result in a thread checker violation.
4269
- fml::ThreadChecker::DisableNextThreadCheckFailure ();
4270
- SendPlatformMessage (shell.get (), std::make_unique<PlatformMessage>(
4271
- " com.test.plugin" , nullptr ));
4272
-
4273
- EXPECT_EQ (stream->str (), " " );
4246
+ {
4247
+ fml::testing::LogCapture log_capture;
4248
+
4249
+ // The next call will result in a thread checker violation.
4250
+ fml::ThreadChecker::DisableNextThreadCheckFailure ();
4251
+ SendPlatformMessage (shell.get (), std::make_unique<PlatformMessage>(
4252
+ " com.test.plugin" , nullptr ));
4253
+
4254
+ EXPECT_THAT (
4255
+ log_capture.str (),
4256
+ ::testing::EndsWith (
4257
+ " The 'com.test.plugin' channel sent a message from native to "
4258
+ " Flutter on a non-platform thread. Platform channel messages "
4259
+ " must be sent on the platform thread. Failure to do so may "
4260
+ " result in data loss or crashes, and must be fixed in the "
4261
+ " plugin or application code creating that channel.\n See "
4262
+ " https://docs.flutter.dev/platform-integration/"
4263
+ " platform-channels#channels-and-platform-threading for more "
4264
+ " information.\n " ));
4265
+ }
4266
+
4267
+ {
4268
+ fml::testing::LogCapture log_capture;
4269
+
4270
+ // The next call will result in a thread checker violation.
4271
+ fml::ThreadChecker::DisableNextThreadCheckFailure ();
4272
+ SendPlatformMessage (shell.get (), std::make_unique<PlatformMessage>(
4273
+ " com.test.plugin" , nullptr ));
4274
+
4275
+ EXPECT_EQ (log_capture.str (), " " );
4276
+ }
4277
+
4278
+ DestroyShell (std::move (shell), task_runners);
4279
+ ASSERT_FALSE (DartVMRef::IsInstanceRunning ());
4274
4280
}
4275
4281
4276
4282
} // namespace testing
0 commit comments