summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson <chiuwinson@google.com> 2020-05-21 11:37:42 -0700
committer Winson <chiuwinson@google.com> 2020-05-21 11:50:43 -0700
commitbadad7b62fac95a82ef71c5b90cfc89d0d939eaf (patch)
treed67c218f3fa3d09288b964c3ed7faaff0be0de9b
parent21ebdf80dd92d5275a3bc8744d3edad7b4c5542c (diff)
Remove InstantAppResolverTests for migration to CTS
See change I79b7c42e8a495c0f4ba4cd42a076ac3b43ee2919 Bug: 155114274 Bug: 155115137 Bug: 155115845 Bug: 155116506 Bug: 155116748 Bug: 155117421 Test: atest CtsInstantAppTests Change-Id: I09023d098c93758c049169a909c27c230bb3dd9b
-rw-r--r--core/java/android/app/TEST_MAPPING2
-rw-r--r--core/java/android/content/pm/TEST_MAPPING2
-rw-r--r--core/tests/InstantAppResolverTests/Android.bp32
-rw-r--r--core/tests/InstantAppResolverTests/AndroidManifest.xml33
-rw-r--r--core/tests/InstantAppResolverTests/AndroidTest.xml29
-rw-r--r--core/tests/InstantAppResolverTests/src/android/app/instantapp/resolver/test/ResolverServiceMethodFallbackTest.kt174
6 files changed, 2 insertions, 270 deletions
diff --git a/core/java/android/app/TEST_MAPPING b/core/java/android/app/TEST_MAPPING
index 344a4d79b766..7c72e932d310 100644
--- a/core/java/android/app/TEST_MAPPING
+++ b/core/java/android/app/TEST_MAPPING
@@ -54,7 +54,7 @@
"file_patterns": ["INotificationManager\\.aidl"]
},
{
- "name": "FrameworksInstantAppResolverTests",
+ "name": "CtsInstantAppTests",
"file_patterns": ["(/|^)InstantAppResolve[^/]*"]
}
],
diff --git a/core/java/android/content/pm/TEST_MAPPING b/core/java/android/content/pm/TEST_MAPPING
index 6f30ecd9b281..e404feea15b9 100644
--- a/core/java/android/content/pm/TEST_MAPPING
+++ b/core/java/android/content/pm/TEST_MAPPING
@@ -12,7 +12,7 @@
],
"presubmit": [
{
- "name": "FrameworksInstantAppResolverTests",
+ "name": "CtsInstantAppTests",
"file_patterns": ["(/|^)InstantApp[^/]*"]
}
],
diff --git a/core/tests/InstantAppResolverTests/Android.bp b/core/tests/InstantAppResolverTests/Android.bp
deleted file mode 100644
index 7b01010ebb2b..000000000000
--- a/core/tests/InstantAppResolverTests/Android.bp
+++ /dev/null
@@ -1,32 +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.
-//
-
-android_test {
- name: "FrameworksInstantAppResolverTests",
- srcs: [ "src/**/*.kt" ],
- libs: [
- "android.test.runner",
- "android.test.base",
- ],
- platform_apis: true,
- static_libs: [
- "androidx.test.ext.junit",
- "androidx.test.rules",
- "mockito-target-minus-junit4",
- "truth-prebuilt",
- ],
- test_suites: ["device-tests"],
-}
diff --git a/core/tests/InstantAppResolverTests/AndroidManifest.xml b/core/tests/InstantAppResolverTests/AndroidManifest.xml
deleted file mode 100644
index f95978b5a63e..000000000000
--- a/core/tests/InstantAppResolverTests/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ 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.
- -->
-
-<manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.app.instantapp.resolver.test"
- >
-
- <application>
- <uses-library android:name="android.test.runner"/>
- </application>
-
- <instrumentation
- android:name="androidx.test.runner.AndroidJUnitRunner"
- android:label="InstantAppResolverTests"
- android:targetPackage="android.app.instantapp.resolver.test"
- />
-
-</manifest>
diff --git a/core/tests/InstantAppResolverTests/AndroidTest.xml b/core/tests/InstantAppResolverTests/AndroidTest.xml
deleted file mode 100644
index fcc6344efd83..000000000000
--- a/core/tests/InstantAppResolverTests/AndroidTest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ 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.
- -->
-
-<configuration description="Test module config for InstantAppResolverTests">
- <option name="test-tag" value="InstantAppResolverTests" />
-
- <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
- <option name="cleanup-apks" value="true" />
- <option name="test-file-name" value="FrameworksInstantAppResolverTests.apk" />
- </target_preparer>
-
- <test class="com.android.tradefed.testtype.AndroidJUnitTest">
- <option name="package" value="android.app.instantapp.resolver.test" />
- </test>
-</configuration>
diff --git a/core/tests/InstantAppResolverTests/src/android/app/instantapp/resolver/test/ResolverServiceMethodFallbackTest.kt b/core/tests/InstantAppResolverTests/src/android/app/instantapp/resolver/test/ResolverServiceMethodFallbackTest.kt
deleted file mode 100644
index 2a17ef210d36..000000000000
--- a/core/tests/InstantAppResolverTests/src/android/app/instantapp/resolver/test/ResolverServiceMethodFallbackTest.kt
+++ /dev/null
@@ -1,174 +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 android.app.instantapp.resolver.test
-
-import android.app.InstantAppResolverService
-import android.app.InstantAppResolverService.InstantAppResolutionCallback
-import android.content.Intent
-import android.content.pm.InstantAppRequestInfo
-import android.net.Uri
-import android.os.Bundle
-import android.os.IRemoteCallback
-import android.os.UserHandle
-import com.google.common.truth.Truth.assertThat
-import org.junit.Before
-import org.junit.Rule
-import org.junit.Test
-import org.junit.rules.ExpectedException
-import org.junit.runner.RunWith
-import org.junit.runners.Parameterized
-import org.mockito.Answers
-import org.mockito.Mock
-import org.mockito.Mockito.doNothing
-import org.mockito.Mockito.never
-import org.mockito.Mockito.verify
-import org.mockito.Mockito.verifyNoMoreInteractions
-import org.mockito.MockitoAnnotations
-import java.util.UUID
-import kotlin.random.Random
-
-private typealias Method = InstantAppResolverService.(InstantAppRequestInfo) -> Unit
-
-@Suppress("max-line-length")
-@RunWith(Parameterized::class)
-class ResolverServiceMethodFallbackTest @Suppress("UNUSED_PARAMETER") constructor(
- private val version: Int,
- private val methodList: List<Method>,
- private val info: InstantAppRequestInfo,
- // Remaining only used to print human-readable test name
- name: String,
- isWebIntent: Boolean
-) {
-
- companion object {
- // Since the resolution callback class is final, mock the IRemoteCallback and have it throw
- // a unique exception to indicate it was called.
- class TestRemoteCallbackException : Exception()
-
- private val testIntentWeb = Intent(Intent.ACTION_VIEW,
- Uri.parse("https://${this::class.java.canonicalName}.com"))
- private val testIntentNotWeb = Intent(Intent.ACTION_VIEW,
- Uri.parse("content://${this::class.java.canonicalName}"))
-
- private val testRemoteCallback = object : IRemoteCallback {
- override fun sendResult(data: Bundle?) = throw TestRemoteCallbackException()
- override fun asBinder() = throw UnsupportedOperationException()
- }
- private val testResolutionCallback = InstantAppResolutionCallback(0, testRemoteCallback)
- private val testArray = IntArray(10) { Random.nextInt() }
- private val testToken = UUID.randomUUID().toString()
- private val testUser = UserHandle(Integer.MAX_VALUE)
- private val testInfoWeb = InstantAppRequestInfo(testIntentWeb, testArray, testUser,
- false, testToken)
- private val testInfoNotWeb = InstantAppRequestInfo(testIntentNotWeb, testArray, testUser,
- false, testToken)
-
- // Each section defines methods versions with later definitions falling back to
- // earlier definitions. Each block receives an [InstantAppResolverService] and invokes
- // the appropriate version with the test data defined above.
- private val infoOne: Method = { onGetInstantAppResolveInfo(testArray, testToken,
- testResolutionCallback) }
- private val infoTwo: Method = { onGetInstantAppResolveInfo(it.intent, testArray, testToken,
- testResolutionCallback) }
- private val infoThree: Method = { onGetInstantAppResolveInfo(it.intent, testArray, testUser,
- testToken, testResolutionCallback) }
- private val infoFour: Method = { onGetInstantAppResolveInfo(it, testResolutionCallback) }
-
- private val filterOne: Method = { onGetInstantAppIntentFilter(testArray, testToken,
- testResolutionCallback) }
- private val filterTwo: Method = { onGetInstantAppIntentFilter(it.intent, testArray,
- testToken, testResolutionCallback) }
- private val filterThree: Method = { onGetInstantAppIntentFilter(it.intent, testArray,
- testUser, testToken, testResolutionCallback) }
- private val filterFour: Method = { onGetInstantAppIntentFilter(it, testResolutionCallback) }
-
- private val infoList = listOf(infoOne, infoTwo, infoThree, infoFour)
- private val filterList = listOf(filterOne, filterTwo, filterThree, filterFour)
-
- @JvmStatic
- @Parameterized.Parameters(name = "{3} version {0}, isWeb = {4}")
- fun parameters(): Array<Array<*>> {
- // Sanity check that web intent logic hasn't changed
- assertThat(testInfoWeb.intent.isWebIntent).isTrue()
- assertThat(testInfoNotWeb.intent.isWebIntent).isFalse()
-
- // Declare all the possible params
- val versions = Array(5) { it }
- val methods = arrayOf("ResolveInfo" to infoList, "IntentFilter" to filterList)
- val infos = arrayOf(testInfoWeb, testInfoNotWeb)
-
- // FlatMap params into every possible combination
- return infos.flatMap { info ->
- methods.flatMap { (name, methods) ->
- versions.map { version ->
- arrayOf(version, methods, info, name, info.intent.isWebIntent)
- }
- }
- }.toTypedArray()
- }
- }
-
- @field:Mock(answer = Answers.CALLS_REAL_METHODS)
- lateinit var mockService: InstantAppResolverService
-
- @get:Rule
- val expectedException = ExpectedException.none()
-
- @Before
- fun setUpMocks() {
- MockitoAnnotations.initMocks(this)
- }
-
- @Test
- fun onGetInstantApp() {
- if (version == 0) {
- // No version of the API was implemented, so expect terminal case
- if (info.intent.isWebIntent) {
- // If web intent, terminal is total failure
- expectedException.expect(IllegalStateException::class.java)
- } else {
- // Otherwise, terminal is a fail safe by calling [testRemoteCallback]
- expectedException.expect(TestRemoteCallbackException::class.java)
- }
- } else if (version < 2 && !info.intent.isWebIntent) {
- // Starting from v2, if resolving a non-web intent and a v2+ method isn't implemented,
- // it fails safely by calling [testRemoteCallback]
- expectedException.expect(TestRemoteCallbackException::class.java)
- }
-
- // Version 1 is the first method (index 0)
- val methodIndex = version - 1
-
- // Implement a method if necessary
- methodList.getOrNull(methodIndex)?.invoke(doNothing().`when`(mockService), info)
-
- // Call the latest API
- methodList.last().invoke(mockService, info)
-
- // Check all methods before implemented method are never called
- (0 until methodIndex).forEach {
- methodList[it].invoke(verify(mockService, never()), info)
- }
-
- // Check all methods from implemented method are called
- (methodIndex until methodList.size).forEach {
- methodList[it].invoke(verify(mockService), info)
- }
-
- verifyNoMoreInteractions(mockService)
- }
-}