androidx.test.filters.SmallTest Java Examples
The following examples show how to use
androidx.test.filters.SmallTest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestSizeTest.java From android-test with Apache License 2.0 | 6 votes |
@Test public void isAnyTestSize_ContainsPlatformAndRunnerFilterAnnotations() { assertThat(TestSize.isAnyTestSize(SmallTest.class), equalTo(true)); assertThat(TestSize.isAnyTestSize(MediumTest.class), equalTo(true)); assertThat(TestSize.isAnyTestSize(LargeTest.class), equalTo(true)); assertThat( TestSize.isAnyTestSize(android.test.suitebuilder.annotation.SmallTest.class), equalTo(true)); assertThat( TestSize.isAnyTestSize(android.test.suitebuilder.annotation.MediumTest.class), equalTo(true)); assertThat( TestSize.isAnyTestSize(android.test.suitebuilder.annotation.LargeTest.class), equalTo(true)); }
Example #2
Source File: DatabaseGeneralTest.java From sqlite-android with Apache License 2.0 | 6 votes |
@SmallTest @Test public void testSetMaxCacheSize() { mDatabase.execSQL("CREATE TABLE test (i int, j int);"); mDatabase.execSQL("insert into test values(1,1);"); // set cache size int N = SQLiteDatabase.MAX_SQL_CACHE_SIZE; mDatabase.setMaxSqlCacheSize(N); // try reduce cachesize try { mDatabase.setMaxSqlCacheSize(1); } catch (IllegalStateException e) { assertTrue(e.getMessage().contains("cannot set cacheSize to a value less than")); } }
Example #3
Source File: FloatingActionButtonTest.java From material-components-android with Apache License 2.0 | 6 votes |
@Test @SmallTest public void testSetStatefulTintAcrossStateChanges() { final Activity activity = activityTestRule.getActivity(); final ColorStateList tint = ContextCompat.getColorStateList(activity, R.color.fab_tint); final int normal = ContextCompat.getColor(activity, R.color.sand_default); final int notSelected = ContextCompat.getColor(activity, R.color.sand_disabled); // First set the background tint list to the ColorStateList onView(withId(R.id.fab_standard)).perform(setBackgroundTintList(tint)); // Assert that the background is tinted correctly across state changes onView(withId(R.id.fab_standard)) .perform(setSelected(true)) .check(matches(withFabBackgroundFill(normal))) .perform(setSelected(false)) .check(matches(withFabBackgroundFill(notSelected))) .perform(setSelected(true)) .check(matches(withFabBackgroundFill(normal))); }
Example #4
Source File: BottomNavigationViewTest.java From material-components-android with Apache License 2.0 | 6 votes |
@UiThreadTest @Test @SmallTest public void testSettingMenuItemVisibility() throws Throwable { final MenuItem homeMenuItem = bottomNavigation.getMenu().findItem(R.id.destination_home); assertTrue(homeMenuItem.isVisible()); homeMenuItem.setVisible(false); assertFalse(homeMenuItem.isVisible()); bottomNavigation.getMenu().clear(); bottomNavigation.inflateMenu(R.menu.bottom_navigation_view_with_invisible_button_content); assertEquals(3, bottomNavigation.getMenu().size()); final MenuItem destinationMenuItem = bottomNavigation.getMenu().findItem(R.id.destination_profile); assertFalse(destinationMenuItem.isVisible()); destinationMenuItem.setVisible(true); assertTrue(destinationMenuItem.isVisible()); }
Example #5
Source File: BottomNavigationViewTest.java From material-components-android with Apache License 2.0 | 6 votes |
@UiThreadTest @Test @SmallTest public void testSettingAutoItemVisibility() throws Throwable { bottomNavigation.getMenu().clear(); bottomNavigation.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_AUTO); bottomNavigation.inflateMenu( R.menu.bottom_navigation_view_shifting_with_invisible_button_content); assertEquals(4, bottomNavigation.getMenu().size()); final MenuItem destinationMenuItem = bottomNavigation.getMenu().findItem(R.id.destination_profile); assertFalse(destinationMenuItem.isVisible()); destinationMenuItem.setVisible(true); assertTrue(destinationMenuItem.isVisible()); }
Example #6
Source File: BottomNavigationViewTest.java From material-components-android with Apache License 2.0 | 6 votes |
@UiThreadTest @Test @SmallTest @SdkSuppress(minSdkVersion = Build.VERSION_CODES.N) @TargetApi(Build.VERSION_CODES.N) public void testPointerIcon() throws Throwable { final Activity activity = activityTestRule.getActivity(); final PointerIcon expectedIcon = PointerIcon.getSystemIcon(activity, PointerIcon.TYPE_HAND); final MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_HOVER_MOVE, 0, 0, 0); final Menu menu = bottomNavigation.getMenu(); for (int i = 0; i < menu.size(); i++) { final MenuItem item = menu.getItem(i); assertTrue(item.isEnabled()); final View itemView = activity.findViewById(item.getItemId()); assertEquals(expectedIcon, itemView.onResolvePointerIcon(event, 0)); item.setEnabled(false); assertEquals(null, itemView.onResolvePointerIcon(event, 0)); item.setEnabled(true); assertEquals(expectedIcon, itemView.onResolvePointerIcon(event, 0)); } }
Example #7
Source File: DatabaseLocaleTest.java From sqlite-android with Apache License 2.0 | 6 votes |
@SmallTest @Test public void testHoge() throws Exception { Cursor cursor = null; try { String expectedString = new String(new int[] {0xFE000}, 0, 1); mDatabase.execSQL("INSERT INTO test(id, data) VALUES(1, '" + expectedString + "')"); cursor = mDatabase.rawQuery("SELECT data FROM test WHERE id = 1", null); assertNotNull(cursor); assertTrue(cursor.moveToFirst()); String actualString = cursor.getString(0); assertEquals(expectedString.length(), actualString.length()); for (int i = 0; i < expectedString.length(); i++) { assertEquals((int)expectedString.charAt(i), (int)actualString.charAt(i)); } assertEquals(expectedString, actualString); } finally { if (cursor != null) cursor.close(); } }
Example #8
Source File: FloatingActionButtonTest.java From material-components-android with Apache License 2.0 | 6 votes |
@Test @SmallTest public void testSetSizeToggle() { final int miniSize = activityTestRule .getActivity() .getResources() .getDimensionPixelSize(R.dimen.fab_mini_height); final int normalSize = activityTestRule .getActivity() .getResources() .getDimensionPixelSize(R.dimen.fab_normal_height); onView(withId(R.id.fab_standard)) .perform(setSize(FloatingActionButton.SIZE_MINI)) .check(matches(withFabContentHeight(miniSize))); onView(withId(R.id.fab_standard)) .perform(setSize(FloatingActionButton.SIZE_NORMAL)) .check(matches(withFabContentHeight(normalSize))); }
Example #9
Source File: TabLayoutPoolingTest.java From material-components-android with Apache License 2.0 | 6 votes |
@UiThreadTest @SmallTest @Test public void testUsingTabsFromOtherInstance() { final Activity activity = activityTestRule.getActivity(); // TabLayout1 has items added via the layout, so we'll just check they're // there first final TabLayout tabLayout1 = activity.findViewById(R.id.tabs_1); assertTrue(tabLayout1.getTabCount() > 0); // Now remove all tabs. TabLayout will pool the Tab instances... tabLayout1.removeAllTabs(); // Now add some tabs to the second TabLayout and make sure that we don't crash final TabLayout tabLayout2 = activity.findViewById(R.id.tabs_2); tabLayout2.addTab(tabLayout2.newTab()); tabLayout2.addTab(tabLayout2.newTab()); tabLayout2.addTab(tabLayout2.newTab()); }
Example #10
Source File: TabLayoutWithViewPagerTest.java From material-components-android with Apache License 2.0 | 6 votes |
@Test @SmallTest public void testBasics() { setupTabLayoutWithViewPager(); final int itemCount = viewPager.getAdapter().getCount(); assertEquals("Matching item count", itemCount, tabLayout.getTabCount()); for (int i = 0; i < itemCount; i++) { assertEquals( "Tab #" + i, viewPager.getAdapter().getPageTitle(i), tabLayout.getTabAt(i).getText()); } assertEquals("Selected tab", viewPager.getCurrentItem(), tabLayout.getSelectedTabPosition()); verifyViewPagerSelection(); }
Example #11
Source File: TabLayoutWithViewPagerTest.java From material-components-android with Apache License 2.0 | 6 votes |
@Test @SmallTest public void testBadgeWithAdapterContentChange() { setupTabLayoutWithViewPager(); onView(withId(R.id.tabs)).perform(showBadgeOnTab(tabLayout.getTabCount() - 1, 1)); try { final int itemCount = viewPager.getAdapter().getCount(); // Remove the last entry from our adapter onView(withId(R.id.tabs_viewpager)).perform(removeItemAtIndexFromPager(itemCount - 1)); } catch (NullPointerException e) { // App should not crash. throw new AssertionError( "Removing a tab from the view pager should not throw, but it did!", e); } assertNull("No badge is displayed", tabLayout.getTabAt(tabLayout.getTabCount() - 1).getBadge()); }
Example #12
Source File: TabLayoutWithViewPagerTest.java From material-components-android with Apache License 2.0 | 6 votes |
@Test @SmallTest public void testAdapterContentChangeWithAutoRefreshDisabled() { onView(withId(R.id.tabs)).perform(setupWithViewPager(viewPager, false)); // Verify that we have the expected initial adapter PagerAdapter initialAdapter = viewPager.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 = defaultPagerAdapter.getCount(); assertNotEquals("Matching item count", newItemCount, tabLayout.getTabCount()); }
Example #13
Source File: TabLayoutWithViewPagerTest.java From material-components-android with Apache License 2.0 | 6 votes |
@Test @SmallTest public void testBasicAutoRefreshDisabled() { onView(withId(R.id.tabs)).perform(setupWithViewPager(viewPager, false)); // Check that the TabLayout has the same number of items are the adapter PagerAdapter initialAdapter = viewPager.getAdapter(); assertEquals("Initial adapter page count", initialAdapter.getCount(), tabLayout.getTabCount()); // Add two more entries to our adapter defaultPagerAdapter.add("Yellow", Color.YELLOW); defaultPagerAdapter.add("Magenta", Color.MAGENTA); final int newItemCount = defaultPagerAdapter.getCount(); // Assert that the TabLayout did not update and add the new items assertNotEquals("Matching item count", newItemCount, tabLayout.getTabCount()); // Now setup again to update the tabs onView(withId(R.id.tabs)).perform(setupWithViewPager(viewPager, false)); // Assert that the TabLayout updated and added the new items assertEquals("Matching item count", newItemCount, tabLayout.getTabCount()); }
Example #14
Source File: TestRequestBuilderTest.java From android-test with Apache License 2.0 | 6 votes |
/** Test provided multiple annotations to exclude. */ @Test public void testTestSizeFilter_multipleNotAnnotation() { Request request = builder .addAnnotationExclusionFilter(SmallTest.class.getName()) .addAnnotationExclusionFilter(MediumTest.class.getName()) .addTestClass(SampleMultipleAnnotation.class.getName()) .build(); JUnitCore testRunner = new JUnitCore(); Result result = testRunner.run(request); // expect 1 test that failed Assert.assertEquals(1, result.getRunCount()); Assert.assertEquals( "testRunThis", result.getFailures().get(0).getDescription().getMethodName()); }
Example #15
Source File: TestRequestBuilderTest.java From android-test with Apache License 2.0 | 6 votes |
/** Test provided multiple annotations to include. */ @Test public void testTestSizeFilter_multipleAnnotation() { Request request = builder .addAnnotationInclusionFilter(SmallTest.class.getName()) .addAnnotationInclusionFilter(FlakyTest.class.getName()) .addTestClass(SampleRunnerFilterSizeTest.class.getName()) .addTestClass(SampleMultipleAnnotation.class.getName()) .build(); JUnitCore testRunner = new JUnitCore(); Result result = testRunner.run(request); // expect 1 test that failed Assert.assertEquals(1, result.getRunCount()); Assert.assertEquals(1, result.getFailureCount()); Assert.assertEquals( "testSmallSkipped", result.getFailures().get(0).getDescription().getMethodName()); }
Example #16
Source File: TestRequestBuilderTest.java From android-test with Apache License 2.0 | 6 votes |
/** Test provided both include and exclude annotations. */ @Test public void testTestSizeFilter_annotationAndNotAnnotationAtMethod() { Request request = builder .addAnnotationInclusionFilter(SmallTest.class.getName()) .addAnnotationExclusionFilter(FlakyTest.class.getName()) .addTestClass(SampleRunnerFilterSizeTest.class.getName()) .addTestClass(SampleMultipleAnnotation.class.getName()) .build(); JUnitCore testRunner = new JUnitCore(); Result result = testRunner.run(request); // expect 1 test that passed. Assert.assertEquals(1, result.getRunCount()); Assert.assertEquals(0, result.getFailureCount()); }
Example #17
Source File: TestRequestBuilderTest.java From android-test with Apache License 2.0 | 5 votes |
/** * Test that annotation filtering by class works when methods are from superclass. * * <p>TODO: add a similar test to upstream junit. */ @Test public void testAddAnnotationInclusionFilter_super() { Request request = builder .addAnnotationInclusionFilter(SmallTest.class.getName()) .addTestClass(InheritedAnnnotation.class.getName()) .build(); JUnitCore testRunner = new JUnitCore(); Result result = testRunner.run(request); Assert.assertEquals(2, result.getRunCount()); }
Example #18
Source File: BottomSheetBehaviorTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SmallTest public void testInitialSetup() { BottomSheetBehavior<?> behavior = getBehavior(); assertThat(behavior.getState(), is(BottomSheetBehavior.STATE_COLLAPSED)); assertThat(behavior.isFitToContents(), is(true)); CoordinatorLayout coordinatorLayout = getCoordinatorLayout(); ViewGroup bottomSheet = getBottomSheet(); assertThat(bottomSheet.getTop(), is(coordinatorLayout.getHeight() - behavior.getPeekHeight())); assertAccessibilityActions(behavior, getBottomSheet()); }
Example #19
Source File: CursorWindowTest.java From sqlite-android with Apache License 2.0 | 5 votes |
@SmallTest @Test public void testConstructor_WithName() { CursorWindow window = new CursorWindow("MyWindow"); assertEquals("MyWindow", window.getName()); assertEquals(0, window.getStartPosition()); assertEquals(2048 * 1024, window.getWindowSizeBytes()); window.close(); }
Example #20
Source File: BottomSheetBehaviorTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SmallTest public void testSwitchFitSheetToContents() throws Throwable { getBehavior().setFitToContents(false); checkSetState(BottomSheetBehavior.STATE_HALF_EXPANDED, ViewMatchers.isDisplayed()); activityTestRule.runOnUiThread(() -> getBehavior().setFitToContents(true)); activityTestRule.runOnUiThread( () -> assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_EXPANDED))); }
Example #21
Source File: AppBarWithScrollbarsTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SmallTest public void testInflationNoCrash() { // This is the implicit test for to check that AppBarLayout inflation doesn't crash // when its theme has attributes that would cause onCreateDrawableState to be called // during the super's constructor flow. }
Example #22
Source File: FabTransformationBehaviorTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SmallTest public void testSetStateCollapsed() { onView(withId(R.id.fab)).perform(setExpanded(true)); onView(withId(R.id.fab)).perform(setExpanded(false)); onView(isRoot()).perform(waitUntilIdle()); onView(withId(R.id.fab)).check(matches(isDisplayed())); onView(withId(R.id.sheet)).check(matches(not(isDisplayed()))); onView(withId(R.id.scrim)).check(matches(not(isDisplayed()))); }
Example #23
Source File: FabTransformationBehaviorTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SmallTest public void testSetStateExpanded() { onView(withId(R.id.fab)).perform(setExpanded(true)); onView(isRoot()).perform(waitUntilIdle()); onView(withId(R.id.fab)).check(matches(not(isDisplayed()))); onView(withId(R.id.sheet)).check(matches(isDisplayed())); onView(withId(R.id.scrim)).check(matches(isDisplayed())); }
Example #24
Source File: FabTransformationBehaviorTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SmallTest public void testInitialSetup() { onView(withId(R.id.fab)).check(matches(isDisplayed())); onView(withId(R.id.sheet)).check(matches(not(isDisplayed()))); onView(withId(R.id.scrim)).check(matches(not(isDisplayed()))); }
Example #25
Source File: FloatingActionButtonTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SmallTest public void testSetCustomSize() { onView(withId(R.id.fab_standard)) .perform(setCustomSize(10)) .check(matches(withFabCustomSize(10))); onView(withId(R.id.fab_standard)) .perform(setCustomSize(20)) .check(matches(withFabCustomSize(20))); }
Example #26
Source File: FloatingActionButtonTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SmallTest public void testHideShow() { onView(withId(R.id.fab_standard)) .perform(setVisibility(View.VISIBLE)) .perform(hideThenShow()) .check(matches(isDisplayed())); }
Example #27
Source File: FloatingActionButtonTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SmallTest public void testOffset() { onView(withId(R.id.fab_standard)) .perform(setLayoutGravity(Gravity.LEFT | Gravity.TOP)) .check(matches(withFabContentAreaOnMargins(Gravity.LEFT | Gravity.TOP))); onView(withId(R.id.fab_standard)) .perform(setLayoutGravity(Gravity.RIGHT | Gravity.BOTTOM)) .check(matches(withFabContentAreaOnMargins(Gravity.RIGHT | Gravity.BOTTOM))); }
Example #28
Source File: BottomSheetBehaviorTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SmallTest public void testFindScrollingChildEnabled() { Context context = activityTestRule.getActivity(); NestedScrollView disabledParent = new NestedScrollView(context); disabledParent.setNestedScrollingEnabled(false); NestedScrollView enabledChild = new NestedScrollView(context); enabledChild.setNestedScrollingEnabled(true); disabledParent.addView(enabledChild); View scrollingChild = getBehavior().findScrollingChild(disabledParent); assertThat(scrollingChild, is((View) enabledChild)); }
Example #29
Source File: FloatingActionButtonTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test @SmallTest public void testSetMiniSize() { final int miniSize = activityTestRule .getActivity() .getResources() .getDimensionPixelSize(R.dimen.fab_mini_height); onView(withId(R.id.fab_standard)) .perform(setSize(FloatingActionButton.SIZE_MINI)) .check(matches(withFabContentHeight(miniSize))); }
Example #30
Source File: CursorWindowTest.java From sqlite-android with Apache License 2.0 | 5 votes |
@SmallTest @Test public void testConstructorDifferentSize() { CursorWindow window = new CursorWindow("big", 8); assertEquals("big", window.getName()); assertEquals(0, window.getStartPosition()); assertEquals(8, window.getWindowSizeBytes()); try { doTestValues(window); fail("For window of size 8, the test should fail."); } catch (Exception e) { } window.close(); }