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

Commit 65fbba60 authored by Lais Andrade's avatar Lais Andrade
Browse files

Extract vibrator service tests from FrameworksServicesTests

Move all tests for package com.android.server.vibrator from
frameworks/base/services/tests/servicestests to a new folder
frameworks/base/services/tests/vibratorservicestests.

Create a new private java library for test utility classes in a new
folder vibratorservicestests/utils, with fake implementations used in
service tests.

Create a new android_test module VibratorServiceTests for the moved
tests, configured for pre/postsubmit test mappings.

Fix: 290745798
Test: atest VibratorServiceTests
Change-Id: I07cb81f484584cada371a00f2d3e798350ddf8f2
parent 15d68f41
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
# Bug component: 345036

lsandrade@google.com
michaelwr@google.com
sbowden@google.com
khalilahmad@google.com
 No newline at end of file
+62 −0
Original line number Diff line number Diff line
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: "FrameworksVibratorServicesTests",

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

    libs: [
        "android.hardware.vibrator-V2-java",
        "android.test.mock",
        "android.test.base",
        "android.test.runner",
    ],

    static_libs: [
        "androidx.test.core",
        "androidx.test.ext.truth",
        "androidx.test.runner",
        "androidx.test.rules",
        "androidx.test.ext.junit",
        "frameworks-base-testutils",
        "frameworks-services-vibrator-testutils",
        "junit",
        "mockito-target-minus-junit4",
        "platform-test-annotations",
        "service-permission.stubs.system_server",
        "services.core",
    ],

    platform_apis: true,
    certificate: "platform",
    dxflags: ["--multi-dex"],

    test_suites: [
        "device-tests",
        "automotive-tests",
    ],

    optimize: {
        enabled: false,
    },
}

java_library {
    name: "frameworks-services-vibrator-testutils",
    visibility: [":__subpackages__"],
    srcs: [
        "utils/**/*.java",
    ],
    static_libs: [
        "services.core",
    ],
}
+45 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 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.framework.services.tests.vibrator">

    <!-- Required to set user settings -->
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
    <!-- Required to register uid observer -->
    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
    <!-- Required to acquire wake locks during vibrations -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
    <!-- Required to request vibrations -->
    <uses-permission android:name="android.permission.VIBRATE" />
    <!-- Required to listen to the vibrator state -->
    <uses-permission android:name="android.permission.ACCESS_VIBRATOR_STATE" />
    <!-- Required to set always-on vibrations -->
    <uses-permission android:name="android.permission.VIBRATE_ALWAYS_ON" />

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

    <instrumentation
        android:name="androidx.test.runner.AndroidJUnitRunner"
        android:label="Vibrator Service Tests"
        android:targetPackage="com.android.framework.services.tests.vibrator" />

</manifest>
+34 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 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 Vibrator Services Tests.">
    <option name="test-suite-tag" value="apct" />
    <option name="test-suite-tag" value="apct-instrumentation" />

    <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="FrameworksVibratorServicesTests.apk" />
    </target_preparer>

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

    <test class="com.android.tradefed.testtype.AndroidJUnitTest">
        <option name="package" value="com.android.framework.services.tests.vibrator" />
        <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
        <option name="hidden-api-checks" value="false" />
    </test>
</configuration>
Loading