diff --git a/java/arcs/android/util/testutil/AndroidLogRule.kt b/java/arcs/android/util/testutil/AndroidLogRule.kt new file mode 100644 index 00000000000..abe5bff209e --- /dev/null +++ b/java/arcs/android/util/testutil/AndroidLogRule.kt @@ -0,0 +1,14 @@ +package arcs.android.util.testutil + +import android.util.Log as AndroidLog +import arcs.core.util.Log +import arcs.core.util.testutil.LogRule +import org.robolectric.shadows.ShadowLog + +/** TestRule which wrappers around [LogRule] and disable some database-related spammy tags. */ +class AndroidLogRule(logLevel: Log.Level = Log.Level.Debug) : LogRule(logLevel) { + init { + ShadowLog.setLoggable("CursorWindowStats", AndroidLog.WARN) + ShadowLog.setLoggable("SQLiteCursor", AndroidLog.WARN) + } +} diff --git a/java/arcs/android/util/testutil/BUILD b/java/arcs/android/util/testutil/BUILD new file mode 100644 index 00000000000..09d8e1ee56c --- /dev/null +++ b/java/arcs/android/util/testutil/BUILD @@ -0,0 +1,17 @@ +load("//third_party/java/arcs/build_defs:build_defs.bzl", "arcs_kt_android_library") + +licenses(["notice"]) + +package(default_visibility = ["//java/arcs:allowed-packages"]) + +arcs_kt_android_library( + name = "testutil", + testonly = True, + srcs = glob(["*.kt"]), + manifest = "//java/arcs/android/common:AndroidManifest.xml", + deps = [ + "//java/arcs/core/util", + "//java/arcs/core/util/testutil", + "//third_party/java/robolectric:shadows", + ], +) diff --git a/java/arcs/core/util/testutil/LogRule.kt b/java/arcs/core/util/testutil/LogRule.kt index 1d6e907124c..6b90a29d92d 100644 --- a/java/arcs/core/util/testutil/LogRule.kt +++ b/java/arcs/core/util/testutil/LogRule.kt @@ -22,7 +22,7 @@ import org.junit.runner.Description import org.junit.runners.model.Statement /** JUnit [TestRule] which prints wrappers around the log output from each test. */ -class LogRule( +open class LogRule( private val logLevel: Log.Level = Log.Level.Debug ) : TestRule { private val taggedLog = TaggedLog { "TEST" } diff --git a/javatests/arcs/android/integration/ttl/BUILD b/javatests/arcs/android/integration/ttl/BUILD index ef63f0e2ace..110a8be8bdd 100644 --- a/javatests/arcs/android/integration/ttl/BUILD +++ b/javatests/arcs/android/integration/ttl/BUILD @@ -39,11 +39,11 @@ arcs_kt_android_test_suite( deps = [ ":ttl_generation", ":ttl_particles", + "//java/arcs/android/util/testutil", "//java/arcs/core/allocator", "//java/arcs/core/entity/testutil", "//java/arcs/core/host", "//java/arcs/core/testutil", - "//java/arcs/core/util/testutil", "//javatests/arcs/android/integration", "//third_party/android/androidx_test/ext/junit", "//third_party/java/junit:junit-android", diff --git a/javatests/arcs/android/integration/ttl/TtlTest.kt b/javatests/arcs/android/integration/ttl/TtlTest.kt index a23e956d392..eb13f01723a 100644 --- a/javatests/arcs/android/integration/ttl/TtlTest.kt +++ b/javatests/arcs/android/integration/ttl/TtlTest.kt @@ -2,10 +2,10 @@ package arcs.android.integration.ttl import androidx.test.ext.junit.runners.AndroidJUnit4 import arcs.android.integration.IntegrationEnvironment +import arcs.android.util.testutil.AndroidLogRule import arcs.core.entity.testutil.FixtureEntities import arcs.core.entity.testutil.FixtureEntity import arcs.core.host.toRegistration -import arcs.core.util.testutil.LogRule import com.google.common.truth.Truth.assertThat import kotlin.time.minutes import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -21,7 +21,7 @@ import org.robolectric.annotation.Config class TtlTest { @get:Rule - val log = LogRule() + val log = AndroidLogRule() @get:Rule val env = IntegrationEnvironment(