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

Commit 8bc4c239 authored by James Wei's avatar James Wei
Browse files

USB: Add test for UsbManager APIs

Make sure UsbManager APIs could only be accessed with required permission

Bug: 142372304
Test: atest UsbTests
Test: atest UsbManagerTests
Test: Forrest (L06700000406507070)
Change-Id: Ibe3337aaa965ba670c3ac363299612f367231f05
parent a4aff1e1
Loading
Loading
Loading
Loading
+32 −0
Original line number Original line Diff line number Diff line
//
// 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: "UsbManagerTests",
    srcs: ["src/**/*.java"],
    static_libs: [
        "frameworks-base-testutils",
        "androidx.test.rules",
        "mockito-target-inline-minus-junit4",
        "platform-test-annotations",
        "truth-prebuilt",
        "UsbManagerTestLib",
    ],
    jni_libs: ["libdexmakerjvmtiagent"],
    certificate: "platform",
    platform_apis: true,
    test_suites: ["device-tests"],
}
+29 −0
Original line number Original line Diff line number Diff line
<?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="com.android.server.usbtest" >

    <uses-permission android:name="android.permission.MANAGE_USB" />

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

    <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
                     android:targetPackage="com.android.server.usbtest"
                     android:label="UsbManagerTests"/>
</manifest>
+31 −0
Original line number Original line Diff line number Diff line
<?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="Runs Frameworks USB API instrumentation Tests.">
    <target_preparer class="com.android.tradefed.targetprep.TestFilePushSetup"/>
    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
        <option name="test-file-name" value="UsbManagerTests.apk" />
    </target_preparer>
    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"/>
    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"/>
    <option name="test-suite-tag" value="apct"/>
    <option name="test-tag" value="UsbManagerTests" />

    <test class="com.android.tradefed.testtype.AndroidJUnitTest">
        <option name="package" value="com.android.server.usbtest"/>
        <option name="runner" value="androidx.test.runner.AndroidJUnitRunner"/>
        <option name="hidden-api-checks" value="false"/>
    </test>
</configuration>
+34 −0
Original line number Original line Diff line number Diff line
//
// 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_library {
    name: "UsbManagerTestLib",
    srcs: ["src/**/*.java"],
    static_libs: [
        "frameworks-base-testutils",
        "androidx.test.rules",
        "mockito-target-inline-minus-junit4",
        "platform-test-annotations",
        "services.core",
        "services.net",
        "services.usb",
        "truth-prebuilt",
        "androidx.core_core",
    ],
    libs: [
        "android.test.mock",
    ],
}
+22 −0
Original line number Original line Diff line number Diff line
<?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="com.android.server.usblib">

    <application/>

</manifest>
Loading