From 29dc3361f054c69a651d149d691f58206a4ae2c2 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 4 May 2023 15:58:12 -0700 Subject: [PATCH] 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 --- .../framework/Source/FlutterChannelsTest.m | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/common/framework/Source/FlutterChannelsTest.m b/engine/src/flutter/shell/platform/darwin/common/framework/Source/FlutterChannelsTest.m index 52e52de3dc..1bd2e7e2b7 100644 --- a/engine/src/flutter/shell/platform/darwin/common/framework/Source/FlutterChannelsTest.m +++ b/engine/src/flutter/shell/platform/darwin/common/framework/Source/FlutterChannelsTest.m @@ -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 #import +@protocol FlutterTaskQueue +@end + @interface MockBinaryMessenger : NSObject @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__)