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

Commit e67c24c1 authored by David Duarte's avatar David Duarte
Browse files

BluetoothInstrumentationTests: Remove certificate

And move GoogleBluetoothInstrumentationTests alongside
BluetoothInstrumentationTests as we don't need the google
certificate anymore.

The AndroidTest.xml is duplicated to be able to give
the right value for mainline-module-package-name
for GoogleBluetoothInstrumentationTests

Bug: 258943608
Test: TreeHugger
Ignore-AOSP-First: Will cherry-pick to AOSP
Change-Id: Ia08f1885e1571a85bf256d7a0a0f4c13e29c81a3
Merged-In: Ia08f1885e1571a85bf256d7a0a0f4c13e29c81a3
parent de608b08
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -2,11 +2,8 @@ package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

android_test {
    name: "BluetoothInstrumentationTests",

    // We only want this apk build for tests.
    certificate: ":com.android.bluetooth.certificate",
java_defaults {
    name: "BluetoothInstrumentationTestsDefaults",
    defaults: ["framework-bluetooth-tests-defaults"],

    min_sdk_version: "current",
@@ -51,3 +48,15 @@ android_test {

    instrumentation_for: "Bluetooth",
}

android_test {
    name: "BluetoothInstrumentationTests",
    defaults: ["BluetoothInstrumentationTestsDefaults"],
}

android_test {
    name: "GoogleBluetoothInstrumentationTests",
    defaults: ["BluetoothInstrumentationTestsDefaults"],
    test_config: "GoogleAndroidTest.xml",
    instrumentation_target_package: "com.google.android.bluetooth",
}
+1 −2
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.android.bluetooth.tests"
          android:sharedUserId="android.uid.bluetooth">
          package="com.android.bluetooth.tests">

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.ACCESS_BLUETOOTH_SHARE" />
+2 −3
Original line number Diff line number Diff line
@@ -40,9 +40,8 @@
        <option name="package" value="com.android.bluetooth.tests" />
        <!-- include and exclude filters go into /data/local/tmp/ajur/ by default
             However it's prohibited for access by system uid packages.
             So instead we use the test data folder for filter. This is applicable
             here as we are root. -->
        <option name="test-filter-dir" value="/data/data/com.android.bluetooth.tests" />
             So instead we use the app cache folder for filter -->
        <option name="test-filter-dir" value="/data/data/com.android.bluetooth/cache" />
        <option name="hidden-api-checks" value="false"/>
    </test>

+52 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 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 Bluetooth Test Cases.">
    <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="test-file-name" value="GoogleBluetoothInstrumentationTests.apk" />
    </target_preparer>
    <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
        <option name="force-root" value="true" />
    </target_preparer>
    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
        <option name="throw-if-cmd-fail" value="true" />
        <option name="run-command" value="settings put global ble_scan_always_enabled 0" />
        <option name="run-command" value="cmd bluetooth_manager disable" />
        <option name="run-command" value="setprop bluetooth.profile.hfp.hf.enabled true" />
        <option name="teardown-command" value="cmd bluetooth_manager enable" />
        <option name="teardown-command" value="settings put global ble_scan_always_enabled 1" />
    </target_preparer>
    <target_preparer class="com.android.tradefed.targetprep.FolderSaver">
        <option name="device-path" value="/data/vendor/ssrdump" />
    </target_preparer>
    <option name="test-tag" value="GoogleBluetoothInstrumentationTests" />
    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
        <option name="package" value="com.android.bluetooth.tests" />
        <!-- include and exclude filters go into /data/local/tmp/ajur/ by default
             However it's prohibited for access by system uid packages.
             So instead we use the app cache folder for filter -->
        <option name="test-filter-dir" value="/data/data/com.google.android.bluetooth/cache" />
        <option name="hidden-api-checks" value="false"/>
    </test>

    <!-- Only run Cts Tests in MTS if the Bluetooth Mainline module is installed. -->
    <object type="module_controller"
            class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
        <option name="mainline-module-package-name" value="com.google.android.btservices" />
    </object>
</configuration>
+6 −11
Original line number Diff line number Diff line
@@ -205,19 +205,14 @@ public class TestUtils {
    }

    public static Resources getTestApplicationResources(Context context) {
        for (String name: context.getPackageManager().getPackagesForUid(Process.BLUETOOTH_UID)) {
            if (name.contains(".android.bluetooth.tests")) {
        try {
                    return context.getPackageManager().getResourcesForApplication(name);
            return context.getPackageManager().getResourcesForApplication("com.android.bluetooth.tests");
        } catch (PackageManager.NameNotFoundException e) {
            assertWithMessage("Setup Failure: Unable to get test application resources"
                    + e.toString()).fail();
                }
            }
        }
        assertWithMessage("Could not find tests package").fail();
            return null;
        }
    }

    /**
     * Wait and verify that an intent has been received.