-
Notifications
You must be signed in to change notification settings - Fork 248
Add fake for GIDProfileDataFetcher #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4c2172b
Add GIDProfileDataFetcher API, implementation and test.
Alex-4-Git 4d13ed2
Style improvement
Alex-4-Git 9996646
FIx the NS_DESIGNATED_INITIALIZER warning.
Alex-4-Git af9bdae
Add fake for GIDProfileDataFetcher.
Alex-4-Git cb17e5f
Use better name and fix style.
Alex-4-Git 8566e79
Improve wording.
Alex-4-Git 4ec4c44
Improve documentation.
Alex-4-Git 4920dfc
Merge branch 'refactorGSI' into pin-GIDProfileDataFetcher-new
Alex-4-Git 4ac5a72
Remove unused const.
Alex-4-Git f6beda2
Merge updates from GIDProfileDataFetcher implementation. Merge branch…
Alex-4-Git 3c9e883
Move the new GIDProfileData initializer to GIDProfileDataFetcher
Alex-4-Git ec79d8f
Merge branch 'pin-GIDProfileDataFetcher-new' into pin-GIDProfileDataF…
Alex-4-Git 163ab52
Add the fake for new method in GIDProfileDataFetcher.
Alex-4-Git 91e4cb1
Merge branch 'refactorGSI' into pin-GIDProfileDataFetcher-fake
Alex-4-Git 4da55e7
Improve documentation and style.
Alex-4-Git a81e1aa
Improve documentation and style.
Alex-4-Git File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
GoogleSignIn/Sources/GIDProfileDataFetcher/Implementations/Fakes/GIDFakeProfileDataFetcher.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Copyright 2023 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #import <Foundation/Foundation.h> | ||
|
|
||
| #import "GoogleSignIn/Sources/GIDProfileDataFetcher/API/GIDProfileDataFetcher.h" | ||
|
|
||
| @class GIDProfileData; | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /// The block type providing the response for user info request. | ||
| /// | ||
| /// @param profileData The `GIDProfileData` object returned on success. | ||
| /// @param error The error returned on failure. | ||
| typedef void (^GIDProfileDataFetcherFakeResponseProvider)(GIDProfileData *_Nullable profileData, | ||
| NSError *_Nullable error); | ||
|
|
||
| /// The block type setting up the response value. | ||
| /// | ||
| /// @param responseProvider The block which provides the response. | ||
| typedef void (^GIDProfileDataFetcherTestBlock)(GIDProfileDataFetcherFakeResponseProvider | ||
| responseProvider); | ||
|
|
||
| @interface GIDFakeProfileDataFetcher : NSObject <GIDProfileDataFetcher> | ||
|
|
||
| /// The test block to set up the response value. | ||
| @property(nonatomic) GIDProfileDataFetcherTestBlock testBlock; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
35 changes: 35 additions & 0 deletions
35
GoogleSignIn/Sources/GIDProfileDataFetcher/Implementations/Fakes/GIDFakeProfileDataFetcher.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #import "GoogleSignIn/Sources/GIDProfileDataFetcher/Implementations/Fakes/GIDFakeProfileDataFetcher.h" | ||
|
|
||
| #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDProfileData.h" | ||
|
|
||
| #ifdef SWIFT_PACKAGE | ||
| @import AppAuth; | ||
| #else | ||
| #import <AppAuth/AppAuth.h> | ||
| #endif | ||
|
|
||
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| @implementation GIDFakeProfileDataFetcher | ||
|
|
||
| - (void)fetchProfileDataWithAuthState:(OIDAuthState *)authState | ||
| completion:(void (^)(GIDProfileData *_Nullable profileData, | ||
| NSError *_Nullable error))completion { | ||
| NSAssert(self.testBlock != nil, @"Set the test block before invoking this method."); | ||
| self.testBlock(^(GIDProfileData *_Nullable profileData, NSError *_Nullable error) { | ||
| completion(profileData, error); | ||
| }); | ||
| } | ||
|
|
||
| - (nullable GIDProfileData *)fetchProfileDataWithIDToken:(OIDIDToken *)idToken { | ||
| NSAssert(self.testBlock != nil, @"Set the test block before invoking this method."); | ||
| __block GIDProfileData *profileDataToReturn; | ||
| self.testBlock(^(GIDProfileData *_Nullable profileData, NSError *_Nullable error) { | ||
| profileDataToReturn = profileData; | ||
| }); | ||
| return profileDataToReturn; | ||
| } | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.