Search in sources :

Example 1 with Presubmit

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

the class LifecycleEventHandlingTest method launchDashboard_shouldSeeFooter.

@Test
@Presubmit
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) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 2 with Presubmit

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

the class SettingsGatewayTest method publicFragmentMustAppearInSettingsGateway.

@Test
@Presubmit
public void publicFragmentMustAppearInSettingsGateway() throws PackageManager.NameNotFoundException {
    final List<String> whitelistedFragment = new ArrayList<>();
    final StringBuilder error = new StringBuilder();
    for (String fragment : SettingsGateway.ENTRY_FRAGMENTS) {
        whitelistedFragment.add(fragment);
    }
    final PackageInfo pi = mPackageManager.getPackageInfo(mPackageName, GET_META_DATA | MATCH_DISABLED_COMPONENTS | GET_ACTIVITIES);
    final List<ActivityInfo> activities = Arrays.asList(pi.activities);
    for (ActivityInfo activity : activities) {
        final Bundle metaData = activity.metaData;
        if (metaData == null || !metaData.containsKey(META_DATA_KEY_FRAGMENT_CLASS)) {
            continue;
        }
        final String fragmentName = metaData.getString(META_DATA_KEY_FRAGMENT_CLASS);
        assertThat(fragmentName).isNotNull();
        if (!whitelistedFragment.contains(fragmentName)) {
            error.append("SettingsGateway.ENTRY_FRAGMENTS must contain " + fragmentName + " because this fragment is used in manifest for " + activity.name).append("\n");
        }
    }
    final String message = error.toString();
    if (!TextUtils.isEmpty(message)) {
        fail(message);
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) PackageInfo(android.content.pm.PackageInfo) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Presubmit(android.platform.test.annotations.Presubmit) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 3 with Presubmit

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

the class SettingsGatewayTest method allRestrictedActivityMustBeDefinedInManifest.

@Test
@Presubmit
public void allRestrictedActivityMustBeDefinedInManifest() {
    for (String className : SettingsGateway.SETTINGS_FOR_RESTRICTED) {
        final Intent intent = new Intent();
        intent.setComponent(new ComponentName(mPackageName, className));
        List<ResolveInfo> resolveInfos = mPackageManager.queryIntentActivities(intent, MATCH_DISABLED_COMPONENTS);
        Log.d(TAG, mPackageName + "/" + className + "; resolveInfo size: " + resolveInfos.size());
        assertFalse(className + " is not-defined in manifest", resolveInfos.isEmpty());
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Presubmit(android.platform.test.annotations.Presubmit) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 4 with Presubmit

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

the class PreferenceControllerContractTest method controllersInSearchShouldImplementPreferenceControllerMixin.

@Test
@Presubmit
public void controllersInSearchShouldImplementPreferenceControllerMixin() {
    // Required by AutofillLoggingLevelPreferenceController
    Looper.prepare();
    final Set<String> errorClasses = new ArraySet<>();
    final SearchIndexableResources resources = FeatureFactory.getFactory(mContext).getSearchFeatureProvider().getSearchIndexableResources();
    for (Class<?> clazz : resources.getProviderValues()) {
        final Indexable.SearchIndexProvider provider = DatabaseIndexingUtils.getSearchIndexProvider(clazz);
        if (provider == null) {
            continue;
        }
        final List<AbstractPreferenceController> controllers = provider.getPreferenceControllers(mContext);
        if (controllers == null) {
            continue;
        }
        for (AbstractPreferenceController controller : controllers) {
            if (!(controller instanceof PreferenceControllerMixin) && !(controller instanceof BasePreferenceController)) {
                errorClasses.add(controller.getClass().getName());
            }
        }
    }
    if (!errorClasses.isEmpty()) {
        final StringBuilder errorMessage = new StringBuilder().append("Each preference must implement PreferenceControllerMixin ").append("or extend BasePreferenceController, ").append("the following classes don't:\n");
        for (String c : errorClasses) {
            errorMessage.append(c).append("\n");
        }
        fail(errorMessage.toString());
    }
}
Also used : ArraySet(android.util.ArraySet) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Indexable(com.android.settings.search.Indexable) SearchIndexableResources(com.android.settingslib.search.SearchIndexableResources) Presubmit(android.platform.test.annotations.Presubmit) MediumTest(androidx.test.filters.MediumTest) Test(org.junit.Test)

Example 5 with Presubmit

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

the class HomepageDisplayTests method testHomepageCategory.

@Presubmit
@Test
public void testHomepageCategory() throws Exception {
    // Launch Settings
    SettingsHelper.launchSettingsPage(InstrumentationRegistry.getContext(), Settings.ACTION_SETTINGS);
    // Scroll to top
    final UiObject2 view = mDevice.wait(Until.findObject(By.res(SETTINGS_PACKAGE, "main_content")), TIMEOUT);
    view.scroll(Direction.UP, 100f);
    // Inspect each item
    for (String item : HOMEPAGE_ITEMS) {
        SettingsTestUtils.assertTitleMatch(mDevice, item);
    }
}
Also used : UiObject2(android.support.test.uiautomator.UiObject2) 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