Unverified Commit 64800c79 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Setup channels during IntegrationTest registration on iOS (#123729)

Setup channels during IntegrationTest registration on iOS
parent 0ddb9643
...@@ -39,10 +39,6 @@ INTEGRATION_TEST_IOS_RUNNER(RunnerTests) ...@@ -39,10 +39,6 @@ INTEGRATION_TEST_IOS_RUNNER(RunnerTests)
@implementation FakeIntegrationTestPlugin @implementation FakeIntegrationTestPlugin
@synthesize testResults; @synthesize testResults;
- (void)setupChannels:(id<FlutterBinaryMessenger>)binaryMessenger {
}
@end @end
#pragma mark - Behavior tests #pragma mark - Behavior tests
......
...@@ -26,13 +26,6 @@ ...@@ -26,13 +26,6 @@
- (void)testIntegrationTestWithResults:(NS_NOESCAPE FLTIntegrationTestResults)testResult { - (void)testIntegrationTestWithResults:(NS_NOESCAPE FLTIntegrationTestResults)testResult {
IntegrationTestPlugin *integrationTestPlugin = self.integrationTestPlugin; IntegrationTestPlugin *integrationTestPlugin = self.integrationTestPlugin;
UIViewController *rootViewController = UIApplication.sharedApplication.delegate.window.rootViewController;
if (![rootViewController isKindOfClass:[FlutterViewController class]]) {
testResult(NSSelectorFromString(@"testSetup"), NO, @"rootViewController was not expected FlutterViewController");
}
FlutterViewController *flutterViewController = (FlutterViewController *)rootViewController;
[integrationTestPlugin setupChannels:flutterViewController.engine.binaryMessenger];
// Spin the runloop. // Spin the runloop.
while (!integrationTestPlugin.testResults) { while (!integrationTestPlugin.testResults) {
[NSRunLoop.currentRunLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]]; [NSRunLoop.currentRunLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
......
...@@ -22,9 +22,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -22,9 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (copy, readonly) NSDictionary<NSString *, UIImage *> *capturedScreenshotsByName; @property (copy, readonly) NSDictionary<NSString *, UIImage *> *capturedScreenshotsByName;
/** Fetches the singleton instance of the plugin. */ /** Fetches the singleton instance of the plugin. */
+ (IntegrationTestPlugin *)instance; + (instancetype)instance;
- (void)setupChannels:(id<FlutterBinaryMessenger>)binaryMessenger;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
......
...@@ -25,7 +25,7 @@ static NSString *const kMethodRevertImage = @"revertFlutterImage"; ...@@ -25,7 +25,7 @@ static NSString *const kMethodRevertImage = @"revertFlutterImage";
NSMutableDictionary<NSString *, UIImage *> *_capturedScreenshotsByName; NSMutableDictionary<NSString *, UIImage *> *_capturedScreenshotsByName;
} }
+ (IntegrationTestPlugin *)instance { + (instancetype)instance {
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
static IntegrationTestPlugin *sInstance; static IntegrationTestPlugin *sInstance;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
...@@ -45,19 +45,9 @@ static NSString *const kMethodRevertImage = @"revertFlutterImage"; ...@@ -45,19 +45,9 @@ static NSString *const kMethodRevertImage = @"revertFlutterImage";
} }
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar { + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
// No initialization happens here because of the way XCTest loads the testing FlutterMethodChannel *channel = [FlutterMethodChannel methodChannelWithName:kIntegrationTestPluginChannel
// bundles. Setup on static variables can be disregarded when a new static binaryMessenger:registrar.messenger];
// instance of IntegrationTestPlugin is allocated when the bundle is reloaded. [registrar addMethodCallDelegate:[self instance] channel:channel];
// See also: https://github.com/flutter/plugins/pull/2465
}
- (void)setupChannels:(id<FlutterBinaryMessenger>)binaryMessenger {
FlutterMethodChannel *channel =
[FlutterMethodChannel methodChannelWithName:kIntegrationTestPluginChannel
binaryMessenger:binaryMessenger];
[channel setMethodCallHandler:^(FlutterMethodCall *call, FlutterResult result) {
[self handleMethodCall:call result:result];
}];
} }
- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment