Skip to content
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
21c351b
make FCM/IID compitable with MacOS
charlotteliang Apr 19, 2019
889c4e4
fix the TARGET typo
charlotteliang Apr 20, 2019
28e9b16
add macOS test app for messaging/instanceID, also add macOS unit test…
charlotteliang Apr 23, 2019
6ed2441
update the license of new files
charlotteliang Apr 23, 2019
f8ad4fb
update podfile
charlotteliang Apr 23, 2019
7b29c78
fix licence for iid mac test app too
charlotteliang Apr 23, 2019
71bebc2
fix couple of warnings
charlotteliang Apr 23, 2019
f850eb0
fix travis breakage
charlotteliang Apr 23, 2019
d6a779a
remove my own sign certificate
charlotteliang Apr 23, 2019
3d63811
fix sigining error
charlotteliang Apr 24, 2019
fd80801
Merge remote-tracking branch 'origin/master' into fcm-iid-macos
charlotteliang Apr 24, 2019
78d9892
fix the deprecation warining, add the new method when os version is a…
charlotteliang Apr 25, 2019
9619f07
remove the deprecation warning
charlotteliang Apr 26, 2019
006f317
add GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1
charlotteliang Apr 26, 2019
9d6eeae
mac entitlement is different than iOS, update the path for mac; also …
charlotteliang May 6, 2019
a00a4d9
Merge remote-tracking branch 'origin/master' into fcm-iid-macos
charlotteliang May 6, 2019
89bd518
use GULApplicationDelegate; osx version should be 10.11
charlotteliang May 6, 2019
81d6841
now that GULAppDelegateSwizzler supports macOS, add it back to enable…
charlotteliang May 6, 2019
adcb66a
fix typo on TARGET_OS_TV
charlotteliang May 6, 2019
1108072
Merge remote-tracking branch 'origin/master' into fcm-iid-macos
charlotteliang May 20, 2019
d607a41
bump up the version of AppDelegateSwizzler
charlotteliang May 21, 2019
e0ea29c
remove NSApplication and unnecessary headers
charlotteliang May 21, 2019
0c7c5a1
use GULAppDelegateSwizzler sharedApplication instead
charlotteliang May 21, 2019
60ccf90
clean up more headers of UIKit
charlotteliang May 21, 2019
34d8fd8
expose more proxy tests for macos
charlotteliang May 22, 2019
864f2f4
fix trailing space
charlotteliang May 22, 2019
b870dc7
removing trailing space
charlotteliang May 22, 2019
24ad321
Merge remote-tracking branch 'origin/master' into fcm-iid-macos
charlotteliang May 22, 2019
aadc303
change the podfile from 10.14 to 10.11 for the mac targets
charlotteliang May 22, 2019
8df21f0
make sure all analytics related logic only run under ios, also make s…
charlotteliang May 22, 2019
68cbd1a
remove unnecessary headers and expose more tests to macOS
charlotteliang May 23, 2019
1b512dd
remove trailing space
charlotteliang May 24, 2019
91ad453
Merge remote-tracking branch 'origin/master' into fcm-iid-macos
charlotteliang May 24, 2019
62a90c7
[FIRMessagingRemoteNotificationsProxyTest testSwizzlingNonAppDelegate…
maksymmalyhin May 24, 2019
5bd0bf9
Merge branch 'fcm-iid-macos' of github.com:firebase/firebase-ios-sdk …
maksymmalyhin May 24, 2019
8443082
Merge branch 'fcm-iid-macos' of github.com:firebase/firebase-ios-sdk …
charlotteliang May 24, 2019
23869fd
add a tvOS support for one of the API
charlotteliang May 24, 2019
829426c
fix warning
charlotteliang May 24, 2019
6a1eb9f
merge master/origin
charlotteliang May 28, 2019
d003b77
remove empty macOS sample app for fcm/iid and merge fix the conflicts
charlotteliang May 29, 2019
e38f820
revert project and scheme files
charlotteliang May 29, 2019
bcbec24
merge conflicts
charlotteliang May 29, 2019
9154be0
update travis
charlotteliang May 29, 2019
fe9b665
always set Weak References in Manual Retain Release to true
charlotteliang May 29, 2019
8f857bd
fix warning in build
charlotteliang May 30, 2019
a378c49
run script/style.sh
charlotteliang May 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Example/InstanceID/Tests/FIRInstanceIDAuthKeyChainTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@

static NSString *const kAuthorizedEntity = @"test-audience";
static NSString *const kScope = @"test-scope";
static NSString *const kAuthID = @"test-auth-id";
static NSString *const kSecret = @"test-secret";

static NSString *const kToken1 =
@"dOr37DpYQ9M:APA91bE5aQ2expDEmoSNDDrZqS6drAz2V-GHJHEsa-qVdlHXVSlWpUsK-Ta6Oe1QsVSLovL7_"
@"rbm8GNnP7XPfwjtDQrjxYS1BdtxHdVVnQKuxlF3Z0QOwL380l1e1Fz91PX5b77XKj0FIyqzX1z0uJc0-pM6YcaPGg";
#if TARGET_OS_IOS || TARGET_OS_TV
static NSString *const kAuthID = @"test-auth-id";
static NSString *const kSecret = @"test-secret";
static NSString *const kToken2 = @"c8oEXUYIl3s:APA91bHtJMs_dZ2lXYXIcwsC47abYIuWhEJ_CshY2PJRjVuI_"
@"H659iYUwfmNNghnZVkCmeUdKDSrK8xqVb0PVHxyAW391Ynp2NchMB87kJWb3BS0z"
@"ud6Ej_xDES_oc353eFRvt0E6NXefDmrUCpBY8y89_1eVFFfiA";
#endif
static NSString *const kFirebaseAppID = @"abcdefg:ios:QrjxYS1BdtxHdVVnQKuxlF3Z0QO";

static NSString *const kBundleID1 = @"com.google.fcm.dev";
Expand Down Expand Up @@ -62,6 +65,8 @@ - (void)tearDown {
}

- (void)testKeyChainNoCorruptionWithUniqueAccount {
// macOS only support one service and one account.
#if TARGET_OS_IOS || TARGET_OS_TV
XCTestExpectation *noCurruptionExpectation =
[self expectationWithDescription:@"No corruption between different accounts."];
// Create a keychain with a service and a unique account
Expand Down Expand Up @@ -130,9 +135,11 @@ - (void)testKeyChainNoCorruptionWithUniqueAccount {
}];
}];
[self waitForExpectationsWithTimeout:1.0 handler:NULL];
#endif
}

