diff options
author | Chen Liang <chliang@google.com> | 2018-01-25 13:44:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-25 13:44:22 -0800 |
commit | 53064743963d7e5cc12f7a42bb036814f5a6df17 (patch) | |
tree | 707d1ade4e7dc1d206c9bececd93257e5fe182fb /Example/Messaging/Tests | |
parent | 821fb909a3007f697ad96d83c6b8e8cc70df0b6b (diff) |
adding unit test for auto init enable function (#710)
Diffstat (limited to 'Example/Messaging/Tests')
-rw-r--r-- | Example/Messaging/Tests/FIRMessagingTest.m | 14 | ||||
-rw-r--r-- | Example/Messaging/Tests/Info.plist | 2 |
2 files changed, 16 insertions, 0 deletions
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> |