aboutsummaryrefslogtreecommitdiffhomepage
path: root/Example
diff options
context:
space:
mode:
authorGravatar Chen Liang <chliang@google.com>2018-01-25 13:44:22 -0800
committerGravatar GitHub <noreply@github.com>2018-01-25 13:44:22 -0800
commit53064743963d7e5cc12f7a42bb036814f5a6df17 (patch)
tree707d1ade4e7dc1d206c9bececd93257e5fe182fb /Example
parent821fb909a3007f697ad96d83c6b8e8cc70df0b6b (diff)
adding unit test for auto init enable function (#710)
Diffstat (limited to 'Example')
-rw-r--r--Example/Messaging/App/iOS/Messaging-Info.plist2
-rw-r--r--Example/Messaging/Tests/FIRMessagingTest.m14
-rw-r--r--Example/Messaging/Tests/Info.plist2
3 files changed, 18 insertions, 0 deletions
diff --git a/Example/Messaging/App/iOS/Messaging-Info.plist b/Example/Messaging/App/iOS/Messaging-Info.plist
index e42f39d..b43105e 100644
--- a/Example/Messaging/App/iOS/Messaging-Info.plist
+++ b/Example/Messaging/App/iOS/Messaging-Info.plist
@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>FirebaseMessagingAutoInitEnabled</key>
+ <false/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
diff --git a/Example/Messaging/Tests/FIRMessagingTest.m b/Example/Messaging/Tests/FIRMessagingTest.m
index 09cdffc..86ed647 100644
--- a/Example/Messaging/Tests/FIRMessagingTest.m
+++ b/Example/Messaging/Tests/FIRMessagingTest.m
@@ -20,6 +20,7 @@
#import "FIRMessaging.h"
#import "FIRMessagingInstanceIDProxy.h"
+#import "FIRMessaging_Private.h"
extern NSString *const kFIRMessagingFCMTokenFetchAPNSOption;
@@ -28,6 +29,7 @@ extern NSString *const kFIRMessagingFCMTokenFetchAPNSOption;
@property(nonatomic, readwrite, strong) NSString *defaultFcmToken;
@property(nonatomic, readwrite, strong) NSData *apnsTokenData;
@property(nonatomic, readwrite, strong) FIRMessagingInstanceIDProxy *instanceIDProxy;
+@property(nonatomic, readwrite, strong) NSUserDefaults *messagingUserDefaults;
- (instancetype)initPrivately;
// Direct Channel Methods
@@ -52,6 +54,9 @@ extern NSString *const kFIRMessagingFCMTokenFetchAPNSOption;
_mockMessaging = OCMPartialMock(self.messaging);
_mockInstanceIDProxy = OCMPartialMock(self.messaging.instanceIDProxy);
self.messaging.instanceIDProxy = _mockInstanceIDProxy;
+ [self.messaging.messagingUserDefaults removePersistentDomainForName:kFIRMessagingSuiteName];
+ self.messaging.messagingUserDefaults =
+ [[NSUserDefaults alloc] initWithSuiteName:kFIRMessagingSuiteName];
}
- (void)tearDown {
@@ -60,6 +65,15 @@ extern NSString *const kFIRMessagingFCMTokenFetchAPNSOption;
[super tearDown];
}
+- (void)testAutoInitEnableFlag {
+ // Should read from Info.plist
+ XCTAssertFalse(_messaging.isAutoInitEnabled);
+
+ // Now set the flag should overwrite Info.plist value.
+ _messaging.autoInitEnabled = YES;
+ XCTAssertTrue(_messaging.isAutoInitEnabled);
+}
+
#pragma mark - Direct Channel Establishment Testing
// Should connect with valid token and application in foreground
diff --git a/Example/Messaging/Tests/Info.plist b/Example/Messaging/Tests/Info.plist
index ba72822..4df9372 100644
--- a/Example/Messaging/Tests/Info.plist
+++ b/Example/Messaging/Tests/Info.plist
@@ -20,5 +20,7 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
+ <key>FirebaseMessagingAutoInitEnabled</key>
+ <false/>
</dict>
</plist>