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)
@implementation FakeIntegrationTestPlugin
@synthesize testResults;
- (void)setupChannels:(id<FlutterBinaryMessenger>)binaryMessenger {
}
@end
#pragma mark - Behavior tests
......
......@@ -26,13 +26,6 @@
- (void)testIntegrationTestWithResults:(NS_NOESCAPE FLTIntegrationTestResults)testResult {
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.
while (!integrationTestPlugin.testResults) {
[NSRunLoop.currentRunLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
......
......@@ -22,9 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (copy, readonly) NSDictionary<NSString *, UIImage *> *capturedScreenshotsByName;
/** Fetches the singleton instance of the plugin. */
+ (IntegrationTestPlugin *)instance;
- (void)setupChannels:(id<FlutterBinaryMessenger>)binaryMessenger;
+ (instancetype)instance;
- (instancetype)init NS_UNAVAILABLE;
......
......@@ -25,7 +25,7 @@ static NSString *const kMethodRevertImage = @"revertFlutterImage";
NSMutableDictionary<NSString *, UIImage *> *_capturedScreenshotsByName;
}
+ (IntegrationTestPlugin *)instance {
+ (instancetype)instance {
static dispatch_once_t onceToken;
static IntegrationTestPlugin *sInstance;
dispatch_once(&onceToken, ^{
......@@ -45,19 +45,9 @@ static NSString *const kMethodRevertImage = @"revertFlutterImage";
}
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
// No initialization happens here because of the way XCTest loads the testing
// bundles. Setup on static variables can be disregarded when a new static
// instance of IntegrationTestPlugin is allocated when the bundle is reloaded.
// 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];
}];
FlutterMethodChannel *channel = [FlutterMethodChannel methodChannelWithName:kIntegrationTestPluginChannel
binaryMessenger:registrar.messenger];
[registrar addMethodCallDelegate:[self instance] channel:channel];
}
- (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