- (void)testKeyChainNoCorruptionWithUniqueService {
#if TARGET_OS_IOS || TARGET_OS_TV
XCTestExpectation *noCurruptionExpectation =
[self expectationWithDescription:@"No corruption between different services."];
// Create a keychain with a service and a unique account
Expand Down Expand Up @@ -206,6 +213,7 @@ - (void)testKeyChainNoCorruptionWithUniqueService {
}];
}];
[self waitForExpectationsWithTimeout:1.0 handler:NULL];
#endif
}

- (void)testQueryCachedKeychainItems {
Expand Down
18 changes: 16 additions & 2 deletions Example/InstanceID/Tests/FIRInstanceIDKeyPairMigrationTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ - (void)testMigrationDataIfLegacyKeyPairsNotExist {
}

- (void)testMigrationIfLegacyKeyPairsExist {
// Legacy keypair should only exist in iOS/tvOS.
#if TARGET_OS_IOS || TARGET_OS_TV
XCTestExpectation *migrationCompleteExpectation =
[self expectationWithDescription:@"migration should be done"];
XCTestExpectation *deletionCompleteExpectation =
[self expectationWithDescription:@"keychain should be cleared"];
// create legacy key pairs
NSString *legacyPublicKeyTag =
FIRInstanceIDLegacyPublicTagWithSubtype(kFIRInstanceIDKeyPairSubType);
Expand Down Expand Up @@ -131,19 +135,28 @@ - (void)testMigrationIfLegacyKeyPairsExist {
XCTAssertEqualObjects(keyPair.publicKeyData, keyPair2.publicKeyData);
XCTAssertEqualObjects(keyPair.privateKeyData, keyPair2.privateKeyData);

// Clear the legacy data after tests
// Clear the keychain data after tests
[FIRInstanceIDKeyPairStore deleteKeyPairWithPrivateTag:legacyPrivateKeyTag
publicTag:legacyPublicKeyTag
handler:^(NSError *error) {
XCTAssertNil(error);
[migrationCompleteExpectation fulfill];
}];
[FIRInstanceIDKeyPairStore deleteKeyPairWithPrivateTag:privateKeyTag
publicTag:publicKeyTag
handler:^(NSError *error) {
XCTAssertNil(error);
[deletionCompleteExpectation fulfill];
}];
}];

[self waitForExpectationsWithTimeout:1 handler:nil];
[self waitForExpectations:@[ migrationCompleteExpectation, deletionCompleteExpectation ]
timeout:10.0];
#endif
}

