3535static SCNetworkReachabilityFlags sentry_current_reachability_state
3636 = kSCNetworkReachabilityFlagsUninitialized ;
3737static dispatch_queue_t sentry_reachability_queue;
38- static BOOL sentry_reachability_ignore_actual_callback = NO ;
3938
4039NSString *const SentryConnectivityCellular = @" cellular" ;
4140NSString *const SentryConnectivityWiFi = @" wifi" ;
4241NSString *const SentryConnectivityNone = @" none" ;
4342
43+ # if TEST || TESTCI
44+ static BOOL sentry_reachability_ignore_actual_callback = NO ;
45+
4446void
4547SentrySetReachabilityIgnoreActualCallback (BOOL value)
4648{
49+ SENTRY_LOG_DEBUG (@" Setting ignore actual callback to %@ " , value ? @" YES" : @" NO" );
4750 sentry_reachability_ignore_actual_callback = value;
4851}
52+ # endif // TEST || TESTCI
4953
5054/* *
5155 * Check whether the connectivity change should be noted or ignored.
132136{
133137 SENTRY_LOG_DEBUG (
134138 @" SentryConnectivityCallback called with target: %@ ; flags: %u " , target, flags);
139+ # if TEST || TESTCI
135140 if (sentry_reachability_ignore_actual_callback) {
136141 SENTRY_LOG_DEBUG (@" Ignoring actual callback." );
137142 return ;
138143 }
144+ # endif // TEST || TESTCI
145+
139146 SentryConnectivityCallback (flags);
140147}
141148
@@ -155,6 +162,19 @@ + (void)initialize
155162 }
156163}
157164
165+ # if TEST || TESTCI
166+
167+ - (instancetype )init
168+ {
169+ if (self = [super init ]) {
170+ self.skipRegisteringActualCallbacks = NO ;
171+ }
172+
173+ return self;
174+ }
175+
176+ # endif // TEST || TESTCI
177+
158178- (void )addObserver : (id <SentryReachabilityObserver>)observer ;
159179{
160180 SENTRY_LOG_DEBUG (@" Adding observer: %@ " , observer);
@@ -171,6 +191,13 @@ - (void)addObserver:(id<SentryReachabilityObserver>)observer;
171191 return ;
172192 }
173193
194+ # if TEST || TESTCI
195+ if (self.skipRegisteringActualCallbacks ) {
196+ SENTRY_LOG_DEBUG (@" Skip registering actual callbacks" );
197+ return ;
198+ }
199+ # endif // TEST || TESTCI
200+
174201 sentry_reachability_queue
175202 = dispatch_queue_create (" io.sentry.cocoa.connectivity" , DISPATCH_QUEUE_SERIAL);
176203 // Ensure to call CFRelease for the return value of SCNetworkReachabilityCreateWithName, see
@@ -214,6 +241,12 @@ - (void)removeAllObservers
214241
215242- (void )unsetReachabilityCallback
216243{
244+ # if TEST || TESTCI
245+ if (self.skipRegisteringActualCallbacks ) {
246+ SENTRY_LOG_DEBUG (@" Skip unsetting actual callbacks" );
247+ }
248+ # endif // TEST || TESTCI
249+
217250 sentry_current_reachability_state = kSCNetworkReachabilityFlagsUninitialized ;
218251
219252 if (_sentry_reachability_ref != nil ) {
0 commit comments