Skip to content

Commit

Permalink
Add sleeps to some flaky Espresso tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amberin committed Dec 28, 2024
1 parent 9d6f529 commit c641149
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.orgzly.android.espresso;

import android.content.pm.ActivityInfo;
import android.os.SystemClock;

import androidx.test.core.app.ActivityScenario;

Expand Down Expand Up @@ -111,6 +112,7 @@ public void testCabStaysOpenOnRotationInQueryFragment() {

// TODO: Check *the same* note is selected.

SystemClock.sleep(500);
scenario.onActivity(activity ->
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public void testPersistedSpinnerSelection() {
searchForTextCloseKeyboard(".it.done ad.7");
onNotesInAgenda().check(matches(recyclerViewItemCount(25)));

SystemClock.sleep(500);
scenario.onActivity(activity ->
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ public void testActionModeMovingStaysOpenAfterRotation() {
onActionItemClick(R.id.move, R.string.move);
onView(withId(R.id.notes_action_move_down)).check(matches(isDisplayed()));

SystemClock.sleep(500);
scenario.onActivity(activity ->
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE));

Expand Down Expand Up @@ -431,6 +432,7 @@ public void testReturnToNonExistentNoteByPressingBack() {
// Rotate
scenario.onActivity(activity -> {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
SystemClock.sleep(500);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
});

Expand Down

0 comments on commit c641149

Please sign in to comment.