Skip to content
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
10 changes: 10 additions & 0 deletions sentry-test-support/api/sentry-test-support.api
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ public final class io/sentry/test/MocksKt {
public static synthetic fun createTestScopes$default (Lio/sentry/SentryOptions;ZLio/sentry/IScope;Lio/sentry/IScope;Lio/sentry/IScope;ILjava/lang/Object;)Lio/sentry/Scopes;
}

public final class io/sentry/test/NonOverridableNoOpSentryExecutorService : io/sentry/ISentryExecutorService {
public fun <init> ()V
public fun close (J)V
public fun isClosed ()Z
public fun prewarm ()V
public fun schedule (Ljava/lang/Runnable;J)Ljava/util/concurrent/Future;
public fun submit (Ljava/lang/Runnable;)Ljava/util/concurrent/Future;
public fun submit (Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;
}

public final class io/sentry/test/ReflectionKt {
public static final fun collectInterfaceHierarchy (Ljava/lang/Class;)Ljava/util/List;
public static final fun containsMethod (Ljava/lang/Class;Ljava/lang/String;Ljava/lang/Class;)Z
Expand Down
15 changes: 15 additions & 0 deletions sentry-test-support/src/main/kotlin/io/sentry/test/Mocks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ class DeferredExecutorService : ISentryExecutorService {
fun hasScheduledRunnables(): Boolean = scheduledRunnables.isNotEmpty()
}

class NonOverridableNoOpSentryExecutorService : ISentryExecutorService {
override fun submit(runnable: Runnable): Future<*> = FutureTask<Void> { null }

override fun <T> submit(callable: Callable<T>): Future<T> = FutureTask<T> { null }

override fun schedule(runnable: Runnable, delayMillis: Long): Future<*> =
FutureTask<Void> { null }

override fun close(timeoutMillis: Long) {}

override fun isClosed(): Boolean = false

override fun prewarm() = Unit
}

fun createSentryClientMock(enabled: Boolean = true) =
mock<ISentryClient>().also {
val isEnabled = AtomicBoolean(enabled)
Expand Down
5 changes: 3 additions & 2 deletions sentry/src/test/java/io/sentry/SentryTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import io.sentry.protocol.SdkVersion
import io.sentry.protocol.SentryId
import io.sentry.protocol.SentryThread
import io.sentry.test.ImmediateExecutorService
import io.sentry.test.NonOverridableNoOpSentryExecutorService
import io.sentry.test.createSentryClientMock
import io.sentry.test.initForTest
import io.sentry.test.injectForField
Expand Down Expand Up @@ -1217,7 +1218,7 @@ class SentryTest {
it.profilesSampleRate = 1.0
it.tracesSampler = mockSampleTracer
it.profilesSampler = mockProfilesSampler
it.executorService = NoOpSentryExecutorService.getInstance()
it.executorService = NonOverridableNoOpSentryExecutorService()
it.cacheDirPath = getTempPath()
}
// Samplers are called with isForNextAppStart flag set to true
Expand All @@ -1236,7 +1237,7 @@ class SentryTest {
it.profilesSampleRate = 1.0
it.tracesSampler = mockSampleTracer
it.profilesSampler = mockProfilesSampler
it.executorService = NoOpSentryExecutorService.getInstance()
it.executorService = NonOverridableNoOpSentryExecutorService()
it.cacheDirPath = null
}
// Samplers are called with isForNextAppStart flag set to true
Expand Down
Loading