Skip to content

Commit

Permalink
Address formatting and indicate designated initializer in GIDFakeMain…
Browse files Browse the repository at this point in the history
…Bundle.
  • Loading branch information
brnnmrls committed May 9, 2024
1 parent 51c5a36 commit 6ce9f10
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ typedef void (^GIDVerifyCompletion)(GIDVerifiedAccountDetailResult *_Nullable ve
/// The active configuration for this instance of `GIDVerifyAccountDetail`.
@property(nonatomic, nullable) GIDConfiguration *configuration;

/// Initialize a `GIDVerifyAccountDetail` object by specifying all available properties.
///
/// @param config The configuration to be used.
/// @return An initialized `GIDVerifyAccountDetail` instance.
- (instancetype)initWithConfig:(nullable GIDConfiguration *)config
NS_DESIGNATED_INITIALIZER;
NS_DESIGNATED_INITIALIZER;

/// Starts an interactive verification flow.
///
Expand Down
3 changes: 2 additions & 1 deletion GoogleSignIn/Tests/Unit/GIDFakeMainBundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
- (nullable instancetype)initWithClientID:(nullable id)clientID
serverClientID:(nullable id)serverClientID
hostedDomain:(nullable id)hostedDomain
openIDRealm:(nullable id)openIDRealm;
openIDRealm:(nullable id)openIDRealm
NS_DESIGNATED_INITIALIZER;

/**
* @fn startFaking:
Expand Down
7 changes: 7 additions & 0 deletions GoogleSignIn/Tests/Unit/GIDFakeMainBundle.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ - (nullable instancetype)initWithClientID:(nullable id)clientID
return self;
}

- (instancetype)init {
return [self initWithClientID:nil
serverClientID:nil
hostedDomain:nil
openIDRealm:nil];
}

- (void)startFaking {
_fakedKeys = @[ kCFBundleURLTypesKey,
kConfigClientIDKey,
Expand Down
2 changes: 2 additions & 0 deletions GoogleSignIn/Tests/Unit/GIDSignInTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ - (void)setUp {
#elif TARGET_OS_OSX
_presentingWindow = OCMStrictClassMock([NSWindow class]);
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST

// TODO: Fix strict mocks from carrying forward to subsequent tests. (#410)
_authState = OCMClassMock([OIDAuthState class]);
OCMStub([_authState alloc]).andReturn(_authState);
OCMStub([_authState initWithAuthorizationResponse:OCMOCK_ANY]).andReturn(_authState);
Expand Down
18 changes: 11 additions & 7 deletions GoogleSignIn/Tests/Unit/GIDVerifyAccountDetailTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@
static NSString * const kFakeHostedDomain = @"fakehosteddomain.com";

@interface GIDVerifyAccountDetailTests : XCTestCase
// The |UIViewController| object being tested.
/// The |UIViewController| object being tested.
@property UIViewController *presentingViewController;

// Fake [NSBundle mainBundle].
/// Fake [NSBundle mainBundle].
@property GIDFakeMainBundle *fakeMainBundle;

// The |GIDVerifyAccountDetail| object being tested.
/// The |GIDVerifyAccountDetail| object being tested.
@property GIDVerifyAccountDetail *verifyAccountDetail;

// The list of account details when testing [GIDVerifiableAccountDetail].
/// The list of account details when testing [GIDVerifiableAccountDetail].
@property NSArray<GIDVerifiableAccountDetail *> *verifiableAccountDetails;
@end

Expand All @@ -75,6 +75,11 @@ - (void)setUp {
openIDRealm:kOpenIDRealm];
}

- (void)tearDown {
[_fakeMainBundle stopFaking];
[super tearDown];
}

#pragma mark - Tests

- (void)testInit {
Expand Down Expand Up @@ -129,8 +134,8 @@ - (void)testInitWithConfig_fullConfig {
hostedDomain:kFakeHostedDomain
openIDRealm:kOpenIDRealm];

GIDVerifyAccountDetail *verifyAccountDetail = [[GIDVerifyAccountDetail alloc]
initWithConfig:configuration];
GIDVerifyAccountDetail *verifyAccountDetail =
[[GIDVerifyAccountDetail alloc] initWithConfig:configuration];
XCTAssertNotNil(verifyAccountDetail.configuration);
XCTAssertEqual(verifyAccountDetail.configuration.clientID, kClientId);
XCTAssertEqual(verifyAccountDetail.configuration.serverClientID, kServerClientId);
Expand All @@ -144,7 +149,6 @@ - (void)testCurrentUserException {
_verifyAccountDetail.configuration = [[GIDConfiguration alloc] initWithClientID:nil];
#pragma GCC diagnostic pop

OIDAuthState *authState = [OIDAuthState testInstance];
GIDSignIn.sharedInstance.currentUser = nil;

@try {
Expand Down

0 comments on commit 6ce9f10

Please sign in to comment.