@Test @LargeTest public void testSaveAndRestorePasswordVisibility() throws Throwable { // Type some text on the EditText onView(withId(R.id.textinput_edittext_pwd)).perform(typeText(INPUT_TEXT)); onView(withId(R.id.textinput_password)).check(isPasswordToggledVisible(false)); // Toggle password to be shown as plain text onView(withId(R.id.textinput_password)).perform(clickPasswordToggle()); onView(withId(R.id.textinput_password)).check(isPasswordToggledVisible(true)); RecreatableAppCompatActivity activity = activityTestRule.getActivity(); ActivityUtils.recreateActivity(activityTestRule, activity); ActivityUtils.waitForExecution(activityTestRule); // Check that the password is still toggled to be shown as plain text onView(withId(R.id.textinput_password)).check(isPasswordToggledVisible(true)); }
@Test @LargeTest public void checkProfileTest() throws InterruptedException{ Thread.sleep(6000); mFireBaseDatabase = FirebaseDatabase.getInstance(); mUsersDatabaseReference = mFireBaseDatabase.getReference().child("users"); FirebaseApp.initializeApp(rule.getActivity()); mAuth = FirebaseAuth.getInstance(); Looper.prepare(); final MainActivity obj = new MainActivity(); if(mAuth.getCurrentUser() != null){ final String user_id = mAuth.getCurrentUser().getUid(); mUsersDatabaseReference.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if(!dataSnapshot.hasChild(user_id)){ obj.startActivity(new Intent(obj.getApplicationContext(), CreateProfileActivity.class)); obj.finish(); } } @Override public void onCancelled(DatabaseError databaseError) { } }); } Thread.sleep(4000); }
/** * Verify that the "Silence during presentation" setting is correctly stored and restored * on activity loading. * * @throws InterruptedException If sleep times fail */ @Test @LargeTest @RequiresDevice public void verifySilenceDuringPresentationStoring() throws InterruptedException { onView(withId(R.id.silenceDuringPresentation)) .perform(click()); Thread.sleep(1000); onView(withId(R.id.silenceDuringPresentation)) .check(matches(isChecked())); settingsActivityRule.getActivity().onStop(); settingsActivityRule.getActivity().finish(); Thread.sleep(1000); assertThat(settingsActivityRule.getActivity().isDestroyed(), is(true)); settingsActivityRule.launchActivity(null); onView(withId(R.id.silenceDuringPresentation)) .check(matches(isChecked())) .perform(click()); Thread.sleep(1000); onView(withId(R.id.silenceDuringPresentation)) .check(matches(isNotChecked())); settingsActivityRule.getActivity().onStop(); settingsActivityRule.getActivity().finish(); Thread.sleep(1000); assertThat(settingsActivityRule.getActivity().isDestroyed(), is(true)); settingsActivityRule.launchActivity(null); onView(withId(R.id.silenceDuringPresentation)).check(matches(isNotChecked())); }
/** * Verify that the "Use volume keys for navigation" setting is correctly stored and restored * on activity loading. * * @throws InterruptedException If sleep times fail */ @Test @LargeTest @RequiresDevice public void verifyUseVolumeKeysForNavigationStoring() throws InterruptedException { onView(withId(R.id.useVolumeKeysForNavigation)) .perform(click()); Thread.sleep(1000); onView(withId(R.id.useVolumeKeysForNavigation)) .check(matches(isNotChecked())); settingsActivityRule.getActivity().onStop(); settingsActivityRule.getActivity().finish(); Thread.sleep(1000); assertThat(settingsActivityRule.getActivity().isDestroyed(), is(true)); settingsActivityRule.launchActivity(null); onView(withId(R.id.useVolumeKeysForNavigation)) .check(matches(isNotChecked())) .perform(click()); Thread.sleep(1000); onView(withId(R.id.useVolumeKeysForNavigation)) .check(matches(isChecked())); settingsActivityRule.getActivity().onStop(); settingsActivityRule.getActivity().finish(); Thread.sleep(1000); assertThat(settingsActivityRule.getActivity().isDestroyed(), is(true)); settingsActivityRule.launchActivity(null); onView(withId(R.id.useVolumeKeysForNavigation)).check(matches(isChecked())); }
@Test @LargeTest public void testLargeTest() { Log.d("Test Filters", "This is a large test"); Activity activity = activityTestRule.getActivity(); assertNotNull("MainActivity is not available", activity); }
@Test @LargeTest public void testBasicContent() throws Throwable { // Verify different combinations of snackbar content (title / subtitle and action) // and duration // Short duration verifySnackbarContent( makeCustomSnackbar() .setTitle(TITLE_TEXT) .setSubtitle(SUBTITLE_TEXT) .setDuration(Snackbar.LENGTH_SHORT), TITLE_TEXT, SUBTITLE_TEXT); // Long duration verifySnackbarContent( makeCustomSnackbar() .setTitle(TITLE_TEXT) .setSubtitle(SUBTITLE_TEXT) .setDuration(Snackbar.LENGTH_LONG), TITLE_TEXT, SUBTITLE_TEXT); // Indefinite duration verifySnackbarContent( makeCustomSnackbar() .setTitle(TITLE_TEXT) .setSubtitle(SUBTITLE_TEXT) .setDuration(Snackbar.LENGTH_INDEFINITE), TITLE_TEXT, SUBTITLE_TEXT); }
@Test @LargeTest public void testMinMaxTabWidth() { verifyMinMaxTabWidth( R.layout.tab_layout_bound_minmax, R.dimen.tab_width_limit_small, R.dimen.tab_width_limit_large); }
@Test @LargeTest public void testStopRestartVideoSource() throws InterruptedException { fixtures.stopRestartVideoSource(); }
@Test @LargeTest public void testStartStopWithDifferentResolutions() throws InterruptedException { fixtures.startStopWithDifferentResolutions(); }
@Test @LargeTest public void testReturnBufferLate() throws InterruptedException { fixtures.returnBufferLate(); }
@Test @LargeTest public void testCameraFreezedEventOnBufferStarvation() throws InterruptedException { fixtures.cameraFreezedEventOnBufferStarvation(); }
@Test @LargeTest public void testStartWhileCameraIsAlreadyOpen() throws InterruptedException { fixtures.startWhileCameraIsAlreadyOpen(); }
@Test @LargeTest public void testStartWhileCameraIsAlreadyOpenAndCloseCamera() throws InterruptedException { fixtures.startWhileCameraIsAlreadyOpenAndCloseCamera(); }
@Test @LargeTest public void testMinTabWidth() { verifyMinMaxTabWidth(R.layout.tab_layout_bound_min, R.dimen.tab_width_limit_medium, 0); }
@Test @LargeTest public void testMaxTabWidth() { verifyMinMaxTabWidth(R.layout.tab_layout_bound_max, 0, R.dimen.tab_width_limit_medium); }
@Test @LargeTest public void testNavigationSelectionListener() { BottomNavigationView.OnNavigationItemSelectedListener mockedListener = mock(BottomNavigationView.OnNavigationItemSelectedListener.class); mBottomNavigation.setOnNavigationItemSelectedListener(mockedListener); // Make the listener return true to allow selecting the item. when(mockedListener.onNavigationItemSelected(any(MenuItem.class))).thenReturn(true); onView( allOf( withText(mMenuStringContent.get(R.id.destination_profile)), isDescendantOfA(withId(R.id.bottom_navigation)), isDisplayed())) .perform(click()); // Verify our listener has been notified of the click verify(mockedListener, times(1)) .onNavigationItemSelected(mBottomNavigation.getMenu().findItem(R.id.destination_profile)); // Verify the item is now selected assertTrue(mBottomNavigation.getMenu().findItem(R.id.destination_profile).isChecked()); // Select the same item again onView( allOf( withText(mMenuStringContent.get(R.id.destination_profile)), isDescendantOfA(withId(R.id.bottom_navigation)), isDisplayed())) .perform(click()); // Verify our listener has been notified of the click verify(mockedListener, times(2)) .onNavigationItemSelected(mBottomNavigation.getMenu().findItem(R.id.destination_profile)); // Verify the item is still selected assertTrue(mBottomNavigation.getMenu().findItem(R.id.destination_profile).isChecked()); // Make the listener return false to disallow selecting the item. when(mockedListener.onNavigationItemSelected(any(MenuItem.class))).thenReturn(false); onView( allOf( withText(mMenuStringContent.get(R.id.destination_people)), isDescendantOfA(withId(R.id.bottom_navigation)), isDisplayed())) .perform(click()); // Verify our listener has been notified of the click verify(mockedListener, times(1)) .onNavigationItemSelected(mBottomNavigation.getMenu().findItem(R.id.destination_people)); // Verify the previous item is still selected assertFalse(mBottomNavigation.getMenu().findItem(R.id.destination_people).isChecked()); assertTrue(mBottomNavigation.getMenu().findItem(R.id.destination_profile).isChecked()); // Set null listener to test that the next click is not going to notify the // previously set listener and will allow selecting items. mBottomNavigation.setOnNavigationItemSelectedListener(null); // Click one of our items onView( allOf( withText(mMenuStringContent.get(R.id.destination_home)), isDescendantOfA(withId(R.id.bottom_navigation)), isDisplayed())) .perform(click()); // Verify that our previous listener has not been notified of the click verifyNoMoreInteractions(mockedListener); // Verify the correct item is now selected. assertTrue(mBottomNavigation.getMenu().findItem(R.id.destination_home).isChecked()); }