SyncedFoldersActivityIT.java 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. *
  3. * Nextcloud Android client application
  4. *
  5. * @author Tobias Kaminsky
  6. * Copyright (C) 2020 Tobias Kaminsky
  7. * Copyright (C) 2020 Nextcloud GmbH
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. package com.nextcloud.client;
  23. import android.app.Activity;
  24. import android.content.Intent;
  25. import com.nextcloud.client.preferences.SubFolderRule;
  26. import com.owncloud.android.AbstractIT;
  27. import com.owncloud.android.databinding.SyncedFoldersLayoutBinding;
  28. import com.owncloud.android.datamodel.MediaFolderType;
  29. import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
  30. import com.owncloud.android.ui.activity.SyncedFoldersActivity;
  31. import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment;
  32. import com.owncloud.android.utils.ScreenshotTest;
  33. import org.junit.Rule;
  34. import org.junit.Test;
  35. import java.util.Objects;
  36. import androidx.test.espresso.intent.rule.IntentsTestRule;
  37. import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
  38. public class SyncedFoldersActivityIT extends AbstractIT {
  39. @Rule public IntentsTestRule<SyncedFoldersActivity> activityRule = new IntentsTestRule<>(SyncedFoldersActivity.class,
  40. true,
  41. false);
  42. @Test
  43. @ScreenshotTest
  44. public void open() {
  45. SyncedFoldersLayoutBinding sut = activityRule.launchActivity(null).binding;
  46. shortSleep();
  47. screenshot(sut.list);
  48. }
  49. @Test
  50. @ScreenshotTest
  51. public void testSyncedFolderDialog() {
  52. SyncedFolderDisplayItem item = new SyncedFolderDisplayItem(1,
  53. "/sdcard/DCIM/",
  54. "/InstantUpload/",
  55. true,
  56. false,
  57. false,
  58. true,
  59. "test@https://nextcloud.localhost",
  60. 0,
  61. 0,
  62. true,
  63. 1000,
  64. "Name",
  65. MediaFolderType.IMAGE,
  66. false,
  67. SubFolderRule.YEAR_MONTH,
  68. false);
  69. SyncedFolderPreferencesDialogFragment sut = SyncedFolderPreferencesDialogFragment.newInstance(item, 0);
  70. Intent intent = new Intent(targetContext, SyncedFoldersActivity.class);
  71. SyncedFoldersActivity activity = activityRule.launchActivity(intent);
  72. sut.show(activity.getSupportFragmentManager(), "");
  73. getInstrumentation().waitForIdleSync();
  74. shortSleep();
  75. screenshot(Objects.requireNonNull(sut.requireDialog().getWindow()).getDecorView());
  76. }
  77. }