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

Commit 37b1cebd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add IntentFilter verification tests"

parents 6b39c3d5 d3a10584
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