|
15 | 15 | #import "FIRTestCase.h" |
16 | 16 |
|
17 | 17 | #import <FirebaseCore/FIRBundleUtil.h> |
| 18 | +#import <GoogleUtilities/GULAppEnvironmentUtil.h> |
18 | 19 |
|
19 | 20 | static NSString *const kResultPath = @"resultPath"; |
20 | 21 | static NSString *const kResourceName = @"resourceName"; |
@@ -69,16 +70,53 @@ - (void)testFindOptionsDictionaryPath_secondBundle { |
69 | 70 | - (void)testBundleIdentifierExistsInBundles { |
70 | 71 | NSString *bundleID = @"com.google.test"; |
71 | 72 | [OCMStub([self.mockBundle bundleIdentifier]) andReturn:bundleID]; |
72 | | - XCTAssertTrue([FIRBundleUtil hasBundleIdentifier:bundleID inBundles:@[ self.mockBundle ]]); |
| 73 | + XCTAssertTrue([FIRBundleUtil hasBundleIdentifierPrefix:bundleID inBundles:@[ self.mockBundle ]]); |
73 | 74 | } |
74 | 75 |
|
75 | 76 | - (void)testBundleIdentifierExistsInBundles_notExist { |
76 | 77 | [OCMStub([self.mockBundle bundleIdentifier]) andReturn:@"com.google.test"]; |
77 | | - XCTAssertFalse([FIRBundleUtil hasBundleIdentifier:@"not-exist" inBundles:@[ self.mockBundle ]]); |
| 78 | + XCTAssertFalse([FIRBundleUtil hasBundleIdentifierPrefix:@"not-exist" |
| 79 | + inBundles:@[ self.mockBundle ]]); |
78 | 80 | } |
79 | 81 |
|
80 | 82 | - (void)testBundleIdentifierExistsInBundles_emptyBundlesArray { |
81 | | - XCTAssertFalse([FIRBundleUtil hasBundleIdentifier:@"com.google.test" inBundles:@[]]); |
| 83 | + XCTAssertFalse([FIRBundleUtil hasBundleIdentifierPrefix:@"com.google.test" inBundles:@[]]); |
| 84 | +} |
| 85 | + |
| 86 | +- (void)testBundleIdentifierHasPrefixInBundlesForExtension { |
| 87 | + id environmentUtilsMock = [OCMockObject mockForClass:[GULAppEnvironmentUtil class]]; |
| 88 | + [[[environmentUtilsMock stub] andReturnValue:@(YES)] isAppExtension]; |
| 89 | + |
| 90 | + [OCMStub([self.mockBundle bundleIdentifier]) andReturn:@"com.google.test"]; |
| 91 | + XCTAssertTrue([FIRBundleUtil hasBundleIdentifierPrefix:@"com.google.test.someextension" |
| 92 | + inBundles:@[ self.mockBundle ]]); |
| 93 | + |
| 94 | + [environmentUtilsMock stopMocking]; |
| 95 | +} |
| 96 | + |
| 97 | +- (void)testBundleIdentifierHasPrefixInBundlesNotValidExtension { |
| 98 | + id environmentUtilsMock = [OCMockObject mockForClass:[GULAppEnvironmentUtil class]]; |
| 99 | + [[[environmentUtilsMock stub] andReturnValue:@(YES)] isAppExtension]; |
| 100 | + |
| 101 | + [OCMStub([self.mockBundle bundleIdentifier]) andReturn:@"com.google.test"]; |
| 102 | + XCTAssertFalse([FIRBundleUtil hasBundleIdentifierPrefix:@"com.google.test.someextension.some" |
| 103 | + inBundles:@[ self.mockBundle ]]); |
| 104 | + |
| 105 | + XCTAssertFalse([FIRBundleUtil hasBundleIdentifierPrefix:@"com.google.testsomeextension" |
| 106 | + inBundles:@[ self.mockBundle ]]); |
| 107 | + |
| 108 | + XCTAssertFalse([FIRBundleUtil hasBundleIdentifierPrefix:@"com.google.testsomeextension.some" |
| 109 | + inBundles:@[ self.mockBundle ]]); |
| 110 | + |
| 111 | + XCTAssertFalse([FIRBundleUtil hasBundleIdentifierPrefix:@"not-exist" |
| 112 | + inBundles:@[ self.mockBundle ]]); |
| 113 | + |
| 114 | + // Should be NO, since if @"com.google.tests" is an app extension identifier, then the app bundle |
| 115 | + // identifier is @"com.google" |
| 116 | + XCTAssertFalse([FIRBundleUtil hasBundleIdentifierPrefix:@"com.google.tests" |
| 117 | + inBundles:@[ self.mockBundle ]]); |
| 118 | + |
| 119 | + [environmentUtilsMock stopMocking]; |
82 | 120 | } |
83 | 121 |
|
84 | 122 | @end |
0 commit comments