Fix flaky FlutterChannelsTests, stop mocking NSObject (flutter/engine#41747)
I don't know why this is only flaking on arm64 Macs, but instead of mocking out `NSObject` which seems to continue to be mocked on some background thread, instead mock out the more-specific `FlutterTaskQueue` protocol. Turn the tests back on. Fixes https://github.com/flutter/flutter/issues/126013 Reverts https://github.com/flutter/engine/pull/41740 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -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
|
||||
@@ -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;
|
||||
@@ -218,7 +217,7 @@
|
||||
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
|
||||
@@ -246,7 +245,7 @@
|
||||
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
|
||||
@@ -283,7 +282,7 @@
|
||||
@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
|
||||
@@ -315,7 +314,7 @@
|
||||
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
|
||||
@@ -340,7 +339,7 @@
|
||||
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
|
||||
@@ -360,5 +359,3 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif // !defined(__arch64__) && !defined(__arm64__)
|
||||
|
||||
Reference in New Issue
Block a user