Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and reenable testANRDetected_UpdatesAppStateToTrue #2526

Merged
merged 2 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@
<Test
Identifier = "SentryNetworkTrackerIntegrationTests/testGetRequest_SpanCreatedAndBaggageHeaderAdded_disabled()">
</Test>
<Test
Identifier = "SentryWatchdogTerminationIntegrationTests/testANRDetected_UpdatesAppStateToTrue_disabled()">
</Test>
<Test
Identifier = "SentryProfilerSwiftTests/testProfileTimeoutTimer_disabled()">
</Test>
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryAppStateManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ - (void)updateAppState:(void (^)(SentryAppState *))block
{
@synchronized(self) {
SentryAppState *appState = [self.fileManager readAppState];
if (nil != appState) {
if (appState != nil) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I do that, get rid of style Yoda. 😁

block(appState);
[self.fileManager storeAppState:appState];
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryFileManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ - (void)storeAppState:(SentryAppState *)appState
NSError *error = nil;
NSData *data = [SentrySerialization dataWithJSONObject:[appState serialize] error:&error];

if (nil != error) {
if (error != nil) {
SENTRY_LOG_ERROR(
@"Failed to store app state, because of an error in serialization: %@", error);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SentryWatchdogTerminationIntegrationTests: XCTestCase {

crashWrapper = TestSentryCrashWrapper.sharedInstance()
SentryDependencyContainer.sharedInstance().crashWrapper = crashWrapper
SentryDependencyContainer.sharedInstance().fileManager = try! SentryFileManager(options: options, andCurrentDateProvider: currentDate)

let hub = SentryHub(client: client, andScope: nil, andCrashWrapper: crashWrapper, andCurrentDateProvider: currentDate)
SentrySDK.setCurrentHub(hub)
Expand Down Expand Up @@ -64,15 +65,12 @@ class SentryWatchdogTerminationIntegrationTests: XCTestCase {
}

#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
func testANRDetected_UpdatesAppStateToTrue_disabled() {
func testANRDetected_UpdatesAppStateToTrue() throws {
givenInitializedTracker()

Dynamic(sut).anrDetected()

guard let appState = fixture.fileManager.readAppState() else {
XCTFail("appState must not be nil")
return
}

let appState = try XCTUnwrap(fixture.fileManager.readAppState())

XCTAssertTrue(appState.isANROngoing)
}
Expand Down