summaryrefslogtreecommitdiff
path: root/tests/utils
diff options
context:
space:
mode:
authorRam Muthiah <rammuthiah@google.com>2019-12-11 17:37:37 -0800
committerRam Muthiah <rammuthiah@google.com>2019-12-11 17:37:37 -0800
commit637138dd944e610c408fb88a7557cc07df4e554b (patch)
tree72cc836e71378269815e4d13e9f601b14e6f6f79 /tests/utils
parenta4bb0444d90fe736dd47267189e406ab1321dbc9 (diff)
Revert "Overlay, actor, and target app visibility handling"
This reverts commit 3f46dbd7a091b5e594be6055ab11d0e0cfe25a18. Bug: 146018363 Test: Treehugger
Diffstat (limited to 'tests/utils')
-rw-r--r--tests/utils/testutils/Android.bp7
-rw-r--r--tests/utils/testutils/java/test/package-info.java21
-rw-r--r--tests/utils/testutils/java/test/util/MockitoUtils.kt70
3 files changed, 1 insertions, 97 deletions
diff --git a/tests/utils/testutils/Android.bp b/tests/utils/testutils/Android.bp
index 027b1d6799fd..f71be7b0b7d3 100644
--- a/tests/utils/testutils/Android.bp
+++ b/tests/utils/testutils/Android.bp
@@ -17,16 +17,11 @@
java_library {
name: "frameworks-base-testutils",
- srcs: [
- "java/**/*.java",
- "java/**/*.kt",
- ],
+ srcs: ["java/**/*.java"],
static_libs: [
"junit",
"hamcrest-library",
- "truth-prebuilt",
- "mockito-target-minus-junit4",
],
libs: [
diff --git a/tests/utils/testutils/java/test/package-info.java b/tests/utils/testutils/java/test/package-info.java
deleted file mode 100644
index c34d7b21ab84..000000000000
--- a/tests/utils/testutils/java/test/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * This package separated from android. because placing classes under android.'s .test/.util
- * may be confused with tests for that actual android subpackage.
- **/
-package test;
diff --git a/tests/utils/testutils/java/test/util/MockitoUtils.kt b/tests/utils/testutils/java/test/util/MockitoUtils.kt
deleted file mode 100644
index 5151abe54108..000000000000
--- a/tests/utils/testutils/java/test/util/MockitoUtils.kt
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package test.util
-
-import org.mockito.Answers
-import org.mockito.Mockito
-import org.mockito.invocation.InvocationOnMock
-import org.mockito.stubbing.Answer
-import org.mockito.stubbing.Stubber
-
-object MockitoUtils {
- val ANSWER_THROWS = Answer<Any?> {
- when (val name = it.method.name) {
- "toString" -> return@Answer Answers.CALLS_REAL_METHODS.answer(it)
- else -> {
- val arguments = it.arguments
- ?.takeUnless { it.isEmpty() }
- ?.joinToString()
- ?.let {
- "with $it"
- }
- .orEmpty()
-
- throw UnsupportedOperationException("${it.mock::class.java.simpleName}#$name " +
- "$arguments should not be called")
- }
- }
- }
-}
-
-inline fun <reified T> mock(block: T.() -> Unit = {}) = Mockito.mock(T::class.java).apply(block)
-
-fun <Type> Stubber.whenever(mock: Type) = Mockito.`when`(mock)
-fun <Type : Any?> whenever(mock: Type) = Mockito.`when`(mock)
-
-@Suppress("UNCHECKED_CAST")
-fun <Type : Any?> whenever(mock: Type, block: InvocationOnMock.() -> Any?) =
- Mockito.`when`(mock).thenAnswer { block(it) }
-
-fun whenever(mock: Unit) = Mockito.`when`(mock).thenAnswer { }
-
-inline fun <reified T> mockThrowOnUnmocked(block: T.() -> Unit): T {
- val swappingAnswer = object : Answer<Any?> {
- var delegate: Answer<*> = Answers.RETURNS_DEFAULTS
-
- override fun answer(invocation: InvocationOnMock?): Any? {
- return delegate.answer(invocation)
- }
- }
-
- return Mockito.mock(T::class.java, swappingAnswer).apply(block)
- .also {
- // To allow when() usage inside block, only swap to throwing afterwards
- swappingAnswer.delegate = MockitoUtils.ANSWER_THROWS
- }
-}