private void cancelCreditCardPayment() throws Exception { Espresso.pressBack(); EspressoTestUtils.waitForView(R.id.activity_payment_method_selection); Espresso.pressBack(); EspressoTestUtils.waitForView(R.id.verificationTextView); try { // Actually this should not be required. However without pressing back one last time; the // activity cannot be started in the next test. To avoid it; we kill the PaymentResultActivity as well. Espresso.pressBack(); } catch (final NoActivityResumedException expected) { // expected } }
private void goBackN() { final int N = 50; // how many times to hit back button try { for (int i = 0; i < N; i++) Espresso.pressBack(); } catch (NoActivityResumedException e) { Log.e("TAG", "Closed all activities", e); } }
public static void closeAllActivities() throws Exception { for (int i = 0; i < 10; i++) { try { pressBack(); } catch (NoActivityResumedException e) { Log.d(TAG, "you made me do this, android"); return; } } throw new IllegalStateException("what are you doing with 10 open activities?!"); }