Skip to content

Commit 8061301

Browse files
charlotteliangpaulb777
authored andcommitted
File directory for tvOS should change from NSApplicationSupportDirector to NSCachesDirectory (#2496)
1 parent 37842fa commit 8061301

23 files changed

+147
-127
lines changed

Example/Firebase.xcodeproj/project.pbxproj

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@
124124
511DD27D2225C4D20094D78D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 511DD27C2225C4D20094D78D /* Assets.xcassets */; };
125125
511DD2802225C4D20094D78D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 511DD27F2225C4D20094D78D /* main.m */; };
126126
511DD2922225C8C40094D78D /* FIRInstanceIDWithFCMTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE8DB550221F5B470068BB0E /* FIRInstanceIDWithFCMTest.m */; };
127-
511DD2932225C8C40094D78D /* FIRMessagingFakeConnection.h in Sources */ = {isa = PBXBuildFile; fileRef = DE9315C81E8738B70083EDBF /* FIRMessagingFakeConnection.h */; };
128-
511DD2942225C8C40094D78D /* FIRMessagingFakeSocket.h in Sources */ = {isa = PBXBuildFile; fileRef = DE9315CA1E8738B70083EDBF /* FIRMessagingFakeSocket.h */; };
129-
511DD2952225C8C40094D78D /* FIRMessagingTestNotificationUtilities.h in Sources */ = {isa = PBXBuildFile; fileRef = DE9315D61E8738B70083EDBF /* FIRMessagingTestNotificationUtilities.h */; };
130127
511DD2962225C8C40094D78D /* FIRMessagingClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE9315C31E8738B70083EDBF /* FIRMessagingClientTest.m */; };
131128
511DD2972225C8C40094D78D /* FIRMessagingCodedInputStreamTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE9315C41E8738B70083EDBF /* FIRMessagingCodedInputStreamTest.m */; };
132129
511DD2982225C8C40094D78D /* FIRMessagingConnectionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE9315C51E8738B70083EDBF /* FIRMessagingConnectionTest.m */; };
@@ -147,8 +144,8 @@
147144
511DD2A72225C8C40094D78D /* FIRMessagingTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE9315D51E8738B70083EDBF /* FIRMessagingTest.m */; };
148145
511DD2A82225C8C40094D78D /* FIRMessagingTestNotificationUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = DE9315D71E8738B70083EDBF /* FIRMessagingTestNotificationUtilities.m */; };
149146
511DD2A92225C8C40094D78D /* FIRMessagingAnalyticsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE37C63A2163D5F30025D03E /* FIRMessagingAnalyticsTest.m */; };
150-
511DD2AA2225C8D50094D78D /* FIRMessagingTestUtilities.h in Sources */ = {isa = PBXBuildFile; fileRef = EDF5242A21EA364600BB24C6 /* FIRMessagingTestUtilities.h */; };
151147
511DD2AB2225C8D50094D78D /* FIRMessagingTestUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = EDF5242B21EA364600BB24C6 /* FIRMessagingTestUtilities.m */; };
148+
51559F8A2238B8DB00CFC32C /* FIRMessagingExtensionHelperTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5188550D2231E02300CA4141 /* FIRMessagingExtensionHelperTest.m */; };
152149
518854D92230652900CA4141 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 518854D82230652900CA4141 /* AppDelegate.m */; };
153150
518854DC2230652900CA4141 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 518854DB2230652900CA4141 /* ViewController.m */; };
154151
518854DF2230652900CA4141 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 518854DD2230652900CA4141 /* Main.storyboard */; };
@@ -177,7 +174,6 @@
177174
5188550A223067E900CA4141 /* FIRInstanceIDUtilitiesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE958BE121F7DF0C00E6C1C5 /* FIRInstanceIDUtilitiesTest.m */; };
178175
5188550C2230873000CA4141 /* FIRInstanceIDAPNSInfoTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE958BDA21F7DF0B00E6C1C5 /* FIRInstanceIDAPNSInfoTest.m */; };
179176
5188550E2231E02400CA4141 /* FIRMessagingExtensionHelperTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5188550D2231E02300CA4141 /* FIRMessagingExtensionHelperTest.m */; };
180-
518855112231E09300CA4141 /* FIRMessagingExtensionHelperTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 518855102231E09300CA4141 /* FIRMessagingExtensionHelperTest.m */; };
181177
7E21E0731F857DFC00D0AC1C /* FIROAuthProviderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E21E0721F857DFC00D0AC1C /* FIROAuthProviderTests.m */; };
182178
7E9485421F578AC4005A3939 /* FIRAuthURLPresenterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E94853F1F578A9D005A3939 /* FIRAuthURLPresenterTests.m */; };
183179
7EE21F7A1FE89193009B1370 /* FIREmailLinkRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7EE21F791FE89193009B1370 /* FIREmailLinkRequestTests.m */; };
@@ -1080,9 +1076,7 @@
10801076
518854E22230652B00CA4141 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
10811077
518854E32230652B00CA4141 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
10821078
518854EC223066BE00CA4141 /* InstanceID_Tests_tvOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InstanceID_Tests_tvOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
1083-
5188550D2231E02300CA4141 /* FIRMessagingExtensionHelperTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = FIRMessagingExtensionHelperTest.m; path = Messaging/Tests/FIRMessagingExtensionHelperTest.m; sourceTree = "<group>"; };
1084-
5188550F2231E04C00CA4141 /* FIRMessagingClientTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = FIRMessagingClientTest.m; path = Messaging/Tests/FIRMessagingClientTest.m; sourceTree = "<group>"; };
1085-
518855102231E09300CA4141 /* FIRMessagingExtensionHelperTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = FIRMessagingExtensionHelperTest.m; path = Messaging/Tests/FIRMessagingExtensionHelperTest.m; sourceTree = "<group>"; };
1079+
5188550D2231E02300CA4141 /* FIRMessagingExtensionHelperTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIRMessagingExtensionHelperTest.m; sourceTree = "<group>"; };
10861080
6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
10871081
6003F58F195388D20070C39A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
10881082
6003F591195388D20070C39A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
@@ -1919,9 +1913,6 @@
19191913
6003F581195388D10070C39A = {
19201914
isa = PBXGroup;
19211915
children = (
1922-
518855102231E09300CA4141 /* FIRMessagingExtensionHelperTest.m */,
1923-
5188550F2231E04C00CA4141 /* FIRMessagingClientTest.m */,
1924-
5188550D2231E02300CA4141 /* FIRMessagingExtensionHelperTest.m */,
19251916
60FF7A9C1954A5C5007DD14C /* Podspec Metadata */,
19261917
DE9314EB1E86C6FF0083EDBF /* Auth */,
19271918
DEE14D661E844677006FA992 /* Core */,
@@ -2547,6 +2538,7 @@
25472538
DE9315C21E8738B70083EDBF /* Tests */ = {
25482539
isa = PBXGroup;
25492540
children = (
2541+
5188550D2231E02300CA4141 /* FIRMessagingExtensionHelperTest.m */,
25502542
DE8DB550221F5B470068BB0E /* FIRInstanceIDWithFCMTest.m */,
25512543
DE9315C81E8738B70083EDBF /* FIRMessagingFakeConnection.h */,
25522544
DE9315CA1E8738B70083EDBF /* FIRMessagingFakeSocket.h */,
@@ -3798,6 +3790,7 @@
37983790
developmentRegion = English;
37993791
hasScannedForEncodings = 0;
38003792
knownRegions = (
3793+
English,
38013794
en,
38023795
Base,
38033796
"es-MX",
@@ -4305,14 +4298,10 @@
43054298
isa = PBXSourcesBuildPhase;
43064299
buildActionMask = 2147483647;
43074300
files = (
4308-
518855112231E09300CA4141 /* FIRMessagingExtensionHelperTest.m in Sources */,
4309-
511DD2AA2225C8D50094D78D /* FIRMessagingTestUtilities.h in Sources */,
4301+
511DD2962225C8C40094D78D /* FIRMessagingClientTest.m in Sources */,
4302+
51559F8A2238B8DB00CFC32C /* FIRMessagingExtensionHelperTest.m in Sources */,
43104303
511DD2AB2225C8D50094D78D /* FIRMessagingTestUtilities.m in Sources */,
43114304
511DD2922225C8C40094D78D /* FIRInstanceIDWithFCMTest.m in Sources */,
4312-
511DD2932225C8C40094D78D /* FIRMessagingFakeConnection.h in Sources */,
4313-
511DD2942225C8C40094D78D /* FIRMessagingFakeSocket.h in Sources */,
4314-
511DD2952225C8C40094D78D /* FIRMessagingTestNotificationUtilities.h in Sources */,
4315-
511DD2962225C8C40094D78D /* FIRMessagingClientTest.m in Sources */,
43164305
511DD2972225C8C40094D78D /* FIRMessagingCodedInputStreamTest.m in Sources */,
43174306
511DD2982225C8C40094D78D /* FIRMessagingConnectionTest.m in Sources */,
43184307
511DD2992225C8C40094D78D /* FIRMessagingContextManagerServiceTest.m in Sources */,

Example/InstanceID/Tests/FIRInstanceIDBackupExcludedPlistTest.m

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@ @implementation FIRInstanceIDBackupExcludedPlistTest
3838

3939
- (void)setUp {
4040
[super setUp];
41-
[FIRInstanceIDStore createApplicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
41+
[FIRInstanceIDStore createSubDirectory:kApplicationSupportSubDirectoryName];
4242
self.plist = [[FIRInstanceIDBackupExcludedPlist alloc]
43-
initWithFileName:kTestPlistFileName
44-
applicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
43+
initWithFileName:kTestPlistFileName
44+
subDirectory:kApplicationSupportSubDirectoryName];
4545
}
4646

4747
- (void)tearDown {
4848
[self.plist deleteFile:nil];
49-
[FIRInstanceIDStore removeApplicationSupportSubDirectory:kApplicationSupportSubDirectoryName
50-
error:nil];
49+
[FIRInstanceIDStore removeSubDirectory:kApplicationSupportSubDirectoryName error:nil];
5150
[super tearDown];
5251
}
5352

@@ -84,7 +83,7 @@ - (void)testWriteToPlistInApplicationSupportFolder {
8483
- (void)testMovePlistToApplicationSupportDirectorySuccess {
8584
NSDictionary *plistContents = @{@"hello" : @"world", @"id" : @123};
8685
[self.plist writeDictionary:plistContents error:nil];
87-
[self.plist moveToApplicationSupportSubDirectory];
86+
[self.plist moveToApplicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
8887
XCTAssertTrue([self isPlistInApplicationSupportDirectory]);
8988
XCTAssertFalse([self isPlistInDocumentsDirectory]);
9089

@@ -94,16 +93,18 @@ - (void)testMovePlistToApplicationSupportDirectorySuccess {
9493
}
9594

9695
- (void)testMovePlistToApplicationSupportDirectoryFailure {
96+
// This is to test moving data from deprecated document folder to application folder
97+
// which should only apply to iOS.
98+
#if TARGET_OS_IOS
9799
// Delete the subdirectory
98-
[FIRInstanceIDStore removeApplicationSupportSubDirectory:kApplicationSupportSubDirectoryName
99-
error:nil];
100+
[FIRInstanceIDStore removeSubDirectory:kApplicationSupportSubDirectoryName error:nil];
100101

101102
// Create a new plistl This would try to move or write to the ApplicationSupport directory
102103
// but since the subdirectory is not there anymore it will fail and rather write to the
103104
// Documents folder.
104105
self.plist = [[FIRInstanceIDBackupExcludedPlist alloc]
105-
initWithFileName:kTestPlistFileName
106-
applicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
106+
initWithFileName:kTestPlistFileName
107+
subDirectory:kApplicationSupportSubDirectoryName];
107108

108109
NSDictionary *plistContents = @{@"hello" : @"world", @"id" : @123};
109110
[self.plist writeDictionary:plistContents error:nil];
@@ -113,18 +114,25 @@ - (void)testMovePlistToApplicationSupportDirectoryFailure {
113114

114115
NSDictionary *newPlistContents = @{@"world" : @"hello"};
115116
[self.plist writeDictionary:newPlistContents error:nil];
117+
116118
XCTAssertEqualObjects(newPlistContents, [self.plist contentAsDictionary]);
117119

118120
// The new file should still be written to the Documents folder.
119121
XCTAssertFalse([self isPlistInApplicationSupportDirectory]);
120122
XCTAssertTrue([self isPlistInDocumentsDirectory]);
123+
#endif
121124
}
122125

123126
#pragma mark - Private Helpers
124127

125128
- (BOOL)isPlistInApplicationSupportDirectory {
129+
#if TARGET_OS_TV
130+
NSArray *directoryPaths =
131+
NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
132+
#else
126133
NSArray *directoryPaths =
127134
NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
135+
#endif
128136
NSString *applicationSupportDirPath = directoryPaths.lastObject;
129137
NSArray *components = @[
130138
applicationSupportDirPath, kApplicationSupportSubDirectoryName,

Example/InstanceID/Tests/FIRInstanceIDCheckinStoreTest.m

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ @implementation FIRInstanceIDCheckinStoreTest
5656

5757
- (void)setUp {
5858
[super setUp];
59-
[FIRInstanceIDStore createApplicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
59+
[FIRInstanceIDStore createSubDirectory:kApplicationSupportSubDirectoryName];
6060
}
6161

6262
- (void)tearDown {
@@ -65,8 +65,7 @@ - (void)tearDown {
6565
NSError *error;
6666
[[NSFileManager defaultManager] removeItemAtPath:path error:&error];
6767
}
68-
[FIRInstanceIDStore removeApplicationSupportSubDirectory:kApplicationSupportSubDirectoryName
69-
error:nil];
68+
[FIRInstanceIDStore removeSubDirectory:kApplicationSupportSubDirectoryName error:nil];
7069
[super tearDown];
7170
}
7271

@@ -77,8 +76,8 @@ - (void)testInvalidCheckinPreferencesOnKeychainFail {
7776
XCTestExpectation *checkinInvalidExpectation = [self
7877
expectationWithDescription:@"Checkin preference should be invalid after keychain failure"];
7978
FIRInstanceIDBackupExcludedPlist *checkinPlist = [[FIRInstanceIDBackupExcludedPlist alloc]
80-
initWithFileName:kFakeCheckinPlistName
81-
applicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
79+
initWithFileName:kFakeCheckinPlistName
80+
subDirectory:kApplicationSupportSubDirectoryName];
8281

8382
FIRInstanceIDFakeKeychain *fakeKeychain = [[FIRInstanceIDFakeKeychain alloc] init];
8483

@@ -110,8 +109,8 @@ - (void)testCheckinSaveFailsOnKeychainWriteFailure {
110109
XCTestExpectation *checkinSaveFailsExpectation =
111110
[self expectationWithDescription:@"Checkin save should fail after keychain write failure"];
112111
FIRInstanceIDBackupExcludedPlist *checkinPlist = [[FIRInstanceIDBackupExcludedPlist alloc]
113-
initWithFileName:kFakeCheckinPlistName
114-
applicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
112+
initWithFileName:kFakeCheckinPlistName
113+
subDirectory:kApplicationSupportSubDirectoryName];
115114

116115
FIRInstanceIDFakeKeychain *fakeKeychain = [[FIRInstanceIDFakeKeychain alloc] init];
117116
fakeKeychain.cannotWriteToKeychain = YES;
@@ -141,8 +140,8 @@ - (void)testCheckinMigrationMovesToNewLocationInKeychain {
141140
[self expectationWithDescription:@"checkin migration should move to the new location"];
142141
// Create checkin store class.
143142
FIRInstanceIDBackupExcludedPlist *checkinPlist = [[FIRInstanceIDBackupExcludedPlist alloc]
144-
initWithFileName:kFakeCheckinPlistName
145-
applicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
143+
initWithFileName:kFakeCheckinPlistName
144+
subDirectory:kApplicationSupportSubDirectoryName];
146145

147146
FIRInstanceIDFakeKeychain *fakeKeychain = [[FIRInstanceIDFakeKeychain alloc] init];
148147
FIRInstanceIDFakeKeychain *weakKeychain = fakeKeychain;

Example/InstanceID/Tests/FIRInstanceIDKeyPairStoreTest.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#import "Firebase/InstanceID/FIRInstanceIDConstants.h"
2121
#import "Firebase/InstanceID/FIRInstanceIDKeyPair.h"
2222
#import "Firebase/InstanceID/FIRInstanceIDKeychain.h"
23+
#import "Firebase/InstanceID/FIRInstanceIDStore.h"
2324

2425
#import <OCMock/OCMock.h>
2526
#import "Firebase/InstanceID/FIRInstanceIDKeyPair.h"
@@ -53,6 +54,10 @@ - (void)setUp {
5354
[super setUp];
5455
id mockStoreClass = OCMClassMock([FIRInstanceIDKeyPairStore class]);
5556
[[[mockStoreClass stub] andReturn:@"com.google.iid-keypairmanager-test"] keyStoreFileName];
57+
// Should make sure the standard directory is created.
58+
if (![FIRInstanceIDStore hasSubDirectory:kFIRInstanceIDSubDirectoryName]) {
59+
[FIRInstanceIDStore createSubDirectory:kFIRInstanceIDSubDirectoryName];
60+
}
5661
_keyPairStore = [[FIRInstanceIDKeyPairStore alloc] init];
5762
}
5863

Example/InstanceID/Tests/FIRInstanceIDStoreTest.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ @implementation FIRInstanceIDStoreTest
7474

7575
- (void)setUp {
7676
[super setUp];
77-
[FIRInstanceIDStore createApplicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
77+
[FIRInstanceIDStore createSubDirectory:kApplicationSupportSubDirectoryName];
7878

7979
NSString *checkinPlistName = @"com.google.test.IIDStoreTestCheckin";
8080
self.checkinPlist = [[FIRInstanceIDBackupExcludedPlist alloc]
81-
initWithFileName:checkinPlistName
82-
applicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
81+
initWithFileName:checkinPlistName
82+
subDirectory:kApplicationSupportSubDirectoryName];
8383

8484
// checkin store
8585
FIRInstanceIDFakeKeychain *fakeKeychain = [[FIRInstanceIDFakeKeychain alloc] init];
@@ -103,8 +103,7 @@ - (void)setUp {
103103
- (void)tearDown {
104104
[self.instanceIDStore removeAllCachedTokensWithHandler:nil];
105105
[self.instanceIDStore removeCheckinPreferencesWithHandler:nil];
106-
[FIRInstanceIDStore removeApplicationSupportSubDirectory:kApplicationSupportSubDirectoryName
107-
error:nil];
106+
[FIRInstanceIDStore removeSubDirectory:kApplicationSupportSubDirectoryName error:nil];
108107
[_mockCheckinStore stopMocking];
109108
[_mockTokenStore stopMocking];
110109
[_mockInstanceIDStore stopMocking];

Example/InstanceID/Tests/FIRInstanceIDTokenManagerTest.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ @implementation FIRInstanceIDTokenManagerTest
9191

9292
- (void)setUp {
9393
[super setUp];
94-
[FIRInstanceIDStore createApplicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
94+
[FIRInstanceIDStore createSubDirectory:kApplicationSupportSubDirectoryName];
9595

9696
NSString *checkinPlistFilename = @"com.google.test.IIDCheckinTest";
9797
self.checkinPlist = [[FIRInstanceIDBackupExcludedPlist alloc]
98-
initWithFileName:checkinPlistFilename
99-
applicationSupportSubDirectory:kApplicationSupportSubDirectoryName];
98+
initWithFileName:checkinPlistFilename
99+
subDirectory:kApplicationSupportSubDirectoryName];
100100

101101
// checkin store
102102
FIRInstanceIDFakeKeychain *fakeCheckinKeychain = [[FIRInstanceIDFakeKeychain alloc] init];
@@ -123,8 +123,7 @@ - (void)tearDown {
123123
}
124124

125125
self.tokenManager = nil;
126-
[FIRInstanceIDStore removeApplicationSupportSubDirectory:kApplicationSupportSubDirectoryName
127-
error:nil];
126+
[FIRInstanceIDStore removeSubDirectory:kApplicationSupportSubDirectoryName error:nil];
128127
[super tearDown];
129128
}
130129

Example/Messaging/Tests/FIRMessagingExtensionHelperTest.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ @implementation FIRMessagingExtensionHelperTest
4747

4848
- (void)setUp {
4949
[super setUp];
50-
FIRMessagingExtensionHelper *extensionHelper = [FIRMessaging extensionHelper];
50+
FIRMessagingExtensionHelper *extensionHelper = [[FIRMessagingExtensionHelper alloc] init];
5151
_mockExtensionHelper = OCMPartialMock(extensionHelper);
5252
}
5353

5454
- (void)tearDown {
5555
[_mockExtensionHelper stopMocking];
5656
}
5757

58-
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
5958
- (void)testModifyNotificationWithValidPayloadData {
59+
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
6060
XCTestExpectation *validPayloadExpectation =
6161
[self expectationWithDescription:@"Test payload is valid."];
6262

@@ -70,9 +70,11 @@ - (void)testModifyNotificationWithValidPayloadData {
7070
OCMVerify([_mockExtensionHelper loadAttachmentForURL:[OCMArg any]
7171
completionHandler:[OCMArg any]]);
7272
[self waitForExpectationsWithTimeout:1.0 handler:nil];
73+
#endif
7374
}
7475

7576
- (void)testModifyNotificationWithInvalidPayloadData {
77+
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
7678
XCTestExpectation *validPayloadExpectation =
7779
[self expectationWithDescription:@"Test payload is valid."];
7880

@@ -87,9 +89,11 @@ - (void)testModifyNotificationWithInvalidPayloadData {
8789
OCMReject([_mockExtensionHelper loadAttachmentForURL:[OCMArg any]
8890
completionHandler:[OCMArg any]]);
8991
[self waitForExpectationsWithTimeout:1.0 handler:nil];
92+
#endif
9093
}
9194

9295
- (void)testModifyNotificationWithEmptyPayloadData {
96+
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
9397
XCTestExpectation *validPayloadExpectation =
9498
[self expectationWithDescription:@"Test payload is valid."];
9599

@@ -104,7 +108,7 @@ - (void)testModifyNotificationWithEmptyPayloadData {
104108
OCMReject([_mockExtensionHelper loadAttachmentForURL:[OCMArg any]
105109
completionHandler:[OCMArg any]]);
106110
[self waitForExpectationsWithTimeout:1.0 handler:nil];
107-
}
108111
#endif
112+
}
109113

110114
@end

0 commit comments

Comments
 (0)