Skip to content

Commit

Permalink
ref: Use the new loadPreviousAppState in SentryAppStartTracker (#2261)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrenskers authored Oct 7, 2022
1 parent 7977992 commit be47c6c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1803,6 +1803,8 @@
7BD729972463E93500EA3610 /* SentryDateUtil.m */,
7B98D7E325FB7A7200C5A389 /* SentryAppState.h */,
7B98D7E725FB7BCD00C5A389 /* SentryAppState.m */,
7B8ECBF926498906005FE2EF /* SentryAppStateManager.h */,
7B8ECBFB26498958005FE2EF /* SentryAppStateManager.m */,
7BD86EC4264A63F6005439DB /* SentrySysctl.h */,
7BD86EC6264A641D005439DB /* SentrySysctl.m */,
7BF9EF832722D07B00B5BBEF /* SentryObjCRuntimeWrapper.h */,
Expand Down Expand Up @@ -2470,8 +2472,6 @@
7B8713AF26415B22006D6004 /* SentryAppStartTrackingIntegration.m */,
7B8713B126415B7A006D6004 /* SentryAppStartTracker.h */,
7B8713B326415BAA006D6004 /* SentryAppStartTracker.m */,
7B8ECBF926498906005FE2EF /* SentryAppStateManager.h */,
7B8ECBFB26498958005FE2EF /* SentryAppStateManager.m */,
7BD86ECE264A7C77005439DB /* SentryAppStartMeasurement.h */,
7BD86ED0264A7CF6005439DB /* SentryAppStartMeasurement.m */,
);
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryAppStartTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ - (instancetype)initWithCurrentDateProvider:(id<SentryCurrentDateProvider>)curre
self.dispatchQueue = dispatchQueueWrapper;
self.appStateManager = appStateManager;
self.sysctl = sysctl;
self.previousAppState = [self.appStateManager loadCurrentAppState];
self.previousAppState = [self.appStateManager loadPreviousAppState];
self.wasInBackground = NO;
self.didFinishLaunchingTimestamp = [currentDateProvider date];
}
Expand Down
5 changes: 0 additions & 5 deletions Sources/Sentry/SentryAppStateManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ - (SentryAppState *)loadPreviousAppState
return [self.fileManager readPreviousAppState];
}

- (SentryAppState *)loadCurrentAppState
{
return [self.fileManager readAppState];
}

- (void)storeCurrentAppState
{
[self.fileManager storeAppState:[self buildCurrentAppState]];
Expand Down
2 changes: 0 additions & 2 deletions Sources/Sentry/include/SentryAppStateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ SENTRY_NO_INIT

- (SentryAppState *)loadPreviousAppState;

- (SentryAppState *)loadCurrentAppState;

- (void)storeCurrentAppState;

- (void)deleteAppState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class SentryAppStartTrackerTests: NotificationCenterTestCase {

func testSecondStart_SystemNotRebooted_IsWarmStart() {
givenSystemNotRebooted()


fixture.fileManager.moveAppStateToPreviousAppState()
startApp()

assertValidStart(type: .warm)
Expand Down Expand Up @@ -109,7 +110,8 @@ class SentryAppStartTrackerTests: NotificationCenterTestCase {

let appState = SentryAppState(releaseName: "1.0.0", osVersion: "14.4.1", vendorId: TestData.someUUID, isDebugging: false, systemBootTimestamp: self.fixture.currentDate.date())
givenPreviousAppState(appState: appState)


fixture.fileManager.moveAppStateToPreviousAppState()
startApp()

assertValidStart(type: .warm)
Expand All @@ -121,7 +123,8 @@ class SentryAppStartTrackerTests: NotificationCenterTestCase {
func testAppLaunches_PreviousBootTimeInFuture_NoAppStartUp() {
let appState = SentryAppState(releaseName: TestData.appState.releaseName, osVersion: UIDevice.current.systemVersion, vendorId: TestData.someUUID, isDebugging: false, systemBootTimestamp: fixture.currentDate.date().addingTimeInterval(1))
givenPreviousAppState(appState: appState)


fixture.fileManager.moveAppStateToPreviousAppState()
startApp()

assertNoAppStartUp()
Expand All @@ -131,7 +134,8 @@ class SentryAppStartTrackerTests: NotificationCenterTestCase {
setenv("ActivePrewarm", "1", 1)
SentryAppStartTracker.load()
givenSystemNotRebooted()


fixture.fileManager.moveAppStateToPreviousAppState()
startApp()

#if os(iOS)
Expand All @@ -149,7 +153,8 @@ class SentryAppStartTrackerTests: NotificationCenterTestCase {
setenv("ActivePrewarm", "0", 1)
SentryAppStartTracker.load()
givenSystemNotRebooted()


fixture.fileManager.moveAppStateToPreviousAppState()
startApp()

assertValidStart(type: .warm)
Expand Down Expand Up @@ -220,7 +225,8 @@ class SentryAppStartTrackerTests: NotificationCenterTestCase {

func testHybridSDKs_SecondStart_SystemNotRebooted_IsWarmStart() {
givenSystemNotRebooted()


fixture.fileManager.moveAppStateToPreviousAppState()
hybridAppStart()

assertValidHybridStart(type: .warm)
Expand Down

0 comments on commit be47c6c

Please sign in to comment.