From bdfccaaf7ec472bda6f92604edde3a1858c5e41f Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Wed, 2 Nov 2022 13:18:36 +0100 Subject: [PATCH] fix: Fixed flaky testTimezoneChangeNotificationBreadcrumb (#2335) --- Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme | 3 --- Sources/Sentry/include/SentrySystemEventBreadcrumbs.h | 1 + .../Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift | 5 +++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme index aa862f2dda8..5d48f6a690b 100644 --- a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme +++ b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme @@ -85,9 +85,6 @@ - - diff --git a/Sources/Sentry/include/SentrySystemEventBreadcrumbs.h b/Sources/Sentry/include/SentrySystemEventBreadcrumbs.h index 2392279359c..57d079848ed 100644 --- a/Sources/Sentry/include/SentrySystemEventBreadcrumbs.h +++ b/Sources/Sentry/include/SentrySystemEventBreadcrumbs.h @@ -16,6 +16,7 @@ SENTRY_NO_INIT #if TARGET_OS_IOS - (void)start:(UIDevice *)currentDevice; +- (void)timezoneEventTriggered; #endif - (void)stop; diff --git a/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift b/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift index 6d21fd29507..5b6108cd819 100644 --- a/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift +++ b/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift @@ -252,13 +252,14 @@ class SentrySystemEventBreadcrumbsTest: XCTestCase { } } - func testTimezoneChangeNotificationBreadcrumb_disabled() { + func testTimezoneChangeNotificationBreadcrumb() { let scope = Scope() sut = fixture.getSut(scope: scope, currentDevice: nil) fixture.currentDateProvider.timezoneOffsetValue = 7_200 - NotificationCenter.default.post(Notification(name: NSNotification.Name.NSSystemTimeZoneDidChange)) + sut.timezoneEventTriggered() + assertBreadcrumbAction(scope: scope, action: "TIMEZONE_CHANGE") { data in XCTAssertEqual(data["previous_seconds_from_gmt"] as? Int, 0) XCTAssertEqual(data["current_seconds_from_gmt"] as? Int, 7_200)