Skip to content

Commit b619344

Browse files
authored
Merge pull request #108 from morganchen12/build-issues
DatabaseUI Tests: Road to green CI
2 parents fe24c52 + a100271 commit b619344

25 files changed

+1403
-324
lines changed

FirebaseUI.xcodeproj/project.pbxproj

Lines changed: 253 additions & 104 deletions
Large diffs are not rendered by default.

FirebaseUI/Auth/AuthProviderUI/Facebook/Source/FIRFacebookAuthUI.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,32 @@ NS_ASSUME_NONNULL_BEGIN
2828
/** @property appId
2929
@brief The Facebook App ID.
3030
*/
31-
@property(nonatomic, copy, readonly) NSString *appID;
31+
@property(nonatomic, readonly, copy) NSString *appID;
3232

3333
/** @property scopes
3434
@brief The scopes to use with Facebook Login.
3535
@remarks Defaults to using "email" scopes.
3636
*/
37-
@property(nonatomic, copy) NSArray<NSString *> *scopes;
37+
@property(nonatomic, readonly, copy) NSArray<NSString *> *scopes;
3838

3939
/** @fn init
4040
@brief Please use initWithAppId:
4141
*/
42-
- (nullable instancetype)init NS_UNAVAILABLE;
42+
- (instancetype)init NS_UNAVAILABLE;
4343

4444
/** @fn initWithAppID:
4545
@brief Conevenience initializer. Uses a default permission of `@[ "email" ]`.
4646
@param appID The Facebook App ID.
4747
*/
48-
- (nullable instancetype)initWithAppID:(NSString *)appID;
48+
- (instancetype)initWithAppID:(NSString *)appID;
4949

5050
/** @fn initWithAppID:permissions:
5151
@brief Designated initializer.
5252
@param appID The Facebook App ID.
5353
@param permissions The permissions of the app. This array must be an array of specific string values
5454
as defined in https://developers.facebook.com/docs/facebook-login/permissions/
5555
*/
56-
- (nullable instancetype)initWithAppID:(NSString *)appID permissions:(NSArray *)permissions NS_DESIGNATED_INITIALIZER;
56+
- (instancetype)initWithAppID:(NSString *)appID permissions:(NSArray *)permissions NS_DESIGNATED_INITIALIZER;
5757

5858
@end
5959

FirebaseUI/Auth/AuthProviderUI/Facebook/Source/FIRFacebookAuthUI.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ @implementation FIRFacebookAuthUI {
4949
FIRAuthProviderSignInCompletionBlock _pendingSignInCallback;
5050
}
5151

