This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
shell/platform/darwin/ios/framework/Source Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -218,4 +218,25 @@ - (void)testDeallocNotification {
218218 [center removeObserver: observer];
219219}
220220
221+ - (void )testSetHandlerAfterRun {
222+ FlutterEngine* engine = [[FlutterEngine alloc ] initWithName: @" foobar" ];
223+ NSObject <FlutterPluginRegistrar>* registrar = [engine registrarForPlugin: @" foo" ];
224+ XCTestExpectation* gotMessage = [self expectationWithDescription: @" gotMessage" ];
225+ fml::AutoResetWaitableEvent latch;
226+ [engine run ];
227+ flutter::Shell& shell = engine.shell ;
228+ engine.shell .GetTaskRunners ().GetUITaskRunner ()->PostTask ([&latch, &shell] {
229+ flutter::Engine::Delegate& delegate = shell;
230+ auto message = std::make_unique<flutter::PlatformMessage>(" foo" , nullptr );
231+ delegate.OnEngineHandlePlatformMessage (std::move (message));
232+ latch.Signal ();
233+ });
234+ latch.Wait ();
235+ [registrar.messenger setMessageHandlerOnChannel: @" foo"
236+ binaryMessageHandler: ^(NSData * message, FlutterBinaryReply reply) {
237+ [gotMessage fulfill ];
238+ }];
239+ [self waitForExpectationsWithTimeout: 1 handler: nil ];
240+ }
241+
221242@end
Original file line number Diff line number Diff line change 22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5+ #import " flutter/shell/common/shell.h"
56#import " flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h"
67#import " flutter/shell/platform/darwin/ios/rendering_api_selection.h"
78
@@ -15,6 +16,7 @@ class ThreadHost;
1516
1617// Category to add test-only visibility.
1718@interface FlutterEngine (Test) <FlutterBinaryMessenger>
19+ - (flutter::Shell&)shell ;
1820- (void )setBinaryMessenger : (FlutterBinaryMessengerRelay*)binaryMessenger ;
1921- (flutter::IOSRenderingAPI)platformViewsRenderingAPI ;
2022- (void )waitForFirstFrame : (NSTimeInterval )timeout callback : (void (^)(BOOL didTimeout))callback ;
You can’t perform that action at this time.
0 commit comments