attempt to get gridview test more reliable

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2019-08-23 07:39:40 +02:00
parent 0fae1b7ba3
commit 0a95210d7b
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7

View file

@ -8,8 +8,7 @@ import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.activity.SettingsActivity;
import junit.framework.Assert;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
@ -19,6 +18,7 @@ import org.junit.runners.JUnit4;
import androidx.test.core.app.ActivityScenario;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.NoActivityResumedException;
import androidx.test.espresso.action.ViewActions;
import androidx.test.espresso.contrib.DrawerActions;
import androidx.test.espresso.contrib.RecyclerViewActions;
@ -56,19 +56,29 @@ public class ScreenshotsIT extends AbstractIT {
public void gridViewScreenshot() throws InterruptedException {
ActivityScenario.launch(FileDisplayActivity.class);
Espresso.openContextualActionModeOverflowMenu();
openOverflowMenu();
onView(anyOf(withText(R.string.action_switch_grid_view), withId(R.id.action_switch_view))).perform(click());
Thread.sleep(1000);
Screengrab.screenshot("01_gridView");
Espresso.openContextualActionModeOverflowMenu();
openOverflowMenu();
onView(anyOf(withText(R.string.action_switch_list_view), withId(R.id.action_switch_view))).perform(click());
Assert.assertTrue(true); // if we reach this, everything is ok
}
private void openOverflowMenu() throws InterruptedException {
try {
Espresso.openContextualActionModeOverflowMenu();
} catch (NoActivityResumedException e) {
ActivityScenario.launch(FileDisplayActivity.class);
Thread.sleep(1000);
Espresso.openContextualActionModeOverflowMenu();
}
}
@Test
public void listViewScreenshot() {
String path = "/Camera/";