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

Commit 8b961419 authored by Utkarsh Nigam's avatar Utkarsh Nigam Committed by Android (Google) Code Review
Browse files

Merge "Set up the the unit test folder" into main

parents 907fb870 4c3c1fdf
Loading
Loading
Loading
Loading
+59 −0
Original line number Diff line number Diff line
// Copyright (C) 2024 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 {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_base_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_base_license"],
}

android_test {
    name: "FrameworksAppFunctionsTests",
    team: "trendy_team_machine_learning",
    defaults: [
        "modules-utils-testable-device-config-defaults",
    ],

    srcs: [
        "src/**/*.kt",
    ],

    static_libs: [
        "androidx.test.core",
        "androidx.test.runner",
        "androidx.test.ext.truth",
        "platform-test-annotations",
        "services.core",
        "servicestests-core-utils",
        "truth",
        "frameworks-base-testutils",
        "androidx.test.rules",
    ],

    libs: [
        "android.test.base",
        "android.test.runner",
    ],

    certificate: "platform",
    platform_apis: true,
    test_suites: ["device-tests"],

    optimize: {
        enabled: false,
    },
}
+30 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2024 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="com.android.frameworks.appfunctionstests">

    <application android:testOnly="true"
                 android:debuggable="true">
        <uses-library android:name="android.test.runner" />
    </application>

    <instrumentation
        android:name="androidx.test.runner.AndroidJUnitRunner"
        android:targetPackage="com.android.frameworks.appfunctionstests"
        android:label="Frameworks AppFunctions Services Tests" />

</manifest>
 No newline at end of file
+30 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2024 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="Runs Frameworks AppFunctions Services Tests.">
    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
        <option name="cleanup-apks" value="true" />
        <option name="install-arg" value="-t" />
        <option name="test-file-name" value="FrameworksAppFunctionsTests.apk" />
    </target_preparer>

    <option name="test-tag" value="FrameworksAppFunctionsTests" />

    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
        <option name="package" value="com.android.frameworks.appfunctionstests" />
        <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
        <option name="hidden-api-checks" value="false"/>
    </test>
</configuration>
 No newline at end of file
+57 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.appfunctions

import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@RunWith(JUnit4::class)
class AppFunctionStaticMetadataHelperTest {

    @Test
    fun getStaticSchemaNameForPackage() {
        val actualSchemaName =
            AppFunctionStaticMetadataHelper.getStaticSchemaNameForPackage("com.example.app")

        assertThat(actualSchemaName).isEqualTo("AppFunctionStaticMetadata-com.example.app")
    }

    @Test
    fun getDocumentIdForAppFunction() {
        val packageName = "com.example.app"
        val functionId = "someFunction"

        val actualDocumentId =
            AppFunctionStaticMetadataHelper.getDocumentIdForAppFunction(packageName, functionId)

        assertThat(actualDocumentId).isEqualTo("com.example.app/someFunction")
    }

    @Test
    fun getStaticMetadataQualifiedId() {
        val packageName = "com.example.app"
        val functionId = "someFunction"

        val actualQualifiedId =
            AppFunctionStaticMetadataHelper.getStaticMetadataQualifiedId(packageName, functionId)

        assertThat(actualQualifiedId)
            .isEqualTo("android\$apps-db/app_functions#com.example.app/someFunction")
    }
}