Skip to content

Commit c30a978

Browse files
committed
fix FirebaseUI unit tests
1 parent d0a7c07 commit c30a978

File tree

11 files changed

+3248
-6915
lines changed

11 files changed

+3248
-6915
lines changed

FirebaseAuthUI/FIRAuthUIUtils.m

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ + (NSBundle *)frameworkBundle {
2222
static NSBundle *frameworkBundle = nil;
2323
static dispatch_once_t predicate;
2424
dispatch_once(&predicate, ^{
25-
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
26-
NSString *frameworkBundlePath =
27-
[mainBundlePath stringByAppendingPathComponent:@"FirebaseAuthUIBundle.bundle"];
28-
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
29-
if (!frameworkBundle) {
30-
frameworkBundle = [NSBundle mainBundle];
31-
}
25+
frameworkBundle = [NSBundle bundleForClass:[self class]];
3226
});
3327
return frameworkBundle;
3428
}

FirebaseAuthUITests/FIRAuthUITest.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ @implementation FUILoginProvider
3333
- (NSString *)providerID { return @"provider id"; }
3434
- (NSString *)shortName { return @"login provider"; }
3535
- (NSString *)signInLabel { return @"sign in label"; }
36+
- (NSString *)accessToken { return @"accessToken"; }
37+
- (NSString *)idToken { return @"idToken"; }
3638

