Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d3a10584 authored by Winson's avatar Winson
Browse files

Add IntentFilter verification tests

In preparation for later changes, adds tests for the existing
domain verification flow for auto verified app links.

Implements a proxy verifier which saves incoming requests to
a file on disk which can be read back later by another call
from the host side test to send a success/failure code.

This tests some basic known success/failure cases, as well as
verifies the presence of bugs, which have been marked with TODOs
against the feature bug number, to be fixed with later work.

Also migrates manual test cases from
I200d85085ce79842a3ed39377d1f75ec381c8991.

Bug: 159952358
Bug: 162346237

Test: atest com.android.server.pm.test.intent.verify.IntentFilterVerificationTest

Change-Id: Ib646b7f6f155ae342195dd25f82bb2463a9ca2b7
parent 8a783b2f
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ java_test_host {
    ],
    static_libs: [
        "frameworks-base-hostutils",
        "PackageManagerServiceHostTestsIntentVerifyUtils",
    ],
    test_suites: ["general-tests"],
    java_resources: [
@@ -33,7 +34,15 @@ java_test_host {
        ":PackageManagerTestAppVersion4",
        ":PackageManagerTestAppOriginalOverride",
        ":PackageManagerServiceDeviceSideTests",
    ],
        ":PackageManagerTestIntentVerifier",
        ":PackageManagerTestIntentVerifierTarget1",
        ":PackageManagerTestIntentVerifierTarget2",
        ":PackageManagerTestIntentVerifierTarget3",
        ":PackageManagerTestIntentVerifierTarget4Base",
        ":PackageManagerTestIntentVerifierTarget4NoAutoVerify",
        ":PackageManagerTestIntentVerifierTarget4Wildcard",
        ":PackageManagerTestIntentVerifierTarget4WildcardNoAutoVerify",
    ]
}

genrule {
+19 −0
Original line number Diff line number Diff line
// Copyright (C) 2020 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.

java_library {
    name: "PackageManagerServiceHostTestsIntentVerifyUtils",
    srcs: ["src/**/*.kt"],
    host_supported: true,
}
+9 −0
Original line number Diff line number Diff line
@@ -13,3 +13,12 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.pm.test.intent.verify

interface IntentVerifyTestParams {

    val methodName: String

    fun toArgsMap(): Map<String, String>
}
+43 −0
Original line number Diff line number Diff line
@@ -13,3 +13,31 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.pm.test.intent.verify

data class SetActivityAsAlwaysParams(
    val uri: String,
    val packageName: String,
    val activityName: String,
    override val methodName: String = "setActivityAsAlways"
) : IntentVerifyTestParams {

    companion object {
        private const val KEY_URI = "uri"
        private const val KEY_PACKAGE_NAME = "packageName"
        private const val KEY_ACTIVITY_NAME = "activityName"

        fun fromArgs(args: Map<String, String>) = SetActivityAsAlwaysParams(
                args.getValue(KEY_URI),
                args.getValue(KEY_PACKAGE_NAME),
                args.getValue(KEY_ACTIVITY_NAME)
        )
    }

    override fun toArgsMap() = mapOf(
            KEY_URI to uri,
            KEY_PACKAGE_NAME to packageName,
            KEY_ACTIVITY_NAME to activityName
    )
}
+48 −0
Original line number Diff line number Diff line
@@ -13,3 +13,36 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.pm.test.intent.verify

data class StartActivityParams(
    val uri: String,
    val expected: List<String>,
    val withBrowsers: Boolean = false,
    override val methodName: String = "verifyActivityStart"
) : IntentVerifyTestParams {
    companion object {
        private const val KEY_URI = "uri"
        private const val KEY_EXPECTED = "expected"
        private const val KEY_BROWSER = "browser"

        fun fromArgs(args: Map<String, String>) = StartActivityParams(
                args.getValue(KEY_URI),
                args.getValue(KEY_EXPECTED).split(","),
                args.getValue(KEY_BROWSER).toBoolean()
        )
    }

    constructor(
        uri: String,
        expected: String,
        withBrowsers: Boolean = false
    ) : this(uri, listOf(expected), withBrowsers)

    override fun toArgsMap() = mapOf(
            KEY_URI to uri,
            KEY_EXPECTED to expected.joinToString(separator = ","),
            KEY_BROWSER to withBrowsers.toString()
    )
}
Loading