ScreenshotsIT.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Nextcloud - Android Client
  3. *
  4. * SPDX-FileCopyrightText: 2018 Tobias Kaminsky <tobias@kaminsky.me>
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. package com.owncloud.android;
  8. import com.owncloud.android.lib.common.operations.RemoteOperationResult;
  9. import com.owncloud.android.operations.CreateFolderOperation;
  10. import com.owncloud.android.operations.common.SyncOperation;
  11. import com.owncloud.android.ui.activity.FileDisplayActivity;
  12. import com.owncloud.android.ui.activity.SettingsActivity;
  13. import com.owncloud.android.ui.activity.SyncedFoldersActivity;
  14. import org.junit.Assert;
  15. import org.junit.BeforeClass;
  16. import org.junit.ClassRule;
  17. import org.junit.Test;
  18. import org.junit.runner.RunWith;
  19. import org.junit.runners.JUnit4;
  20. import androidx.test.core.app.ActivityScenario;
  21. import androidx.test.espresso.action.ViewActions;
  22. import androidx.test.espresso.contrib.DrawerActions;
  23. import androidx.test.espresso.contrib.RecyclerViewActions;
  24. import androidx.test.espresso.matcher.PreferenceMatchers;
  25. import androidx.test.filters.LargeTest;
  26. import tools.fastlane.screengrab.Screengrab;
  27. import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy;
  28. import tools.fastlane.screengrab.locale.LocaleTestRule;
  29. import static androidx.test.espresso.Espresso.onData;
  30. import static androidx.test.espresso.Espresso.onView;
  31. import static androidx.test.espresso.Espresso.pressBack;
  32. import static androidx.test.espresso.action.ViewActions.click;
  33. import static androidx.test.espresso.matcher.ViewMatchers.withId;
  34. import static androidx.test.espresso.matcher.ViewMatchers.withText;
  35. import static org.hamcrest.core.AnyOf.anyOf;
  36. import static org.junit.Assert.assertTrue;
  37. @LargeTest
  38. @RunWith(JUnit4.class)
  39. public class ScreenshotsIT extends AbstractOnServerIT {
  40. @ClassRule
  41. public static final LocaleTestRule localeTestRule = new LocaleTestRule();
  42. @BeforeClass
  43. public static void beforeScreenshot() {
  44. Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());
  45. }
  46. @Test
  47. public void gridViewScreenshot() {
  48. ActivityScenario.launch(FileDisplayActivity.class);
  49. onView(anyOf(withText(R.string.action_switch_grid_view), withId(R.id.switch_grid_view_button))).perform(click());
  50. shortSleep();
  51. Screengrab.screenshot("01_gridView");
  52. onView(anyOf(withText(R.string.action_switch_list_view), withId(R.id.switch_grid_view_button))).perform(click());
  53. Assert.assertTrue(true); // if we reach this, everything is ok
  54. }
  55. @Test
  56. public void listViewScreenshot() {
  57. String path = "/Camera/";
  58. // folder does not exist yet
  59. if (getStorageManager().getFileByEncryptedRemotePath(path) == null) {
  60. SyncOperation syncOp = new CreateFolderOperation(path, user, targetContext, getStorageManager());
  61. RemoteOperationResult result = syncOp.execute(client);
  62. assertTrue(result.isSuccess());
  63. }
  64. ActivityScenario.launch(FileDisplayActivity.class);
  65. // go into work folder
  66. onView(withId(R.id.list_root)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
  67. Screengrab.screenshot("02_listView");
  68. Assert.assertTrue(true); // if we reach this, everything is ok
  69. }
  70. @Test
  71. public void drawerScreenshot() {
  72. ActivityScenario.launch(FileDisplayActivity.class);
  73. onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
  74. Screengrab.screenshot("03_drawer");
  75. onView(withId(R.id.drawer_layout)).perform(DrawerActions.close());
  76. Assert.assertTrue(true); // if we reach this, everything is ok
  77. }
  78. @Test
  79. public void multipleAccountsScreenshot() {
  80. ActivityScenario.launch(FileDisplayActivity.class);
  81. onView(withId(R.id.switch_account_button)).perform(click());
  82. Screengrab.screenshot("04_accounts");
  83. pressBack();
  84. Assert.assertTrue(true); // if we reach this, everything is ok
  85. }
  86. @Test
  87. public void autoUploadScreenshot() {
  88. ActivityScenario.launch(SyncedFoldersActivity.class);
  89. Screengrab.screenshot("05_autoUpload");
  90. Assert.assertTrue(true); // if we reach this, everything is ok
  91. }
  92. @Test
  93. public void davdroidScreenshot() {
  94. ActivityScenario.launch(SettingsActivity.class);
  95. onData(PreferenceMatchers.withTitle(R.string.prefs_category_more)).perform(ViewActions.scrollTo());
  96. shortSleep();
  97. Screengrab.screenshot("06_davdroid");
  98. Assert.assertTrue(true); // if we reach this, everything is ok
  99. }
  100. }