@@ -281,14 +281,14 @@ - (void)setUp {
281281 OCMStub ([_authorization initWithAuthState: OCMOCK_ANY]).andReturn (_authorization);
282282 _user = OCMStrictClassMock ([GIDGoogleUser class ]);
283283 _oidAuthorizationService = OCMStrictClassMock ([OIDAuthorizationService class ]);
284- OCMStub ([_oidAuthorizationService
285- presentAuthorizationRequest: OCMOCK_ANY
286- #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
287- presentingViewController:SAVE_TO_ARG_BLOCK(self->_savedPresentingViewController)
288- #elif TARGET_OS_OSX
289- presentingWindow:SAVE_TO_ARG_BLOCK(self->_savedPresentingWindow)
290- #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
291- callback: COPY_TO_ARG_BLOCK (self ->_savedAuthorizationCallback)]);
284+ // OCMStub([_oidAuthorizationService
285+ // presentAuthorizationRequest:OCMOCK_ANY
286+ // #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
287+ // presentingViewController:SAVE_TO_ARG_BLOCK(self->_savedPresentingViewController)
288+ // #elif TARGET_OS_OSX
289+ // presentingWindow:SAVE_TO_ARG_BLOCK(self->_savedPresentingWindow)
290+ // #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
291+ // callback:COPY_TO_ARG_BLOCK(self->_savedAuthorizationCallback)]);
292292 OCMStub ([self ->_oidAuthorizationService
293293 performTokenRequest: SAVE_TO_ARG_BLOCK (self ->_savedTokenRequest)
294294 callback: COPY_TO_ARG_BLOCK (self ->_savedTokenCallback)]);
@@ -595,12 +595,6 @@ - (void)testSignOut {
595595 XCTAssertNil ([_keychainHandler loadAuthState ]);
596596}
597597
598- - (void )testNotHandleWrongScheme {
599- XCTAssertFalse ([_signIn handleURL: [NSURL URLWithString: kWrongSchemeURL ]],
600- @" should not handle URL" );
601- XCTAssertFalse (_completionCalled, @" should not call delegate" );
602- }
603-
604598- (void )testNotHandleWrongPath {
605599 XCTAssertFalse ([_signIn handleURL: [NSURL URLWithString: kWrongPathURL ]], @" should not handle URL" );
606600 XCTAssertFalse (_completionCalled, @" should not call delegate" );
@@ -1038,8 +1032,8 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow
10381032 refreshToken: kRefreshToken
10391033 codeVerifier: nil
10401034 additionalParameters: tokenResponse.request.additionalParameters];
1041-
1042- // Simulate auth endpoint response
1035+
1036+ // Set the response for the auth endpoint.
10431037 GIDAuthorizationFlowProcessorTestBlock authorizationFlowTestBlock;
10441038 if (modalCancel) {
10451039 NSError *error = [NSError errorWithDomain: OIDGeneralErrorDomain
@@ -1057,29 +1051,17 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow
10571051 }
10581052 _authorizationFlowProcessor.testBlock = authorizationFlowTestBlock;
10591053
1060- // maybeFetchToken
1061- if (!(authError || modalCancel)) {
1062- [[[_authState expect ] andReturn: nil ] lastTokenResponse ];
1063- #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1064- // Corresponds to EMM support
1065- [[[_authState expect ] andReturn: authResponse] lastAuthorizationResponse ];
1066- #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1067- [[[_authState expect ] andReturn: nil ] lastTokenResponse ];
1068- [[[_authState expect ] andReturn: authResponse] lastAuthorizationResponse ];
1069- [[[_authState expect ] andReturn: authResponse] lastAuthorizationResponse ];
1070- }
1071-
10721054 // Set the response for `GIDProfileDataFetcher`.
1073- GIDProfileDataFetcherTestBlock testBlock = ^(GIDProfileDataFetcherFakeResponseProvider
1074- responseProvider) {
1075- GIDProfileData *profileData = [GIDProfileData testInstance ];
1076- responseProvider (profileData, nil );
1055+ GIDProfileDataFetcherTestBlock profileDataFetcherTestBlock =
1056+ ^(GIDProfileDataFetcherFakeResponseProvider responseProvider) {
1057+ GIDProfileData *profileData = [GIDProfileData testInstance ];
1058+ responseProvider (profileData, nil );
10771059 };
10781060
1079- _profileDataFetcher.testBlock = testBlock ;
1061+ _profileDataFetcher.testBlock = profileDataFetcherTestBlock ;
10801062
10811063 if (restoredSignIn) {
1082- // maybeFetchToken
1064+ // Mock ` maybeFetchToken:` method in `restorePreviousSignIn:` flow.
10831065 [[[_authState expect ] andReturn: tokenResponse] lastTokenResponse ];
10841066 [[[_authState expect ] andReturn: tokenResponse] lastTokenResponse ];
10851067 if (oldAccessToken) {
@@ -1115,6 +1097,18 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow
11151097#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
11161098 completion: completion];
11171099 } else {
1100+ // Mock `maybeFetchToken:` method in Sign in flow.
1101+ if (!(authError || modalCancel)) {
1102+ [[[_authState expect ] andReturn: nil ] lastTokenResponse ];
1103+ #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1104+ // Corresponds to EMM support
1105+ [[[_authState expect ] andReturn: authResponse] lastAuthorizationResponse ];
1106+ #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
1107+ [[[_authState expect ] andReturn: nil ] lastTokenResponse ];
1108+ [[[_authState expect ] andReturn: authResponse] lastAuthorizationResponse ];
1109+ [[[_authState expect ] andReturn: authResponse] lastAuthorizationResponse ];
1110+ }
1111+
11181112#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
11191113 [_signIn signInWithPresentingViewController: _presentingViewController
11201114#elif TARGET_OS_OSX
@@ -1123,21 +1117,11 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow
11231117 hint: _hint
11241118 completion: completion];
11251119 }
1126-
1127- [_authState verify ];
1128-
1129- XCTAssertNotNil (_savedAuthorizationCallback);
1130-
1131- #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
1132- XCTAssertEqual (_savedPresentingViewController, _presentingViewController);
1133- #elif TARGET_OS_OSX
1134- XCTAssertEqual (_savedPresentingWindow, _presentingWindow);
1135- #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
1136-
11371120
11381121 if (authError || modalCancel) {
11391122 return ;
11401123 }
1124+
11411125 [_authState verify ];
11421126 }
11431127
0 commit comments