Skip to content

Commit 0644496

Browse files
fix tests with OCMock 3.6 (#5638)
1 parent 1db0457 commit 0644496

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

FirebaseMessaging/Tests/UnitTests/FIRMessagingClientTest.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ - (void)testDisconnectAfterConnect {
233233

234234
XCTestExpectation *setupConnection =
235235
[self expectationWithDescription:@"Fcm should successfully setup a connection"];
236+
XCTestExpectation *disconnected = [self expectationWithDescription:@"Fcm should disconnect"];
236237

237238
__block int timesConnected = 0;
238239
FIRMessagingConnectCompletionHandler handler = ^(NSError *error) {
@@ -243,11 +244,12 @@ - (void)testDisconnectAfterConnect {
243244
// disconnect the connection after some time
244245
FIRMessagingFakeConnection *fakeConnection =
245246
(FIRMessagingFakeConnection *)[self.mockClient connection];
246-
dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (0.2 * NSEC_PER_SEC));
247+
dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (0.5 * NSEC_PER_SEC));
247248
dispatch_after(time, dispatch_get_main_queue(), ^{
248249
// disconnect now
249250
[(FIRMessagingFakeConnection *)fakeConnection mockSocketDisconnect];
250251
[(FIRMessagingFakeConnection *)fakeConnection disconnectNow];
252+
[disconnected fulfill];
251253
});
252254
} else {
253255
XCTFail(@"Fcm should only connect at max 2 times");
@@ -258,12 +260,11 @@ - (void)testDisconnectAfterConnect {
258260
// reconnect after disconnect
259261
XCTAssertTrue(self.client.isConnectionActive);
260262

261-
[self waitForExpectationsWithTimeout:10.0
262-
handler:^(NSError *error) {
263-
XCTAssertNil(error);
264-
XCTAssertNotEqual(self.client.lastDisconnectedTimestamp, 0);
265-
XCTAssertTrue(self.client.isConnectionActive);
266-
}];
263+
[self waitForExpectations:@[ setupConnection ] timeout:2];
264+
XCTAssertNotEqual(self.client.lastDisconnectedTimestamp, 0);
265+
XCTAssertTrue(self.client.isConnectionActive);
266+
[self waitForExpectations:@[ disconnected ] timeout:2];
267+
XCTAssertFalse(self.client.isConnectionActive);
267268
}
268269

269270
#pragma mark - Private Helpers

0 commit comments

Comments
 (0)