52-
- (nullable instancetype)init {
52+
- (instancetype)init {
5353
@throw [NSException exceptionWithName:@"Attempt to call unavailable initializer."
5454
reason:@"Please call the designated initializer."
5555
userInfo:nil];
5656
}
5757

58-
- (nullable instancetype)initWithAppID:(NSString *)appID permissions:(NSArray *)permissions {
58+
- (instancetype)initWithAppID:(NSString *)appID permissions:(NSArray *)permissions {
5959
self = [super init];
6060
if (self != nil) {
6161
_scopes = permissions;
@@ -65,7 +65,7 @@ - (nullable instancetype)initWithAppID:(NSString *)appID permissions:(NSArray *)
6565
return self;
6666
}
6767

68-
- (nullable instancetype)initWithAppID:(NSString *)appID {
68+
- (instancetype)initWithAppID:(NSString *)appID {
6969
return [self initWithAppID:appID permissions:@[ @"email" ]];
7070
}
7171

FirebaseUI/Auth/AuthProviderUI/Google/Source/FIRGoogleAuthUI.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,30 @@ NS_ASSUME_NONNULL_BEGIN
3232

3333
/** @property scopes
3434
@brief The scopes to use with Google Sign In.
35-
@remarks Defaults to using "email" and "profile" scopes.
35+
@remarks Defaults to using email and profile scopes. For a list of all scopes
36+
see https://developers.google.com/identity/protocols/googlescopes
3637
*/
37-
@property(nonatomic, copy) NSArray<NSString *> *scopes;
38+
@property(nonatomic, copy, readonly) NSArray<NSString *> *scopes;
3839

3940
/** @fn init
4041
@brief Please use initWithClientId:
4142
*/
42-
- (nullable instancetype)init NS_UNAVAILABLE;
43+
- (instancetype)init NS_UNAVAILABLE;
4344

4445
/** @fn initWithClientID:
45-
@brief Designated initializer.
46+
@brief Convenience initializer. Calls designated init with default
47+
scopes of "email" and "profile".
4648
@param clientId The Google Sign In client ID.
4749
*/
48-
- (nullable instancetype)initWithClientID:(NSString *)clientID NS_DESIGNATED_INITIALIZER;
50+
- (instancetype)initWithClientID:(NSString *)clientID;
51+
52+
/** @fn initWithClientID:scopes:
53+
@brief Designated initializer.
54+
@param clientId The Google Sign In client ID.
55+
@param scopes The user account scopes required by the app. A list of possible scopes can be
56+
found at https://developers.google.com/identity/protocols/googlescopes
57+
*/
58+
- (instancetype)initWithClientID:(NSString *)clientID scopes:(NSArray <NSString *> *)scopes NS_DESIGNATED_INITIALIZER;
4959

5060
@end
5161

FirebaseUI/Auth/AuthProviderUI/Google/Source/FIRGoogleAuthUI.m

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@
3131
*/
3232
static NSString *const kGooglePlusMeScope = @"https://www.googleapis.com/auth/plus.me";
3333

34-
/** @var kGooglePlusScopesPrefix
35-
@brief The OAuth scope string prefix for all scopes starting with "plus.".
34+
/** @var kGooglePlusMeScope
35+
@brief The OAuth scope string for the user's email scope.
36+
*/
37+
static NSString *const kGoogleUserInfoEmailScope = @"https://www.googleapis.com/auth/userinfo.email";
38+
39+
/** @var kGooglePlusMeScope
40+
@brief The OAuth scope string for the basic G+ profile information scope.
3641
*/
37-
static NSString *const kGooglePlusScopesPrefix = @"https://www.googleapis.com/auth/plus.";
42+
static NSString *const kGoogleUserInfoProfileScope = @"https://www.googleapis.com/auth/userinfo.profile";
3843

3944
/** @var kTableName
4045
@brief The name of the strings table to search for localized strings.
@@ -60,17 +65,22 @@ @implementation FIRGoogleAuthUI {
6065
FIRAuthProviderSignInCompletionBlock _pendingSignInCallback;
6166
}
6267

63-
- (nullable instancetype)init {
68+
- (instancetype)init {
6469
@throw [NSException exceptionWithName:@"Attempt to call unavailable initializer."
6570
reason:@"Please call the designated initializer."
6671
userInfo:nil];
6772
}
6873

69-
- (nullable instancetype)initWithClientID:(NSString *)clientID {
74+
- (instancetype)initWithClientID:(NSString *)clientID {
75+
return [self initWithClientID:clientID
76+
scopes:@[kGoogleUserInfoEmailScope, kGoogleUserInfoProfileScope]];
77+
}
78+
79+
- (instancetype)initWithClientID:(NSString *)clientID scopes:(NSArray *)scopes {
7080
self = [super init];
7181
if (self) {
7282
_clientID = [clientID copy];
73-
_scopes = @[ @"email", @"profile" ];
83+
_scopes = [scopes copy];
7484
}
7585
return self;
7686
}

FirebaseUI/Auth/AuthUI/Source/FIRAuthPickerViewController.xib

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
33
<dependencies>
4-
<deployment identifier="iOS"/>
54
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
65
</dependencies>
76
<objects>

FirebaseUI/Auth/AuthUI/Source/FIRAuthUI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ typedef void (^FIRAuthUIResultCallback)(FIRUser *_Nullable user, NSError *_Nulla
6767
@brief Gets the @c FIRAuthUI object for the default FirebaseApp.
6868
@remarks Thread safe.
6969
*/
70-
+ (nullable FIRAuthUI *)authUI NS_SWIFT_NAME(authUI());
70+
+ (nullable FIRAuthUI *)defaultAuthUI;
7171

7272
/** @fn authUIWithAuth:
7373
@brief Gets the @c FIRAuthUI instance for a @c FIRAuth.

FirebaseUI/Auth/AuthUI/Source/FIRAuthUI.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ - (nullable instancetype)initWithAuth:(FIRAuth *)auth NS_DESIGNATED_INITIALIZER;
4545

4646
@implementation FIRAuthUI
4747

48-
+ (nullable FIRAuthUI *)authUI {
48+
+ (nullable FIRAuthUI *)defaultAuthUI {
4949
FIRAuth *defaultAuth = [FIRAuth auth];
5050
if (!defaultAuth) {
5151
return nil;
@@ -54,6 +54,7 @@ + (nullable FIRAuthUI *)authUI {
5454
}
5555

5656
+ (nullable FIRAuthUI *)authUIWithAuth:(FIRAuth *)auth {
57+
NSParameterAssert(auth != nil);
5758
@synchronized (self) {
5859
// Let the FIRAuth instance retain the FIRAuthUI instance.
5960
FIRAuthUI *authUI = objc_getAssociatedObject(auth, &kAuthAssociationKey);
@@ -66,7 +67,7 @@ + (nullable FIRAuthUI *)authUIWithAuth:(FIRAuth *)auth {
6667
}
6768
}
6869

69-
- (nullable instancetype)initWithAuth:(FIRAuth *)auth {
70+
- (instancetype)initWithAuth:(FIRAuth *)auth {
7071
self = [super init];
7172
if (self) {
7273
_auth = auth;

FirebaseUI/Auth/AuthUI/Source/FIRAuthUIStrings.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ @implementation FIRAuthUIStrings
7575
@return Localized value of the string identified by the key.
7676
*/
7777
+ (NSString *)localizedStringForKey:(nonnull NSString *)key {
78-
NSBundle *customStringsBundle = [FIRAuthUI authUI].customStringsBundle;
78+
NSBundle *customStringsBundle = [FIRAuthUI defaultAuthUI].customStringsBundle;
7979
if (customStringsBundle) {
8080
NSString *localizedString = [customStringsBundle localizedStringForKey:key
8181
value:kKeyNotFound

FirebaseUI/Database/API/FirebaseArray.h

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,25 @@
1818

1919
// clang-format on
2020

21-
#import <Foundation/Foundation.h>
21+
@import Firebase;
2222

2323
#import "FirebaseArrayDelegate.h"
2424

2525
NS_ASSUME_NONNULL_BEGIN
2626

27-
@class FIRDatabaseQuery;
28-
@class FIRDatabaseReference;
29-
@class FIRDataSnapshot;
27+
@protocol FIRDataObservable
28+
@required
29+
30+
- (FIRDatabaseHandle)observeEventType:(FIRDataEventType)eventType
31+
andPreviousSiblingKeyWithBlock:(void (^)(FIRDataSnapshot *snapshot, NSString *__nullable prevKey))block
32+
withCancelBlock:(nullable void (^)(NSError* error))cancelBlock;
33+
34+
- (void)removeObserverWithHandle:(FIRDatabaseHandle)handle;
35+
36+
@end
37+
38+
@interface FIRDatabaseQuery (FIRDataObservable) <FIRDataObservable>
39+
@end
3040

3141
/**
3242
* FirebaseArray provides an array structure that is synchronized with a Firebase reference or
@@ -39,43 +49,36 @@ NS_ASSUME_NONNULL_BEGIN
3949
* The delegate object that array changes are surfaced to, which conforms to the
4050
* [FirebaseArrayDelegate Protocol](FirebaseArrayDelegate).
4151
*/
42-
@property(weak, nonatomic) id<FirebaseArrayDelegate> delegate;
52+
@property(weak, nonatomic, nullable) id<FirebaseArrayDelegate> delegate;
4353

4454
/**
4555
* The query on a Firebase reference that provides data to populate the instance of FirebaseArray.
4656
*/
47-
@property(strong, nonatomic) FIRDatabaseQuery *query;
57+
@property(strong, nonatomic) id<FIRDataObservable> query;
4858

4959
/**
50-
* The delegate object that array changes are surfaced to.
60+
* The number of objects in the FirebaseArray.
5161
*/
52-
@property(strong, nonatomic) NSMutableArray<FIRDataSnapshot *> * snapshots;
53-
54-
#pragma mark -
55-
#pragma mark Initializer methods
62+
@property(nonatomic, readonly) NSUInteger count;
5663

5764
/**
58-
* Intitalizes FirebaseArray with a standard Firebase reference.
59-
* @param ref The Firebase reference which provides data to FirebaseArray
60-
* @return The instance of FirebaseArray
65+
* The items currently in the FirebaseArray.
6166
*/
62-
- (instancetype)initWithRef:(FIRDatabaseReference *)ref;
67+
@property(nonatomic, readonly, copy) NSArray *items;
68+
69+
#pragma mark - Initializer methods
6370

6471
/**
65-
* Intitalizes FirebaseArray with a Firebase query (FIRDatabaseQuery).
66-
* @param query A query on a Firebase reference which provides filtered data to FirebaseArray
67-
* @return The instance of FirebaseArray
72+
* Initalizes FirebaseArray with a Firebase query (FIRDatabaseQuery) or database reference
73+
* (FIRDatabaseReference).
74+
* @param query A query or Firebase database reference
75+
* @return A FirebaseArray instance
6876
*/
69-
- (instancetype)initWithQuery:(FIRDatabaseQuery *)query;
77+
- (instancetype)initWithQuery:(id<FIRDataObservable>)query NS_DESIGNATED_INITIALIZER;
7078

71-
#pragma mark -
72-
#pragma mark Public API methods
79+
- (instancetype)init NS_UNAVAILABLE;
7380

74-
/**
75-
* Returns the count of objects in the FirebaseArray.
76-
* @return The count of objects in the FirebaseArray
77-
*/
78-
- (NSUInteger)count;
81+
#pragma mark - Public API methods
7982

8083
/**
8184
* Returns an object at a specific index in the FirebaseArray.
@@ -100,21 +103,16 @@ NS_ASSUME_NONNULL_BEGIN
100103

101104
/**
102105
* Support for subscripting. This method is unused and trying to write directly to the
103-
* array using subscripting will cause an assertion.
106+
* array using subscripting will cause an assertion failure.
104107
*/
105-
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx;
106-
107-
#pragma mark -
108-
#pragma mark Private API methods
108+
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx NS_UNAVAILABLE;
109109

110110
/**
111111
* Returns an index for a given object's key (that matches the object's key in the corresponding
112112
* Firebase reference).
113113
* @param key The key of the desired object
114-
* @return The index of the object for which the key matches or -1 if the key is null
115-
* @exception FirebaseArrayKeyNotFoundException Thrown when the desired key is not in the
116-
* FirebaseArray, likely indicating that the FirebaseArray is no longer being properly synchronized
117-
* with the Firebase database.
114+
* @return The index of the object for which the key matches or NSNotFound if the key is not found
115+
* @exception NSInvalidArgumentException Thrown when the `key` parameter is `nil`.
118116
*/
119117
- (NSUInteger)indexForKey:(NSString *)key;
120118

0 commit comments

Comments
 (0)