Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7bbe0ed

Browse files
committed
WIP not having luck at figuring out how to test this
1 parent be1a37a commit 7bbe0ed

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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

shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
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

0 commit comments

Comments
 (0)