Search in sources :

Example 31 with SmallTest

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());
}
Also used : Binder(android.os.Binder) SmallTest(android.support.test.filters.SmallTest)

Example 32 with SmallTest

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());
}
Also used : Binder(android.os.Binder) SmallTest(android.support.test.filters.SmallTest)

Example 33 with SmallTest

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());
        }
    });
}
Also used : Parcelable(android.os.Parcelable) SmallTest(android.support.test.filters.SmallTest) UiThreadTest(android.support.test.annotation.UiThreadTest) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 34 with SmallTest

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());
}
Also used : PagerAdapter(android.support.v4.view.PagerAdapter) SmallTest(android.support.test.filters.SmallTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest) SmallTest(android.support.test.filters.SmallTest)

Example 35 with SmallTest

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());
}
Also used : PagerAdapter(android.support.v4.view.PagerAdapter) SmallTest(android.support.test.filters.SmallTest) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest) SmallTest(android.support.test.filters.SmallTest)

Aggregations

SmallTest (android.support.test.filters.SmallTest)252 Test (org.junit.Test)137 AbstractExistingDBTest (org.liberty.android.fantastischmemo.test.AbstractExistingDBTest)86 Parcel (android.os.Parcel)48 TimeBase (com.android.internal.os.BatteryStatsImpl.TimeBase)45 Card (org.liberty.android.fantastischmemo.entity.Card)43 CardDao (org.liberty.android.fantastischmemo.dao.CardDao)37 Setting (org.liberty.android.fantastischmemo.entity.Setting)21 Binder (android.os.Binder)20 Category (org.liberty.android.fantastischmemo.entity.Category)17 AbstractPreferencesTest (org.liberty.android.fantastischmemo.test.AbstractPreferencesTest)17 LearningData (org.liberty.android.fantastischmemo.entity.LearningData)15 UiThreadTest (android.support.test.annotation.UiThreadTest)14 CategoryDao (org.liberty.android.fantastischmemo.dao.CategoryDao)13 LocaleList (android.os.LocaleList)10 Option (org.liberty.android.fantastischmemo.entity.Option)9 QueueManager (org.liberty.android.fantastischmemo.queue.QueueManager)9 ContentResolver (android.content.ContentResolver)8 Cursor (android.database.Cursor)8 OnTickListener (com.tmall.wireless.tangram.support.TimerSupport.OnTickListener)8