3739
- (UIImage *)icon {
3840
return [[UIImage alloc] init];

FirebaseAuthUITests/GoogleService-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<key>IS_SIGNIN_ENABLED</key>
3434
<true/>
3535
<key>GOOGLE_APP_ID</key>
36-
<string>google-app-id</string>
36+
<string>0:000000000000:ios:0000000000000000</string>
3737
<key>DATABASE_URL</key>
3838
<string>database-url</string>
3939
</dict>

FirebaseFacebookAuthUI/FIRFacebookAuthUI.m

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
#import <FBSDKLoginKit/FBSDKLoginKit.h>
2323
#import <FirebaseAuthUI/FIRAuthUIErrorUtils.h>
2424

25-
/** @var kBundleFileName
26-
@brief The name of the bundle containing Facebook auth provider assets/resources.
27-
*/
28-
static NSString *const kBundleFileName = @"FirebaseFacebookAuthUIBundle.bundle";
29-
3025
/** @var kTableName
3126
@brief The name of the strings table to search for localized strings.
3227
*/
@@ -80,13 +75,7 @@ + (NSBundle *)frameworkBundle {
8075
static NSBundle *frameworkBundle = nil;
8176
static dispatch_once_t predicate;
8277
dispatch_once(&predicate, ^{
83-
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
84-
NSString *frameworkBundlePath =
85-
[mainBundlePath stringByAppendingPathComponent:kBundleFileName];
86-
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
87-
if (!frameworkBundle) {
88-
frameworkBundle = [NSBundle mainBundle];
89-
}
78+
frameworkBundle = [NSBundle bundleForClass:[self class]];
9079
});
9180
return frameworkBundle;
9281
}
@@ -221,9 +210,9 @@ - (void)callbackWithCredential:(nullable FIRAuthCredential *)credential
221210
@brief Validates that Facebook SDK data was filled in Info.plist and creates Facebook login manager
222211
*/
223212
- (void)configureProvider {
224-
NSString *facebookAppId = [[NSBundle mainBundle] objectForInfoDictionaryKey:kFacebookAppId];
225-
NSString *facebookDisplayName =
226-
[[NSBundle mainBundle] objectForInfoDictionaryKey:kFacebookDisplayName];
213+
NSBundle *bundle = [[self class] frameworkBundle];
214+
NSString *facebookAppId = [bundle objectForInfoDictionaryKey:kFacebookAppId];
215+
NSString *facebookDisplayName = [bundle objectForInfoDictionaryKey:kFacebookDisplayName];
227216

228217
if (!(facebookAppId && facebookDisplayName)) {
229218
[NSException raise:NSInternalInconsistencyException
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Copyright (c) 2016 Google Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
#import <FirebaseFacebookAuthUI/FirebaseFacebookAuthUI.h>
18+
19+
@interface FIRFacebookAuthUITest : FIRFacebookAuthUI
20+
21+
@end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Copyright (c) 2016 Google Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
#import "FIRFacebookAuthUITest.h"
17+
18+
@implementation FIRFacebookAuthUITest
19+
20+
+ (NSBundle *)frameworkBundle {
21+
static NSBundle *frameworkBundle = nil;
22+
static dispatch_once_t predicate;
23+
dispatch_once(&predicate, ^{
24+
frameworkBundle = [NSBundle bundleForClass:[self class]];
25+
});
26+
return frameworkBundle;
27+
}
28+
@end

FirebaseFacebookAuthUITests/FirebaseFacebookAuthUITests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//
1616

1717
@import XCTest;
18-
#import <FirebaseFacebookAuthUI/FIRFacebookAuthUI.h>
18+
#import "FIRFacebookAuthUITest.h"
1919

2020
@interface FirebaseFacebookAuthUITests : XCTestCase
2121
@property (nonatomic, strong) FIRFacebookAuthUI *provider;
@@ -25,7 +25,7 @@ @implementation FirebaseFacebookAuthUITests
2525

2626
- (void)setUp {
2727
[super setUp];
28-
self.provider = [[FIRFacebookAuthUI alloc] initWithAppID:@"an id"];
28+
self.provider = [[FIRFacebookAuthUITest alloc] init];
2929
}
3030

3131
- (void)testItExists {

FirebaseFacebookAuthUITests/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@
1818
<string>????</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
21+
<key>FacebookAppID</key>
22+
<string>{your-app-id}</string>
23+
<key>FacebookDisplayName</key>
24+
<string>{your-app-name}</string>
2125
</dict>
2226
</plist>

FirebaseGoogleAuthUI/FIRGoogleAuthUI.m

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,7 @@ + (NSBundle *)frameworkBundle {
8787
static NSBundle *frameworkBundle = nil;
8888
static dispatch_once_t predicate;
8989
dispatch_once(&predicate, ^{
90-
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
91-
NSString *frameworkBundlePath =
92-
[mainBundlePath stringByAppendingPathComponent:@"FirebaseGoogleAuthUIBundle.bundle"];
93-
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
94-
if (!frameworkBundle) {
95-
frameworkBundle = [NSBundle mainBundle];
96-
}
90+
frameworkBundle = [NSBundle bundleForClass:[self class]];
9791
});
9892
return frameworkBundle;
9993
}

FirebaseTwitterAuthUI/FIRTwitterAuthUI.m

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
#import <TwitterKit/TwitterKit.h>
2020
#import "FIRTwitterAuthUI.h"
2121

22-
/** @var kBundleFileName
23-
@brief The name of the bundle containing Twitter auth provider assets/resources.
24-
*/
25-
static NSString *const kBundleFileName = @"FirebaseTwitterAuthUIBundle.bundle";
26-
2722
/** @var kTableName
2823
@brief The name of the strings table to search for localized strings.
2924
*/
@@ -44,13 +39,7 @@ + (NSBundle *)frameworkBundle {
4439
static NSBundle *frameworkBundle = nil;
4540
static dispatch_once_t predicate;
4641
dispatch_once(&predicate, ^{
47-
NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
48-
NSString *frameworkBundlePath =
49-
[mainBundlePath stringByAppendingPathComponent:kBundleFileName];
50-
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
51-
if (!frameworkBundle) {
52-
frameworkBundle = [NSBundle mainBundle];
53-
}
42+
frameworkBundle = [NSBundle bundleForClass:[self class]];
5443
});
5544
return frameworkBundle;
5645
}

0 commit comments

Comments
 (0)