79 {
80 ThreadHost thread_host(
"io.flutter.test." + std::string(
self.
name.UTF8String),
82 TaskRunners task_runners(
84 thread_host.ui_thread->GetTaskRunner(), thread_host.io_thread->GetTaskRunner());
85
86 auto handler = std::make_unique<PlatformMessageHandlerIos>(task_runners.GetPlatformTaskRunner());
87 std::string channel = "foo";
88 XCTestExpectation* didCallMessage = [self expectationWithDescription:@"didCallMessage"];
89 handler->SetMessageHandler(
90 channel,
92 XCTFail(@"This shouldn't be called");
93 reply(nil);
94 },
95 nil);
96 handler->SetMessageHandler(channel, nil, nil);
98 task_runners.GetUITaskRunner()->PostTask([channel, response, &handler, &didCallMessage] {
99 auto platform_message = std::make_unique<flutter::PlatformMessage>(channel, response);
100 handler->HandlePlatformMessage(std::move(platform_message));
101 [didCallMessage fulfill];
102 });
103 [self waitForExpectationsWithTimeout:1.0 handler:nil];
104 XCTAssertTrue(response->is_complete());
105}