From 3bbe1e2459d12cbfbd48048d8793eca313c06db9 Mon Sep 17 00:00:00 2001 From: chliangGoogle Date: Thu, 25 Jan 2018 13:25:01 -0800 Subject: [PATCH 1/2] add unit test for auto init function --- Example/Messaging/Tests/FIRMessagingTest.m | 14 ++++++++++++++ Example/Messaging/Tests/Info.plist | 2 ++ 2 files changed, 16 insertions(+) diff --git a/Example/Messaging/Tests/FIRMessagingTest.m b/Example/Messaging/Tests/FIRMessagingTest.m index 09cdffc353b..86ed6470ce9 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 @@ @interface FIRMessaging () @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 @@ - (void)setUp { _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 @@ - (void)tearDown { [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 ba72822e872..4df9372a691 100644 --- a/Example/Messaging/Tests/Info.plist +++ b/Example/Messaging/Tests/Info.plist @@ -20,5 +20,7 @@ ???? CFBundleVersion 1 + FirebaseMessagingAutoInitEnabled + From c963b6bf5d23fe9beb15a8ab240cff58309d433f Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Thu, 25 Jan 2018 13:39:21 -0800 Subject: [PATCH 2/2] Add new attribute to Messaging test app --- Example/Messaging/App/iOS/Messaging-Info.plist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Example/Messaging/App/iOS/Messaging-Info.plist b/Example/Messaging/App/iOS/Messaging-Info.plist index e42f39d270b..b43105e2da5 100644 --- a/Example/Messaging/App/iOS/Messaging-Info.plist +++ b/Example/Messaging/App/iOS/Messaging-Info.plist @@ -2,6 +2,8 @@ + FirebaseMessagingAutoInitEnabled + CFBundleDevelopmentRegion en CFBundleDisplayName