Search in sources :

Example 6 with Presubmit

use of android.platform.test.annotations.Presubmit in project android_packages_apps_Settings by omnirom.

the class LifecycleEventHandlingTest method launchDashboard_shouldSeeFooter.

@Test
@Presubmit
@Ignore("b/133334887")
public void launchDashboard_shouldSeeFooter() {
    new SubSettingLauncher(mContext).setDestination(FeatureFlagsDashboard.class.getName()).setSourceMetricsCategory(Instrumentable.METRICS_CATEGORY_UNKNOWN).addFlags(FLAG_ACTIVITY_NEW_TASK).launch();
    final String footerText = "Experimental";
    // Scroll to bottom
    final UiObject2 view = mDevice.wait(Until.findObject(By.res(mTargetPackage, "main_content")), TIMEOUT);
    view.scroll(Direction.DOWN, 100f);
    assertThat(mDevice.wait(Until.findObject(By.text(footerText)), TIMEOUT)).isNotNull();
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) Presubmit(android.platform.test.annotations.Presubmit) Ignore(org.junit.Ignore) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 7 with Presubmit

use of android.platform.test.annotations.Presubmit in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SettingsSearchResultRegressionTest method searchResultsDoNotRegress.

/**
 * Tests that the set of search results does not regress.
 * <p>
 * The data set used here (/tests/unit/assets/search_results_list) needs to be updated
 * every once in a while so that we can check newly added results.
 * </p>
 */
@Test
@Presubmit
public void searchResultsDoNotRegress() {
    final ContentResolver resolver = mContext.getContentResolver();
    final Uri uri = getTestProviderUri();
    if (uri == null) {
        Log.e(TAG, "Something is wrong getting test provider uri, skipping");
        return;
    }
    final Cursor cursor = resolver.query(uri, null, null, null, null);
    if (cursor == null) {
        // Assume Settings Intelligence is wrong.
        return;
    }
    final Set<SearchData> availableSearchResults = getSearchDataFromCursor(cursor);
    final Set<SearchData> registeredSearchResults = getRegisteredResults();
    // Seed with results that we expect
    final Set<SearchData> missingSearchResults = new HashSet<>(registeredSearchResults);
    // Seed with results that are available
    final Set<SearchData> newSearchResults = new HashSet<>(availableSearchResults);
    // Remove all available results, leaving results that have been removed.
    missingSearchResults.removeAll(availableSearchResults);
    // Remove all results we expect, leaving results that have not yet been registered.
    newSearchResults.removeAll(registeredSearchResults);
    assertWithMessage(ERROR_RESULTS_MISSING + ERROR_RERUN_TEST).that(missingSearchResults).isEmpty();
    assertWithMessage(ERROR_NEW_RESULTS + ERROR_RERUN_TEST).that(newSearchResults).isEmpty();
}
Also used : Cursor(android.database.Cursor) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver) HashSet(java.util.HashSet) Presubmit(android.platform.test.annotations.Presubmit) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 8 with Presubmit

use of android.platform.test.annotations.Presubmit in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceDataContractTest method preferenceWithControllerMustHaveNonEmptyTitle.

@Test
@Presubmit
public void preferenceWithControllerMustHaveNonEmptyTitle() throws IOException, XmlPullParserException {
    final Set<String> nullTitleFragments = new HashSet<>();
    final SearchIndexableResources resources = FeatureFactory.getFactory(mContext).getSearchFeatureProvider().getSearchIndexableResources();
    for (Class<?> clazz : resources.getProviderValues()) {
        verifyPreferenceTitle(nullTitleFragments, clazz);
    }
    if (!nullTitleFragments.isEmpty()) {
        final StringBuilder error = new StringBuilder("All preferences with a controller must have a non-empty title by default, " + "found empty title in the following fragments\n");
        for (String c : nullTitleFragments) {
            error.append(c).append("\n");
        }
        fail(error.toString());
    }
}
Also used : SearchIndexableResources(com.android.settingslib.search.SearchIndexableResources) HashSet(java.util.HashSet) Presubmit(android.platform.test.annotations.Presubmit) MediumTest(androidx.test.filters.MediumTest) Test(org.junit.Test)

