Skip to content

Commit

Permalink
Revert "Started waiting for the notifications locally before assertin…
Browse files Browse the repository at this point in the history
…g side effects (#25226)" (#25248)

This reverts commit 8726c78.
  • Loading branch information
gaaclarke committed Mar 25, 2021
1 parent afab588 commit 7e18491
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 31 deletions.
Expand Up @@ -87,24 +87,17 @@ - (void)testCallsNotifyLowMemory {
OCMVerify([mockEngine notifyLowMemory]);
OCMReject([mockEngine notifyLowMemory]);

XCTNSNotificationExpectation* memoryExpectation = [[XCTNSNotificationExpectation alloc]
initWithName:UIApplicationDidReceiveMemoryWarningNotification];
[[NSNotificationCenter defaultCenter]
postNotificationName:UIApplicationDidReceiveMemoryWarningNotification
object:nil];
[self waitForExpectations:@[ memoryExpectation ] timeout:5.0];
OCMVerify([mockEngine notifyLowMemory]);
OCMReject([mockEngine notifyLowMemory]);

XCTNSNotificationExpectation* backgroundExpectation = [[XCTNSNotificationExpectation alloc]
initWithName:UIApplicationDidEnterBackgroundNotification];
[[NSNotificationCenter defaultCenter]
postNotificationName:UIApplicationDidEnterBackgroundNotification
object:nil];
[self waitForExpectations:@[ backgroundExpectation ] timeout:5.0];

OCMVerify([mockEngine notifyLowMemory]);
[mockEngine stopMocking];
}

@end
Expand Up @@ -11,6 +11,7 @@
FLUTTER_ASSERT_ARC

@interface FlutterPluginAppLifeCycleDelegateTest : XCTestCase

@end

@implementation FlutterPluginAppLifeCycleDelegateTest
Expand All @@ -21,71 +22,51 @@ - (void)testCreate {
}

- (void)testDidEnterBackground {
XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc]
initWithName:UIApplicationDidEnterBackgroundNotification];
FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc] init];
id plugin = OCMProtocolMock(@protocol(FlutterPlugin));
[delegate addDelegate:plugin];
[[NSNotificationCenter defaultCenter]
postNotificationName:UIApplicationDidEnterBackgroundNotification
object:nil];

[self waitForExpectations:@[ expectation ] timeout:5.0];
OCMVerify([plugin applicationDidEnterBackground:[UIApplication sharedApplication]]);
}

- (void)testWillEnterForeground {
XCTNSNotificationExpectation* expectation = [[XCTNSNotificationExpectation alloc]
initWithName:UIApplicationWillEnterForegroundNotification];

FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc] init];
id plugin = OCMProtocolMock(@protocol(FlutterPlugin));
[delegate addDelegate:plugin];
[[NSNotificationCenter defaultCenter]
postNotificationName:UIApplicationWillEnterForegroundNotification
object:nil];
[self waitForExpectations:@[ expectation ] timeout:5.0];
OCMVerify([plugin applicationWillEnterForeground:[UIApplication sharedApplication]]);
}

- (void)testWillResignActive {
XCTNSNotificationExpectation* expectation =
[[XCTNSNotificationExpectation alloc] initWithName:UIApplicationWillResignActiveNotification];

- (void)skip_testWillResignActive {
FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc] init];
id plugin = OCMProtocolMock(@protocol(FlutterPlugin));
[delegate addDelegate:plugin];
[[NSNotificationCenter defaultCenter]
postNotificationName:UIApplicationWillResignActiveNotification
object:nil];
[self waitForExpectations:@[ expectation ] timeout:5.0];
OCMVerify([plugin applicationWillResignActive:[UIApplication sharedApplication]]);
}

- (void)testDidBecomeActive {
XCTNSNotificationExpectation* expectation =
[[XCTNSNotificationExpectation alloc] initWithName:UIApplicationDidBecomeActiveNotification];

- (void)skip_testDidBecomeActive {
FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc] init];
id plugin = OCMProtocolMock(@protocol(FlutterPlugin));
[delegate addDelegate:plugin];
[[NSNotificationCenter defaultCenter]
postNotificationName:UIApplicationDidBecomeActiveNotification
object:nil];
[self waitForExpectations:@[ expectation ] timeout:5.0];
OCMVerify([plugin applicationDidBecomeActive:[UIApplication sharedApplication]]);
}

- (void)testWillTerminate {
XCTNSNotificationExpectation* expectation =
[[XCTNSNotificationExpectation alloc] initWithName:UIApplicationWillTerminateNotification];

FlutterPluginAppLifeCycleDelegate* delegate = [[FlutterPluginAppLifeCycleDelegate alloc] init];
id plugin = OCMProtocolMock(@protocol(FlutterPlugin));
[delegate addDelegate:plugin];
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification
object:nil];
[self waitForExpectations:@[ expectation ] timeout:5.0];
OCMVerify([plugin applicationWillTerminate:[UIApplication sharedApplication]]);
}

Expand Down
Expand Up @@ -885,8 +885,9 @@ - (void)testFlutterTokenizerCanParseLines {

- (void)testFlutterTextInputPluginRetainsFlutterTextInputView {
FlutterTextInputPlugin* myInputPlugin;
id myEngine = OCMClassMock([FlutterEngine class]);
myInputPlugin = [[FlutterTextInputPlugin alloc] init];
myInputPlugin.textInputDelegate = engine;
myInputPlugin.textInputDelegate = myEngine;
__weak UIView* activeView;
@autoreleasepool {
FlutterMethodCall* setClientCall = [FlutterMethodCall
Expand Down
Expand Up @@ -970,6 +970,5 @@ - (void)testAccessibilityMessageAfterDeletion {
});
latch.Wait();
OCMVerify([messenger cleanupConnection:connection]);
[engine stopMocking];
}
@end

0 comments on commit 7e18491

Please sign in to comment.