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 +36
-0
lines changed
shell/platform/darwin/ios/framework/Source Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -79,4 +79,18 @@ - (void)testNotifyPluginOfDealloc {
7979 OCMVerify ([plugin detachFromEngineForRegistrar: [OCMArg any ]]);
8080}
8181
82+ // TODO(justinmc): Or is this the way to test platform channel messages? How can
83+ // I see if it was handled?
84+ /*
85+ - (void)testHasStrings {
86+ id project = OCMClassMock([FlutterDartProject class]);
87+ FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
88+ XCTAssertNotNil(engine);
89+ XCTAssertNoThrow([engine.binaryMessenger
90+ sendOnChannel:@"Clipboard"
91+ message:[@"hasStrings" dataUsingEncoding:NSUTF8StringEncoding]
92+ binaryReply:nil]);
93+ }
94+ */
95+
8296@end
Original file line number Diff line number Diff line change 88#import " flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
99#import " flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlatformViews.h"
1010#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
11+ // #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h"
1112#import " flutter/shell/platform/darwin/ios/platform_view_ios.h"
1213#import " third_party/ocmock/Source/OCMock/OCMock.h"
1314
@@ -143,4 +144,25 @@ - (void)testCanCreatePlatformViewWithoutFlutterView {
143144 flutterPlatformViewsController->Reset ();
144145}
145146
147+ // TODO(justinmc): I wrote this test before realizing handleMethodCall is
148+ // private. Is there any way around that to make this approach work?
149+ /*
150+ - (void)testHasStrings {
151+ FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:nil];
152+ std::unique_ptr<fml::WeakPtrFactory<FlutterEngine>> _weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterEngine>>(engine);
153+ FlutterPlatformPlugin* plugin = [[FlutterPlatformPlugin alloc] initWithEngine:_weakFactory->GetWeakPtr()];
154+ __block bool called = false;
155+ __block bool value;
156+ FlutterResult result = ^(id result) {
157+ called = true;
158+ value = result[@"value"];
159+ };
160+ FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName:@"Clipboard.hasStrings" arguments:@{}];
161+ plugin.handleMethodCall(methodCall, result);
162+
163+ XCTAssertEqual(called, true);
164+ XCTAssertEqual(value, true);
165+ }
166+ */
167+
146168@end
You can’t perform that action at this time.
0 commit comments