Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky FlutterChannelsTests, stop mocking NSObject #41747

Merged
merged 1 commit into from May 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2,10 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// These tests are flaky on arm64.
// TODO(dnfield): reenable after fixing https://github.com/flutter/flutter/issues/126013
#if !defined(__aarch64__) && !defined(__arm64__)

#if !__has_feature(objc_arc)
#error ARC must be enabled!
#endif
Expand All @@ -15,6 +11,9 @@
#import <OCMock/OCMock.h>
#import <XCTest/XCTest.h>

@protocol FlutterTaskQueue <NSObject>
@end

@interface MockBinaryMessenger : NSObject <FlutterBinaryMessenger>
@property(nonatomic, copy) NSString* channel;
@property(nonatomic, strong) NSData* message;
Expand Down Expand Up @@ -218,7 +217,7 @@ - (void)testBasicMessageChannelTaskQueue {
FlutterBinaryMessengerConnection connection = 123;
id binaryMessenger = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
id codec = OCMProtocolMock(@protocol(FlutterMethodCodec));
id taskQueue = OCMClassMock([NSObject class]);
id taskQueue = OCMProtocolMock(@protocol(FlutterTaskQueue));
FlutterBasicMessageChannel* channel =
[[FlutterBasicMessageChannel alloc] initWithName:channelName
binaryMessenger:binaryMessenger
Expand Down Expand Up @@ -246,7 +245,7 @@ - (void)testBasicMessageChannelInvokeHandlerAfterChannelReleased {
FlutterBinaryMessengerConnection connection = 123;
id binaryMessenger = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
id codec = OCMProtocolMock(@protocol(FlutterMessageCodec));
id taskQueue = OCMClassMock([NSObject class]);
id taskQueue = OCMProtocolMock(@protocol(FlutterTaskQueue));
FlutterBasicMessageChannel* channel =
[[FlutterBasicMessageChannel alloc] initWithName:channelName
binaryMessenger:binaryMessenger
Expand Down Expand Up @@ -283,7 +282,7 @@ - (void)testMethodChannelInvokeHandlerAfterChannelReleased {
@autoreleasepool {
id binaryMessenger = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
id codec = OCMProtocolMock(@protocol(FlutterMethodCodec));
id taskQueue = OCMClassMock([NSObject class]);
id taskQueue = OCMProtocolMock(@protocol(FlutterTaskQueue));
FlutterMethodChannel* channel = [[FlutterMethodChannel alloc] initWithName:channelName
binaryMessenger:binaryMessenger
codec:codec
Expand Down Expand Up @@ -315,7 +314,7 @@ - (void)testMethodChannelTaskQueue {
FlutterBinaryMessengerConnection connection = 123;
id binaryMessenger = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
id codec = OCMProtocolMock(@protocol(FlutterMethodCodec));
id taskQueue = OCMClassMock([NSObject class]);
id taskQueue = OCMProtocolMock(@protocol(FlutterTaskQueue));
FlutterMethodChannel* channel = [[FlutterMethodChannel alloc] initWithName:channelName
binaryMessenger:binaryMessenger
codec:codec
Expand All @@ -340,7 +339,7 @@ - (void)testEventChannelTaskQueue {
FlutterBinaryMessengerConnection connection = 123;
id binaryMessenger = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
id codec = OCMProtocolMock(@protocol(FlutterMethodCodec));
id taskQueue = OCMClassMock([NSObject class]);
id taskQueue = OCMProtocolMock(@protocol(FlutterTaskQueue));
id handler = OCMProtocolMock(@protocol(FlutterStreamHandler));
FlutterEventChannel* channel = [[FlutterEventChannel alloc] initWithName:channelName
binaryMessenger:binaryMessenger
Expand All @@ -360,5 +359,3 @@ - (void)testEventChannelTaskQueue {
}

@end

#endif // !defined(__arch64__) && !defined(__arm64__)