Skip to content

Commit 5306474

Browse files
adding unit test for auto init enable function (firebase#710)
1 parent 821fb90 commit 5306474

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

Example/Messaging/App/iOS/Messaging-Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>FirebaseMessagingAutoInitEnabled</key>
6+
<false/>
57
<key>CFBundleDevelopmentRegion</key>
68
<string>en</string>
79
<key>CFBundleDisplayName</key>

Example/Messaging/Tests/FIRMessagingTest.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#import "FIRMessaging.h"
2222
#import "FIRMessagingInstanceIDProxy.h"
23+
#import "FIRMessaging_Private.h"
2324

2425
extern NSString *const kFIRMessagingFCMTokenFetchAPNSOption;
2526

@@ -28,6 +29,7 @@ @interface FIRMessaging ()
2829
@property(nonatomic, readwrite, strong) NSString *defaultFcmToken;
2930
@property(nonatomic, readwrite, strong) NSData *apnsTokenData;
3031
@property(nonatomic, readwrite, strong) FIRMessagingInstanceIDProxy *instanceIDProxy;
32+
@property(nonatomic, readwrite, strong) NSUserDefaults *messagingUserDefaults;
3133

3234
- (instancetype)initPrivately;
3335
// Direct Channel Methods
@@ -52,6 +54,9 @@ - (void)setUp {
5254
_mockMessaging = OCMPartialMock(self.messaging);
5355
_mockInstanceIDProxy = OCMPartialMock(self.messaging.instanceIDProxy);
5456
self.messaging.instanceIDProxy = _mockInstanceIDProxy;
57+
[self.messaging.messagingUserDefaults removePersistentDomainForName:kFIRMessagingSuiteName];
58+
self.messaging.messagingUserDefaults =
59+
[[NSUserDefaults alloc] initWithSuiteName:kFIRMessagingSuiteName];
5560
}
5661

5762
- (void)tearDown {
@@ -60,6 +65,15 @@ - (void)tearDown {
6065
[super tearDown];
6166
}
6267

68+
- (void)testAutoInitEnableFlag {
69+
// Should read from Info.plist
70+
XCTAssertFalse(_messaging.isAutoInitEnabled);
71+
72+
// Now set the flag should overwrite Info.plist value.
73+
_messaging.autoInitEnabled = YES;
74+
XCTAssertTrue(_messaging.isAutoInitEnabled);
75+
}
76+
6377
#pragma mark - Direct Channel Establishment Testing
6478

6579
// Should connect with valid token and application in foreground

Example/Messaging/Tests/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
2222
<string>1</string>
23+
<key>FirebaseMessagingAutoInitEnabled</key>
24+
<false/>
2325
</dict>
2426
</plist>

0 commit comments

Comments
 (0)