use of android.support.test.filters.SmallTest in project platform_frameworks_base by android.
the class ResourcesManagerTest method testTwoActivitiesWithIdenticalParametersShareImpl.
@SmallTest
public void testTwoActivitiesWithIdenticalParametersShareImpl() {
Binder activity1 = new Binder();
Resources resources1 = mResourcesManager.getResources(activity1, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
assertNotNull(resources1);
Binder activity2 = new Binder();
Resources resources2 = mResourcesManager.getResources(activity2, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
assertNotNull(resources1);
// The references themselves should be unique.
assertNotSame(resources1, resources2);
// The implementations should be the same.
assertSame(resources1.getImpl(), resources2.getImpl());
}
use of android.support.test.filters.SmallTest in project platform_frameworks_base by android.
the class ResourcesManagerTest method testMultipleResourcesForOneActivityGetUpdatedWhenActivityBaseUpdates.
@SmallTest
public void testMultipleResourcesForOneActivityGetUpdatedWhenActivityBaseUpdates() {
Binder activity1 = new Binder();
// Create a Resources for the Activity.
Configuration config1 = new Configuration();
config1.densityDpi = 280;
Resources resources1 = mResourcesManager.createBaseActivityResources(activity1, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, config1, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
assertNotNull(resources1);
// Create a Resources based on the Activity.
Configuration config2 = new Configuration();
config2.screenLayout |= Configuration.SCREENLAYOUT_ROUND_YES;
Resources resources2 = mResourcesManager.getResources(activity1, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, config2, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
assertNotNull(resources2);
assertNotSame(resources1, resources2);
assertNotSame(resources1.getImpl(), resources2.getImpl());
final Configuration expectedConfig1 = new Configuration();
expectedConfig1.setLocales(LocaleList.getAdjustedDefault());
expectedConfig1.densityDpi = 280;
assertEquals(expectedConfig1, resources1.getConfiguration());
// resources2 should be based on the Activity's override config, so the density should
// be the same as resources1.
final Configuration expectedConfig2 = new Configuration();
expectedConfig2.setLocales(LocaleList.getAdjustedDefault());
expectedConfig2.densityDpi = 280;
expectedConfig2.screenLayout |= Configuration.SCREENLAYOUT_ROUND_YES;
assertEquals(expectedConfig2, resources2.getConfiguration());
// Now update the Activity base override, and both resources should update.
config1.orientation = Configuration.ORIENTATION_LANDSCAPE;
mResourcesManager.updateResourcesForActivity(activity1, config1);
expectedConfig1.orientation = Configuration.ORIENTATION_LANDSCAPE;
assertEquals(expectedConfig1, resources1.getConfiguration());
expectedConfig2.orientation = Configuration.ORIENTATION_LANDSCAPE;
assertEquals(expectedConfig2, resources2.getConfiguration());
}
use of android.support.test.filters.SmallTest in project material-components-android by material-components.
the class BottomNavigationViewTest method testSavedState.
@Test
@SmallTest
public void testSavedState() throws Throwable {
// Select an item other than the first
onView(allOf(withText(mMenuStringContent.get(R.id.destination_profile)), isDescendantOfA(withId(R.id.bottom_navigation)), isDisplayed())).perform(click());
assertTrue(mBottomNavigation.getMenu().findItem(R.id.destination_profile).isChecked());
// Save the state
final Parcelable state = mBottomNavigation.onSaveInstanceState();
// Restore the state into a fresh BottomNavigationView
activityTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
BottomNavigationView testView = new BottomNavigationView(activityTestRule.getActivity());
testView.inflateMenu(R.menu.bottom_navigation_view_content);
testView.onRestoreInstanceState(state);
assertTrue(testView.getMenu().findItem(R.id.destination_profile).isChecked());
}
});
}
use of android.support.test.filters.SmallTest in project material-components-android by material-components.
the class TabLayoutWithViewPagerTest method testBasicAutoRefreshDisabled.
@Test
@SmallTest
public void testBasicAutoRefreshDisabled() {
onView(withId(R.id.tabs)).perform(setupWithViewPager(mViewPager, false));
// Check that the TabLayout has the same number of items are the adapter
PagerAdapter initialAdapter = mViewPager.getAdapter();
assertEquals("Initial adapter page count", initialAdapter.getCount(), mTabLayout.getTabCount());
// Add two more entries to our adapter
mDefaultPagerAdapter.add("Yellow", Color.YELLOW);
mDefaultPagerAdapter.add("Magenta", Color.MAGENTA);
final int newItemCount = mDefaultPagerAdapter.getCount();
// Assert that the TabLayout did not update and add the new items
assertNotEquals("Matching item count", newItemCount, mTabLayout.getTabCount());
// Now setup again to update the tabs
onView(withId(R.id.tabs)).perform(setupWithViewPager(mViewPager, false));
// Assert that the TabLayout updated and added the new items
assertEquals("Matching item count", newItemCount, mTabLayout.getTabCount());
}
use of android.support.test.filters.SmallTest in project material-components-android by material-components.
the class TabLayoutWithViewPagerTest method testAdapterContentChangeWithAutoRefreshDisabled.
@Test
@SmallTest
public void testAdapterContentChangeWithAutoRefreshDisabled() {
onView(withId(R.id.tabs)).perform(setupWithViewPager(mViewPager, false));
// Verify that we have the expected initial adapter
PagerAdapter initialAdapter = mViewPager.getAdapter();
assertEquals("Initial adapter class", ColorPagerAdapter.class, initialAdapter.getClass());
assertEquals("Initial adapter page count", 3, initialAdapter.getCount());
// Add two more entries to our adapter
onView(withId(R.id.tabs_viewpager)).perform(addItemsToPager(new String[] { "Yellow", "Magenta" }, new Integer[] { Color.YELLOW, Color.MAGENTA }));
// Assert that the TabLayout did not update and add the new items
final int newItemCount = mDefaultPagerAdapter.getCount();
assertNotEquals("Matching item count", newItemCount, mTabLayout.getTabCount());
}
Aggregations