Skip to content

Commit

Permalink
adding unit test for auto init enable function (firebase#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlotteliang authored Jan 25, 2018
1 parent 821fb90 commit 5306474
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Example/Messaging/App/iOS/Messaging-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
14 changes: 14 additions & 0 deletions Example/Messaging/Tests/FIRMessagingTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#import "FIRMessaging.h"
#import "FIRMessagingInstanceIDProxy.h"
#import "FIRMessaging_Private.h"

extern NSString *const kFIRMessagingFCMTokenFetchAPNSOption;

Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Example/Messaging/Tests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>FirebaseMessagingAutoInitEnabled</key>
<false/>
</dict>
</plist>

0 comments on commit 5306474

Please sign in to comment.