From 11947ad911963939e11c7c4960df308ebc1c842c Mon Sep 17 00:00:00 2001 From: Steven Gschwind Date: Mon, 20 May 2019 11:30:58 -0700 Subject: [PATCH] Add Unit test FBSDKApplicationDelegate Summary: Unit test checks if FBSDKAppEvents becomes active Reviewed By: tianqibt Differential Revision: D15379668 fbshipit-source-id: f9e41506a9e449ef544d487ac2c95d71d6da5ed9 --- .../FBSDKApplicationDelegateTests.m | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/FBSDKCoreKit/FBSDKCoreKitTests/FBSDKApplicationDelegateTests.m b/FBSDKCoreKit/FBSDKCoreKitTests/FBSDKApplicationDelegateTests.m index f5d8879f7f..8bfee6ff9f 100644 --- a/FBSDKCoreKit/FBSDKCoreKitTests/FBSDKApplicationDelegateTests.m +++ b/FBSDKCoreKit/FBSDKCoreKitTests/FBSDKApplicationDelegateTests.m @@ -41,6 +41,7 @@ @interface FBSDKApplicationDelegateTests : XCTestCase { @interface FBSDKApplicationDelegate(Test) - (void)_logSDKInitialize; +- (void)applicationDidBecomeActive:(NSNotification *)notification; @end @@ -85,4 +86,26 @@ - (void)testAutoLogAppEventsDisabled { [_delegate application:app didFinishLaunchingWithOptions:nil]; } +- (void)testAppEventsEnabled { + + [OCMStub(ClassMethod([_settingsMock isAutoLogAppEventsEnabled])) andReturnValue: OCMOCK_VALUE(YES)]; + + id appEvents = OCMClassMock([FBSDKAppEvents class]); + + id notification = OCMClassMock([NSNotification class]); + [_delegate applicationDidBecomeActive:notification]; + + OCMVerify([appEvents activateApp]); +} + +-(void)testAppEventsDisabled { + + [OCMStub(ClassMethod([_settingsMock isAutoLogAppEventsEnabled])) andReturnValue: OCMOCK_VALUE(NO)]; + + id appEvents = OCMStrictClassMock([FBSDKAppEvents class]); + OCMReject([appEvents activateApp]); + + id notification = OCMClassMock([NSNotification class]); + [_delegate applicationDidBecomeActive:notification]; +} @end