From 08f447cd3fffae80748239daada493fcc19c111f Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Mon, 14 May 2018 10:02:25 -0700 Subject: Add global data collection switch. (#1219) * Addition of global data collection switch. * Added Messaging conformance to data switch. Also formatted code. * Move data collection flag internal until all SDKs conform to it. * Formatting in response to code review. --- Example/Messaging/Tests/FIRMessagingTest.m | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'Example/Messaging') diff --git a/Example/Messaging/Tests/FIRMessagingTest.m b/Example/Messaging/Tests/FIRMessagingTest.m index adc830d..61ff136 100644 --- a/Example/Messaging/Tests/FIRMessagingTest.m +++ b/Example/Messaging/Tests/FIRMessagingTest.m @@ -75,6 +75,46 @@ extern NSString *const kFIRMessagingFCMTokenFetchAPNSOption; XCTAssertTrue(_messaging.isAutoInitEnabled); } +- (void)testAutoInitEnableFlagOverrideGlobalTrue { + OCMStub([self.mockMessaging isGlobalAutomaticDataCollectionEnabled]).andReturn(YES); + id bundleMock = OCMPartialMock([NSBundle mainBundle]); + OCMStub([bundleMock objectForInfoDictionaryKey:kFIRMessagingPlistAutoInitEnabled]).andReturn(nil); + XCTAssertTrue(self.messaging.isAutoInitEnabled); + + self.messaging.autoInitEnabled = NO; + XCTAssertFalse(self.messaging.isAutoInitEnabled); + [bundleMock stopMocking]; +} + +- (void)testAutoInitEnableFlagOverrideGlobalFalse { + OCMStub([self.mockMessaging isGlobalAutomaticDataCollectionEnabled]).andReturn(YES); + id bundleMock = OCMPartialMock([NSBundle mainBundle]); + OCMStub([bundleMock objectForInfoDictionaryKey:kFIRMessagingPlistAutoInitEnabled]).andReturn(nil); + XCTAssertTrue(self.messaging.isAutoInitEnabled); + + self.messaging.autoInitEnabled = NO; + XCTAssertFalse(self.messaging.isAutoInitEnabled); + [bundleMock stopMocking]; +} + +- (void)testAutoInitEnableGlobalDefaultTrue { + OCMStub([self.mockMessaging isGlobalAutomaticDataCollectionEnabled]).andReturn(YES); + id bundleMock = OCMPartialMock([NSBundle mainBundle]); + OCMStub([bundleMock objectForInfoDictionaryKey:kFIRMessagingPlistAutoInitEnabled]).andReturn(nil); + + XCTAssertTrue(self.messaging.isAutoInitEnabled); + [bundleMock stopMocking]; +} + +- (void)testAutoInitEnableGlobalDefaultFalse { + OCMStub([self.mockMessaging isGlobalAutomaticDataCollectionEnabled]).andReturn(NO); + id bundleMock = OCMPartialMock([NSBundle mainBundle]); + OCMStub([bundleMock objectForInfoDictionaryKey:kFIRMessagingPlistAutoInitEnabled]).andReturn(nil); + + XCTAssertFalse(self.messaging.isAutoInitEnabled); + [bundleMock stopMocking]; +} + #pragma mark - Direct Channel Establishment Testing // Should connect with valid token and application in foreground -- cgit v1.2.3