Example 9 with Presubmit

use of android.platform.test.annotations.Presubmit in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SettingsSearchIndexablesProviderTest method nonIndexableKeys_shouldNotCrash.

/**
 * All {@link Indexable.SearchIndexProvider} should collect a list of non-indexable keys
 * without crashing. This test enables crashing of individual providers in the indexing pipeline
 * and checks that there are no crashes.
 */
@Test
@Presubmit
public void nonIndexableKeys_shouldNotCrash() {
    // Allow crashes in the indexing pipeline.
    System.setProperty(SettingsSearchIndexablesProvider.SYSPROP_CRASH_ON_ERROR, "enabled");
    final Uri uri = Uri.parse("content://" + mContext.getPackageName() + "/" + SearchIndexablesContract.NON_INDEXABLES_KEYS_PATH);
    mContext.getContentResolver().query(uri, null, null, null, null);
}
Also used : Uri(android.net.Uri) Presubmit(android.platform.test.annotations.Presubmit) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 10 with Presubmit

use of android.platform.test.annotations.Presubmit in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class UniquePreferenceTest method allPreferencesShouldHaveUniqueKey.

/**
 * All preferences should have their unique key. It's especially important for many parts of
 * Settings to work properly: we assume pref keys are unique in displaying, search ranking,\
 * search result suppression, and many other areas.
 * <p/>
 * So in this test we are checking preferences participating in search.
 * <p/>
 * Note: Preference is not limited to just <Preference/> object. Everything in preference xml
 * should have a key.
 */
@Test
@Presubmit
public void allPreferencesShouldHaveUniqueKey() throws IOException, XmlPullParserException, Resources.NotFoundException {
    final Set<String> uniqueKeys = new HashSet<>();
    final Set<String> nullKeyClasses = new HashSet<>();
    final Set<String> duplicatedKeys = new HashSet<>();
    final SearchIndexableResources resources = FeatureFactory.getFactory(mContext).getSearchFeatureProvider().getSearchIndexableResources();
    for (Class<?> clazz : resources.getProviderValues()) {
        verifyPreferenceKeys(uniqueKeys, duplicatedKeys, nullKeyClasses, clazz);
    }
    if (!nullKeyClasses.isEmpty()) {
        final StringBuilder nullKeyErrors = new StringBuilder().append("Each preference/SearchIndexableData must have a key, ").append("the following classes have null keys:\n");
        for (String c : nullKeyClasses) {
            nullKeyErrors.append(c).append("\n");
        }
        fail(nullKeyErrors.toString());
    }
    if (!duplicatedKeys.isEmpty()) {
        final StringBuilder dupeKeysError = new StringBuilder("The following keys are not unique\n");
        for (String c : duplicatedKeys) {
            dupeKeysError.append(c).append("\n");
        }
        fail(dupeKeysError.toString());
    }
}
Also used : SearchIndexableResources(com.android.settingslib.search.SearchIndexableResources) HashSet(java.util.HashSet) Presubmit(android.platform.test.annotations.Presubmit) MediumTest(androidx.test.filters.MediumTest) Test(org.junit.Test)

Aggregations

Presubmit (android.platform.test.annotations.Presubmit)12 Test (org.junit.Test)12 SmallTest (androidx.test.filters.SmallTest)7 MediumTest (androidx.test.filters.MediumTest)5 UiObject2 (android.support.test.uiautomator.UiObject2)4 Uri (android.net.Uri)3 SearchIndexableResources (com.android.settingslib.search.SearchIndexableResources)3 HashSet (java.util.HashSet)3 ComponentName (android.content.ComponentName)1 ContentResolver (android.content.ContentResolver)1 Intent (android.content.Intent)1 ActivityInfo (android.content.pm.ActivityInfo)1 PackageInfo (android.content.pm.PackageInfo)1 ResolveInfo (android.content.pm.ResolveInfo)1 Cursor (android.database.Cursor)1 Bundle (android.os.Bundle)1 ArraySet (android.util.ArraySet)1 Indexable (com.android.settings.search.Indexable)1 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)1 ArrayList (java.util.ArrayList)1