- (void)testUpdateKeyRefWithTagRetainsAndReleasesKeyRef {
#if TARGET_OS_IOS || TARGET_OS_TV
__weak id weakKeyRef;

// Use a local autorelease pool to make sure any autorelease objects allocated will be released.
Expand All @@ -170,6 +183,7 @@ - (void)testUpdateKeyRefWithTagRetainsAndReleasesKeyRef {
// The check below is flaky for build under DEBUG (petentially due to ARC specifics).
// Comment it so far as not-so-important one.
// XCTAssertNil(weakKeyRef);
#endif
}

- (SecKeyRef)generateKeyRef {
Expand Down
4 changes: 3 additions & 1 deletion Example/InstanceID/Tests/FIRInstanceIDKeyPairStoreTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,15 @@ - (void)testAppIdentity {
* should be successfull and return the same keyPair.
*/
- (void)testKeyPairCache {
// TODO: figure out why same query doesn't work for macOS.
#if TARGET_OS_IOS || TARGET_OS_TV
NSError *error;

FIRInstanceIDKeyPair *keyPair1 =
[self.keyPairStore generateAndSaveKeyWithSubtype:kFIRInstanceIDKeyPairSubType
creationTime:FIRInstanceIDCurrentTimestampInSeconds()
error:&error];
XCTAssertNotNil(keyPair1);

NSString *iid1 = FIRInstanceIDAppIdentity(keyPair1);

[NSThread sleepForTimeInterval:2.0];
Expand All @@ -205,6 +206,7 @@ - (void)testKeyPairCache {
NSString *iid2 = FIRInstanceIDAppIdentity(keyPair2);

XCTAssertEqualObjects(iid1, iid2);
#endif
}
/**
* Test that if the Keychain preferences does not store any KeyPair, trying to
Expand Down
6 changes: 6 additions & 0 deletions Example/Messaging/Tests/FIRMessagingAnalyticsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#import <FirebaseAnalyticsInterop/FIRInteropEventNames.h>
#import <FirebaseAnalyticsInterop/FIRInteropParameterNames.h>

// Analytics tracking is iOS only feature.
#if TARGET_OS_IOS
static NSString *const kFIRParameterLabel = @"label";
static NSString *const kReengagementSource = @"Firebase";
static NSString *const kReengagementMedium = @"notification";
Expand Down Expand Up @@ -409,6 +411,7 @@ - (void)testNoConversionTracking {
[FIRMessagingAnalytics logUserPropertyForConversionTracking:notification toAnalytics:analytics];
}


- (void)testLogMessage {
NSDictionary *notification = @{
@"google.c.a.e" : @"1",
Expand All @@ -417,6 +420,7 @@ - (void)testLogMessage {
OCMVerify([self.logClassMock logEvent:OCMOCK_ANY withNotification:notification toAnalytics:nil]);
}


- (void)testLogOpenNotification {
NSDictionary *notification = @{
@"google.c.a.e" : @"1",
Expand All @@ -430,3 +434,5 @@ - (void)testLogOpenNotification {
}

@end

#endif
22 changes: 9 additions & 13 deletions Example/Messaging/Tests/FIRMessagingExtensionHelperTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,26 @@
* limitations under the License.
*/

#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>

#import <OCMock/OCMock.h>

#import "FIRMessaging.h"
#import "FIRMessagingExtensionHelper.h"

API_AVAILABLE(ios(10.0))
API_AVAILABLE(macos(10.14), ios(10.0))
typedef void (^FIRMessagingContentHandler)(UNNotificationContent *content);

#if TARGET_OS_IOS
#if TARGET_OS_IOS || TARGET_OS_OSX
static NSString *const kFCMPayloadOptionsName = @"fcm_options";
static NSString *const kFCMPayloadOptionsImageURLName = @"image";
static NSString *const kValidImageURL =
@"https://firebasestorage.googleapis.com/v0/b/fcm-ios-f7f9c.appspot.com/o/"
@"chubbyBunny.jpg?alt=media&token=d6c56a57-c007-4b27-b20f-f267cc83e9e5";
#endif

@interface FIRMessagingExtensionHelper (ExposedForTest)
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0

- (void)loadAttachmentForURL:(NSURL *)attachmentURL
completionHandler:(void (^)(UNNotificationAttachment *))completionHandler;
#endif
@end

@interface FIRMessagingExtensionHelperTest : XCTestCase {
Expand All @@ -49,7 +45,7 @@ @implementation FIRMessagingExtensionHelperTest

- (void)setUp {
[super setUp];
if (@available(iOS 10.0, *)) {
if (@available(macOS 10.14, iOS 10.0, *)) {
FIRMessagingExtensionHelper *extensionHelper = [FIRMessaging extensionHelper];
_mockExtensionHelper = OCMPartialMock(extensionHelper);
} else {
Expand All @@ -61,11 +57,10 @@ - (void)tearDown {
[_mockExtensionHelper stopMocking];
}

#if TARGET_OS_IOS
#ifdef COCOAPODS
// This test requires internet access.
- (void)testModifyNotificationWithValidPayloadData {
if (@available(iOS 10.0, *)) {
if (@available(macOS 10.14, iOS 10.0, *)) {
XCTestExpectation *validPayloadExpectation =
[self expectationWithDescription:@"Test payload is valid."];
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
Expand All @@ -82,7 +77,7 @@ - (void)testModifyNotificationWithValidPayloadData {
#endif

- (void)testModifyNotificationWithInvalidPayloadData {
if (@available(iOS 10.0, *)) {
if (@available(macOS 10.14, iOS 10.0, *)) {
XCTestExpectation *validPayloadExpectation =
[self expectationWithDescription:@"Test payload is valid."];
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
Expand All @@ -100,7 +95,7 @@ - (void)testModifyNotificationWithInvalidPayloadData {
}

- (void)testModifyNotificationWithEmptyPayloadData {
if (@available(iOS 10.0, *)) {
if (@available(macOS 10.14, iOS 10.0, *)) {
XCTestExpectation *validPayloadExpectation =
[self expectationWithDescription:@"Test payload is valid."];
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
Expand All @@ -115,6 +110,7 @@ - (void)testModifyNotificationWithEmptyPayloadData {
[self waitForExpectationsWithTimeout:1.0 handler:nil];
}
}
#endif // TARGET_OS_IOS

@end
#endif

Loading