Skip to content

Commit

Permalink
add AndroidLogRule to disable some sqlite-related spammy tags, and us…
Browse files Browse the repository at this point in the history
…e in TtlTest

PiperOrigin-RevId: 348724893
  • Loading branch information
galganif authored and arcs-c3po committed Dec 23, 2020
1 parent 98b5514 commit 06a2d31
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
14 changes: 14 additions & 0 deletions java/arcs/android/util/testutil/AndroidLogRule.kt
Original file line number Diff line number Diff line change
@@ -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)
}
}
17 changes: 17 additions & 0 deletions java/arcs/android/util/testutil/BUILD
Original file line number Diff line number Diff line change
@@ -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",
],
)
2 changes: 1 addition & 1 deletion java/arcs/core/util/testutil/LogRule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion javatests/arcs/android/integration/ttl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions javatests/arcs/android/integration/ttl/TtlTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,7 +21,7 @@ import org.robolectric.annotation.Config
class TtlTest {

@get:Rule
val log = LogRule()
val log = AndroidLogRule()

@get:Rule
val env = IntegrationEnvironment(
Expand Down

0 comments on commit 06a2d31

Please sign in to comment.