Skip to content

Commit 64800c7

Browse files
authored
Setup channels during IntegrationTest registration on iOS (#123729)
Setup channels during IntegrationTest registration on iOS
1 parent 0ddb964 commit 64800c7

File tree

4 files changed

+5
-28
lines changed

4 files changed

+5
-28
lines changed

packages/integration_test/example/ios/RunnerTests/RunnerTests.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ @interface FakeIntegrationTestPlugin : IntegrationTestPlugin
3939

4040
@implementation FakeIntegrationTestPlugin
4141
@synthesize testResults;
42-
43-
- (void)setupChannels:(id<FlutterBinaryMessenger>)binaryMessenger {
44-
}
45-
4642
@end
4743

4844
#pragma mark - Behavior tests

packages/integration_test/ios/Classes/FLTIntegrationTestRunner.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ - (instancetype)init {
2626

2727
- (void)testIntegrationTestWithResults:(NS_NOESCAPE FLTIntegrationTestResults)testResult {
2828
IntegrationTestPlugin *integrationTestPlugin = self.integrationTestPlugin;
29-
UIViewController *rootViewController = UIApplication.sharedApplication.delegate.window.rootViewController;
30-
if (![rootViewController isKindOfClass:[FlutterViewController class]]) {
31-
testResult(NSSelectorFromString(@"testSetup"), NO, @"rootViewController was not expected FlutterViewController");
32-
}
33-
FlutterViewController *flutterViewController = (FlutterViewController *)rootViewController;
34-
[integrationTestPlugin setupChannels:flutterViewController.engine.binaryMessenger];
35-
3629
// Spin the runloop.
3730
while (!integrationTestPlugin.testResults) {
3831
[NSRunLoop.currentRunLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];

packages/integration_test/ios/Classes/IntegrationTestPlugin.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
2222
@property (copy, readonly) NSDictionary<NSString *, UIImage *> *capturedScreenshotsByName;
2323

2424
/** Fetches the singleton instance of the plugin. */
25-
+ (IntegrationTestPlugin *)instance;
26-
27-
- (void)setupChannels:(id<FlutterBinaryMessenger>)binaryMessenger;
25+
+ (instancetype)instance;
2826

2927
- (instancetype)init NS_UNAVAILABLE;
3028

packages/integration_test/ios/Classes/IntegrationTestPlugin.m

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ @implementation IntegrationTestPlugin {
2525
NSMutableDictionary<NSString *, UIImage *> *_capturedScreenshotsByName;
2626
}
2727

28-
+ (IntegrationTestPlugin *)instance {
28+
+ (instancetype)instance {
2929
static dispatch_once_t onceToken;
3030
static IntegrationTestPlugin *sInstance;
3131
dispatch_once(&onceToken, ^{
@@ -45,19 +45,9 @@ - (instancetype)init {
4545
}
4646

4747
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
48-
// No initialization happens here because of the way XCTest loads the testing
49-
// bundles. Setup on static variables can be disregarded when a new static
50-
// instance of IntegrationTestPlugin is allocated when the bundle is reloaded.
51-
// See also: https://github.com/flutter/plugins/pull/2465
52-
}
53-
54-
- (void)setupChannels:(id<FlutterBinaryMessenger>)binaryMessenger {
55-
FlutterMethodChannel *channel =
56-
[FlutterMethodChannel methodChannelWithName:kIntegrationTestPluginChannel
57-
binaryMessenger:binaryMessenger];
58-
[channel setMethodCallHandler:^(FlutterMethodCall *call, FlutterResult result) {
59-
[self handleMethodCall:call result:result];
60-
}];
48+
FlutterMethodChannel *channel = [FlutterMethodChannel methodChannelWithName:kIntegrationTestPluginChannel
49+
binaryMessenger:registrar.messenger];
50+
[registrar addMethodCallDelegate:[self instance] channel:channel];
6151
}
6252

6353
- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {

0 commit comments

Comments
 (0)