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

Commit f40566e3 authored by jovanak's avatar jovanak
Browse files

Modifying test to exclude automotive specific classes if running in

non-automotive build.

Without this, test will fail to find car-related dependencies on non-car build
and throw.

Bug: 80150596
Test: Ran the test on phone (non-automotive) and mojave (automotive). Both passed successfully.
Change-Id: I3d3d2639ebebc0474b28d5c9303b83c95820eac4
parent 2c1bf635
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;

import android.content.pm.PackageManager;
import android.support.test.filters.LargeTest;
import android.support.test.filters.MediumTest;
import android.support.test.filters.SmallTest;
@@ -115,6 +116,13 @@ public class AAAPlusPlusVerifySysuiRequiredTestPropertiesTest extends SysuiTestC
        filter.add(new ExternalClassNameFilter());
        filter.add(s -> s.startsWith("com.android.systemui")
                || s.startsWith("com.android.keyguard"));


        if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
            // If it's not automotive target, exclude automotive classes from the test.
            excludeAutomotiveClasses(filter);
        }

        try {
            return scanner.getClassPathEntries(filter);
        } catch (IOException e) {
@@ -123,6 +131,13 @@ public class AAAPlusPlusVerifySysuiRequiredTestPropertiesTest extends SysuiTestC
        return Collections.emptyList();
    }

    private void excludeAutomotiveClasses(ChainedClassNameFilter filter) {
        // Modifies the passed in filter.
        filter.add(s -> !s.startsWith("com.android.systemui.statusbar.car."));
        filter.add(s -> !s.startsWith("com.android.systemui.qs.car."));
        filter.add(s -> !s.startsWith("com.android.systemui.car."));
    }

    private String getClsStr() {
        return TextUtils.join(",", Arrays.asList(BASE_CLS_WHITELIST)
                .stream().map(cls -> cls.getSimpleName()).toArray());