Browse Source

new screenshots, disabled non working

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 5 years ago
parent
commit
db6c1ba055
31 changed files with 256 additions and 156 deletions
  1. 2 44
      .drone.yml
  2. BIN
      screenshots/gplay/debug/com.nextcloud.client.ActivitiesActivityIT_openDrawer.png
  3. BIN
      screenshots/gplay/debug/com.nextcloud.client.FileDisplayActivityIT_drawer.png
  4. BIN
      screenshots/gplay/debug/com.nextcloud.client.FileDisplayActivityIT_open.png
  5. BIN
      screenshots/gplay/debug/com.nextcloud.client.NotificationsActivityIT_openDrawer.png
  6. BIN
      screenshots/gplay/debug/com.nextcloud.client.SettingsActivityIT_open.png
  7. BIN
      screenshots/gplay/debug/com.nextcloud.client.SyncedFoldersActivityIT_openDrawer.png
  8. BIN
      screenshots/gplay/debug/com.nextcloud.client.SyncedFoldersActivityIT_testSyncedFolderDialog.png
  9. BIN
      screenshots/gplay/debug/com.nextcloud.client.UploadListActivityActivityIT_openDrawer.png
  10. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.activity.ConflictsResolveActivityIT_keepBoth.png
  11. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.activity.ConflictsResolveActivityIT_keepExisting.png
  12. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.activity.ConflictsResolveActivityIT_keepNew.png
  13. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.activity.ConflictsResolveActivityIT_screenshotTextFiles.png
  14. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.activity.ManageAccountsActivityIT_open.png
  15. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.activity.ManageAccountsActivityIT_userInfoDetail.png
  16. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testAccountChooserDialog.png
  17. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testLoadingDialog.png
  18. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testRemoveFileDialog.png
  19. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testRemoveFilesDialog.png
  20. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testRemoveFolderDialog.png
  21. BIN
      screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testRemoveFoldersDialog.png
  22. 1 1
      src/androidTest/java/com/nextcloud/client/FileDisplayActivityIT.java
  23. 1 1
      src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
  24. 8 95
      src/androidTest/java/com/owncloud/android/AbstractIT.java
  25. 229 0
      src/androidTest/java/com/owncloud/android/AbstractOnServerIT.java
  26. 2 2
      src/androidTest/java/com/owncloud/android/datamodel/FileDataStorageManagerTest.java
  27. 1 1
      src/androidTest/java/com/owncloud/android/ui/activity/ConflictsResolveActivityIT.java
  28. 3 3
      src/androidTest/java/com/owncloud/android/ui/dialog/DialogFragmentIT.java
  29. 4 5
      src/androidTest/java/com/owncloud/android/ui/fragment/OCFileListFragmentIT.kt
  30. 2 3
      src/androidTest/java/com/owncloud/android/ui/preview/PreviewTextFileFragmentTest.java
  31. 3 1
      src/main/java/com/nextcloud/ui/ChooseAccountDialogFragment.kt

+ 2 - 44
.drone.yml

@@ -22,6 +22,7 @@ steps:
       - emulator-headless -avd android-27 -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
       - sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
       - sed -i s"#server#server#" gradle.properties
+      - sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
       - ./gradlew assembleGplay
       - ./gradlew assembleGplayDebug
       - scripts/wait_for_emulator.sh
@@ -101,6 +102,7 @@ steps:
       - scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
       - emulator-headless -avd android-27 -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
       - sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
+      - sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
       - ./gradlew assembleGplay
       - ./gradlew assembleGplayDebug
       - scripts/wait_for_emulator.sh
@@ -186,8 +188,6 @@ steps:
       - ./gradlew assembleGplayDebug
       - scripts/wait_for_emulator.sh
       - ./gradlew installGplayDebugAndroidTest
-      - scripts/wait_for_server.sh "server"
-      - sed -i s"#5#1#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
       - ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest && scripts/deleteOutdatedComments.sh "stable" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
   - name: notify
     image: drillster/drone-email
@@ -210,26 +210,6 @@ steps:
         - failure
       branch:
         - master
-
-services:
-  - name: server
-    image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
-    commands:
-      - BRANCH='stable18' /usr/local/bin/initnc.sh
-      - su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
-      - su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
-      - su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3"
-      - su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G"
-      - su www-data -c "php /var/www/html/occ group:add users"
-      - su www-data -c "php /var/www/html/occ group:adduser users user1"
-      - su www-data -c "php /var/www/html/occ group:adduser users user2"
-      - su www-data -c "git clone -b stable18 https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
-      - su www-data -c "php /var/www/html/occ app:enable activity"
-      - su www-data -c "git clone -b stable18 https://github.com/nextcloud/text.git /var/www/html/apps/text/"
-      - su www-data -c "php /var/www/html/occ app:enable text"
-      - su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
-      - /usr/local/bin/run.sh
-
 trigger:
   branch:
     - master
@@ -262,7 +242,6 @@ steps:
       - ./gradlew assembleGplayDebug
       - scripts/wait_for_emulator.sh
       - ./gradlew installGplayDebugAndroidTest
-      - scripts/wait_for_server.sh "server"
       - sed -i s"#5#1#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
       - ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest && scripts/deleteOutdatedComments.sh "master" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
   - name: notify
@@ -286,27 +265,6 @@ steps:
         - failure
       branch:
         - master
-
-services:
-  - name: server
-    image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
-    commands:
-      - /usr/local/bin/initnc.sh
-      - su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
-      - su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
-      - su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3"
-      - su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G"
-      - su www-data -c "php /var/www/html/occ group:add users"
-      - su www-data -c "php /var/www/html/occ group:adduser users user1"
-      - su www-data -c "php /var/www/html/occ group:adduser users user2"
-      - su www-data -c "git clone -b master https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
-      - su www-data -c "php /var/www/html/occ app:enable activity"
-      - su www-data -c "git clone -b master https://github.com/nextcloud/text.git /var/www/html/apps/text/"
-      - su www-data -c "php /var/www/html/occ app:enable text"
-      - su www-data -c "git clone -b master https://github.com/nextcloud/end_to_end_encryption/  /var/www/html/apps/end_to_end_encryption/"
-      - su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
-      - /usr/local/bin/run.sh
-
 trigger:
   branch:
     - master

BIN
screenshots/gplay/debug/com.nextcloud.client.ActivitiesActivityIT_openDrawer.png


BIN
screenshots/gplay/debug/com.nextcloud.client.FileDisplayActivityIT_drawer.png


BIN
screenshots/gplay/debug/com.nextcloud.client.FileDisplayActivityIT_open.png


BIN
screenshots/gplay/debug/com.nextcloud.client.NotificationsActivityIT_openDrawer.png


BIN
screenshots/gplay/debug/com.nextcloud.client.SettingsActivityIT_open.png


BIN
screenshots/gplay/debug/com.nextcloud.client.SyncedFoldersActivityIT_openDrawer.png


BIN
screenshots/gplay/debug/com.nextcloud.client.SyncedFoldersActivityIT_testSyncedFolderDialog.png


BIN
screenshots/gplay/debug/com.nextcloud.client.UploadListActivityActivityIT_openDrawer.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.activity.ConflictsResolveActivityIT_keepBoth.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.activity.ConflictsResolveActivityIT_keepExisting.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.activity.ConflictsResolveActivityIT_keepNew.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.activity.ConflictsResolveActivityIT_screenshotTextFiles.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.activity.ManageAccountsActivityIT_open.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.activity.ManageAccountsActivityIT_userInfoDetail.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testAccountChooserDialog.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testLoadingDialog.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testRemoveFileDialog.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testRemoveFilesDialog.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testRemoveFolderDialog.png


BIN
screenshots/gplay/debug/com.owncloud.android.ui.dialog.DialogFragmentIT_testRemoveFoldersDialog.png


+ 1 - 1
src/androidTest/java/com/nextcloud/client/FileDisplayActivityIT.java

@@ -90,7 +90,7 @@ public class FileDisplayActivityIT extends AbstractIT {
     }
 
     @Test
-    @ScreenshotTest
+    // @ScreenshotTest // todo run without real server
     public void showShares() {
         assertTrue(new ExistenceCheckRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
         assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());

+ 1 - 1
src/androidTest/java/com/nextcloud/client/RetryTestRule.kt

@@ -30,7 +30,7 @@ import org.junit.runners.model.Statement
 /**
  * C&p from https://stackoverflow.com/questions/45635833/how-can-i-use-flakytest-annotation-now on 18.03.2020
  */
-class RetryTestRule(val retryCount: Int = 5) : TestRule {
+class RetryTestRule(val retryCount: Int = 1) : TestRule {
 
     companion object {
         private val TAG = RetryTestRule::class.java.simpleName

+ 8 - 95
src/androidTest/java/com/owncloud/android/AbstractIT.java

@@ -7,8 +7,6 @@ import android.accounts.OperationCanceledException;
 import android.app.Activity;
 import android.content.ActivityNotFoundException;
 import android.content.Context;
-import android.net.Uri;
-import android.os.Bundle;
 
 import com.facebook.testing.screenshot.Screenshot;
 import com.nextcloud.client.RetryTestRule;
@@ -29,21 +27,13 @@ import com.owncloud.android.lib.common.OwnCloudClient;
 import com.owncloud.android.lib.common.OwnCloudClientFactory;
 import com.owncloud.android.lib.common.accounts.AccountUtils;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
-import com.owncloud.android.lib.resources.e2ee.ToggleEncryptionRemoteOperation;
-import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
-import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
-import com.owncloud.android.lib.resources.files.model.RemoteFile;
 import com.owncloud.android.operations.CreateFolderOperation;
 import com.owncloud.android.operations.UploadFileOperation;
 import com.owncloud.android.utils.FileStorageUtils;
 
 import junit.framework.TestCase;
 
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.io.FileUtils;
-import org.junit.After;
-import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 
@@ -78,7 +68,7 @@ public abstract class AbstractIT {
     protected static User user;
     protected static Context targetContext;
 
-    private Activity currentActivity;
+    protected Activity currentActivity;
 
     protected FileDataStorageManager fileDataStorageManager =
         new FileDataStorageManager(account, targetContext.getContentResolver());
@@ -87,26 +77,15 @@ public abstract class AbstractIT {
     public static void beforeAll() {
         try {
             targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
-            Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
-
-            Uri baseUrl = Uri.parse(arguments.getString("TEST_SERVER_URL"));
-            String loginName = arguments.getString("TEST_SERVER_USERNAME");
-            String password = arguments.getString("TEST_SERVER_PASSWORD");
-
-            Account temp = new Account(loginName + "@" + baseUrl, MainApp.getAccountType(targetContext));
-            UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
-            if (!accountManager.exists(temp)) {
-                AccountManager platformAccountManager = AccountManager.get(targetContext);
-                platformAccountManager.addAccountExplicitly(temp, password, null);
-                platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
-                        Integer.toString(UserAccountManager.ACCOUNT_VERSION));
-                platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0");
-                platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString());
-                platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName); // same as userId
-            }
+
+            Account temp = new Account("test@server.com", MainApp.getAccountType(targetContext));
+            AccountManager platformAccountManager = AccountManager.get(targetContext);
+            platformAccountManager.addAccountExplicitly(temp, "password", null);
+            platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, "https://server.com");
+            platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, "test");
 
             final UserAccountManager userAccountManager = UserAccountManagerImpl.fromContext(targetContext);
-            account = userAccountManager.getAccountByName(loginName + "@" + baseUrl);
+            account = userAccountManager.getAccountByName("test@server.com");
 
             if (account == null) {
                 throw new ActivityNotFoundException();
@@ -116,12 +95,6 @@ public abstract class AbstractIT {
             user = optionalUser.orElseThrow(IllegalAccessError::new);
 
             client = OwnCloudClientFactory.createOwnCloudClient(account, targetContext);
-
-            createDummyFiles();
-
-            waitForServer(client, baseUrl);
-
-            deleteAllFiles(); // makes sure that no file/folder is in root
         } catch (OperationCanceledException e) {
             e.printStackTrace();
         } catch (AuthenticatorException e) {
@@ -133,36 +106,6 @@ public abstract class AbstractIT {
         }
     }
 
-    @After
-    public void after() {
-        deleteAllFiles();
-    }
-
-    public static void deleteAllFiles() {
-        RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
-        assertTrue(result.getLogMessage(), result.isSuccess());
-
-        for (Object object : result.getData()) {
-            RemoteFile remoteFile = (RemoteFile) object;
-
-            if (!remoteFile.getRemotePath().equals("/")) {
-                if (remoteFile.isEncrypted()) {
-                    assertTrue(new ToggleEncryptionRemoteOperation(remoteFile.getLocalId(),
-                                                                   remoteFile.getRemotePath(),
-                                                                   false)
-                                   .execute(client)
-                                   .isSuccess());
-                }
-
-                assertTrue(new RemoveFileRemoteOperation(remoteFile.getRemotePath())
-                               .execute(client)
-                               .isSuccess()
-                          );
-            }
-        }
-    }
-
-
     protected FileDataStorageManager getStorageManager() {
         return fileDataStorageManager;
     }
@@ -171,14 +114,6 @@ public abstract class AbstractIT {
         return AccountManager.get(targetContext).getAccounts();
     }
 
-    private static void createDummyFiles() throws IOException {
-        new File(FileStorageUtils.getSavePath(account.name)).mkdirs();
-
-        createFile("empty.txt", 0);
-        createFile("nonEmpty.txt", 100);
-        createFile("chunkedFile.txt", 500000);
-    }
-
     public static void createFile(String name, int iteration) throws IOException {
         File file = new File(FileStorageUtils.getSavePath(account.name) + File.separator + name);
         file.createNewFile();
@@ -192,28 +127,6 @@ public abstract class AbstractIT {
         writer.close();
     }
 
-    private static void waitForServer(OwnCloudClient client, Uri baseUrl) {
-        GetMethod get = new GetMethod(baseUrl + "/status.php");
-
-        try {
-            int i = 0;
-            while (client.executeMethod(get) != HttpStatus.SC_OK && i < 3) {
-                System.out.println("wait…");
-                Thread.sleep(60 * 1000);
-                i++;
-            }
-
-            if (i == 3) {
-                Assert.fail("Server not ready!");
-            }
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-    }
-
     protected File getFile(String filename) throws IOException {
         InputStream inputStream = getInstrumentation().getContext().getAssets().open(filename);
         File temp = File.createTempFile("file", "file");

+ 229 - 0
src/androidTest/java/com/owncloud/android/AbstractOnServerIT.java

@@ -0,0 +1,229 @@
+package com.owncloud.android;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
+import android.content.ActivityNotFoundException;
+import android.net.Uri;
+import android.os.Bundle;
+
+import com.nextcloud.client.account.UserAccountManager;
+import com.nextcloud.client.account.UserAccountManagerImpl;
+import com.nextcloud.client.device.BatteryStatus;
+import com.nextcloud.client.device.PowerManagementService;
+import com.nextcloud.client.network.Connectivity;
+import com.nextcloud.client.network.ConnectivityService;
+import com.owncloud.android.datamodel.UploadsStorageManager;
+import com.owncloud.android.db.OCUpload;
+import com.owncloud.android.files.services.FileUploader;
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.OwnCloudClientFactory;
+import com.owncloud.android.lib.common.accounts.AccountUtils;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.resources.e2ee.ToggleEncryptionRemoteOperation;
+import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
+import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
+import com.owncloud.android.lib.resources.files.model.RemoteFile;
+import com.owncloud.android.operations.UploadFileOperation;
+import com.owncloud.android.utils.FileStorageUtils;
+
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import androidx.annotation.NonNull;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import static org.junit.Assert.assertTrue;
+
+
+/**
+ * Common base for all integration tests
+ */
+
+public abstract class AbstractOnServerIT extends AbstractIT {
+    @BeforeClass
+    public static void beforeAll() {
+        try {
+            targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+            Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
+
+            Uri baseUrl = Uri.parse(arguments.getString("TEST_SERVER_URL"));
+            String loginName = arguments.getString("TEST_SERVER_USERNAME");
+            String password = arguments.getString("TEST_SERVER_PASSWORD");
+
+            Account temp = new Account(loginName + "@" + baseUrl, MainApp.getAccountType(targetContext));
+            UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
+            if (!accountManager.exists(temp)) {
+                AccountManager platformAccountManager = AccountManager.get(targetContext);
+                platformAccountManager.addAccountExplicitly(temp, password, null);
+                platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
+                                                   Integer.toString(UserAccountManager.ACCOUNT_VERSION));
+                platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0");
+                platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString());
+                platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName); // same as userId
+            }
+
+            final UserAccountManager userAccountManager = UserAccountManagerImpl.fromContext(targetContext);
+            account = userAccountManager.getAccountByName(loginName + "@" + baseUrl);
+
+            if (account == null) {
+                throw new ActivityNotFoundException();
+            }
+
+            client = OwnCloudClientFactory.createOwnCloudClient(account, targetContext);
+
+            createDummyFiles();
+
+            waitForServer(client, baseUrl);
+
+            deleteAllFiles(); // makes sure that no file/folder is in root
+
+        } catch (OperationCanceledException e) {
+            e.printStackTrace();
+        } catch (AuthenticatorException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (AccountUtils.AccountNotFoundException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @After
+    public void after() {
+        deleteAllFiles();
+    }
+
+    public static void deleteAllFiles() {
+        RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
+        assertTrue(result.getLogMessage(), result.isSuccess());
+
+        for (Object object : result.getData()) {
+            RemoteFile remoteFile = (RemoteFile) object;
+
+            if (!remoteFile.getRemotePath().equals("/")) {
+                if (remoteFile.isEncrypted()) {
+                    assertTrue(new ToggleEncryptionRemoteOperation(remoteFile.getLocalId(),
+                                                                   remoteFile.getRemotePath(),
+                                                                   false)
+                                   .execute(client)
+                                   .isSuccess());
+                }
+
+                assertTrue(new RemoveFileRemoteOperation(remoteFile.getRemotePath())
+                               .execute(client)
+                               .isSuccess()
+                          );
+            }
+        }
+    }
+
+    private static void createDummyFiles() throws IOException {
+        new File(FileStorageUtils.getSavePath(account.name)).mkdirs();
+
+        createFile("empty.txt", 0);
+        createFile("nonEmpty.txt", 100);
+        createFile("chunkedFile.txt", 500000);
+    }
+
+    public static void createFile(String name, int iteration) throws IOException {
+        File file = new File(FileStorageUtils.getSavePath(account.name) + File.separator + name);
+        file.createNewFile();
+
+        FileWriter writer = new FileWriter(file);
+
+        for (int i = 0; i < iteration; i++) {
+            writer.write("123123123123123123123123123\n");
+        }
+        writer.flush();
+        writer.close();
+    }
+
+    private static void waitForServer(OwnCloudClient client, Uri baseUrl) {
+        GetMethod get = new GetMethod(baseUrl + "/status.php");
+
+        try {
+            int i = 0;
+            while (client.executeMethod(get) != HttpStatus.SC_OK && i < 3) {
+                System.out.println("wait…");
+                Thread.sleep(60 * 1000);
+                i++;
+            }
+
+            if (i == 3) {
+                Assert.fail("Server not ready!");
+            }
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void uploadOCUpload(OCUpload ocUpload) {
+        ConnectivityService connectivityServiceMock = new ConnectivityService() {
+            @Override
+            public boolean isInternetWalled() {
+                return false;
+            }
+
+            @Override
+            public Connectivity getConnectivity() {
+                return Connectivity.CONNECTED_WIFI;
+            }
+        };
+
+        PowerManagementService powerManagementServiceMock = new PowerManagementService() {
+            @NonNull
+            @Override
+            public BatteryStatus getBattery() {
+                return new BatteryStatus();
+            }
+
+            @Override
+            public boolean isPowerSavingEnabled() {
+                return false;
+            }
+
+            @Override
+            public boolean isPowerSavingExclusionAvailable() {
+                return false;
+            }
+        };
+
+        UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
+        UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(accountManager,
+                                                                                targetContext.getContentResolver());
+
+        UploadFileOperation newUpload = new UploadFileOperation(
+            uploadsStorageManager,
+            connectivityServiceMock,
+            powerManagementServiceMock,
+            account,
+            null,
+            ocUpload,
+            FileUploader.NameCollisionPolicy.DEFAULT,
+            FileUploader.LOCAL_BEHAVIOUR_COPY,
+            targetContext,
+            false,
+            false
+        );
+        newUpload.addRenameUploadListener(() -> {
+            // dummy
+        });
+
+        newUpload.setRemoteFolderToBeCreated();
+
+        RemoteOperationResult result = newUpload.execute(client, getStorageManager());
+        assertTrue(result.getLogMessage(), result.isSuccess());
+    }
+}

+ 2 - 2
src/androidTest/java/com/owncloud/android/datamodel/FileDataStorageManagerTest.java

@@ -24,7 +24,7 @@ package com.owncloud.android.datamodel;
 
 import android.content.ContentValues;
 
-import com.owncloud.android.AbstractIT;
+import com.owncloud.android.AbstractOnServerIT;
 import com.owncloud.android.db.ProviderMeta;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
@@ -50,7 +50,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-abstract public class FileDataStorageManagerTest extends AbstractIT {
+abstract public class FileDataStorageManagerTest extends AbstractOnServerIT {
 
     protected FileDataStorageManager sut;
 

+ 1 - 1
src/androidTest/java/com/owncloud/android/ui/activity/ConflictsResolveActivityIT.java

@@ -96,7 +96,7 @@ public class ConflictsResolveActivityIT extends AbstractIT {
     }
 
     @Test
-    @ScreenshotTest
+    // @ScreenshotTest // todo run without real server
     public void screenshotImages() throws IOException {
         FileDataStorageManager storageManager = new FileDataStorageManager(account,
                                                                            targetContext.getContentResolver());

+ 3 - 3
src/androidTest/java/com/owncloud/android/ui/dialog/DialogFragmentTest.java → src/androidTest/java/com/owncloud/android/ui/dialog/DialogFragmentIT.java

@@ -53,7 +53,7 @@ import androidx.test.rule.GrantPermissionRule;
 
 import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
 
-public class DialogFragmentTest extends AbstractIT {
+public class DialogFragmentIT extends AbstractIT {
     @Rule public IntentsTestRule<FileDisplayActivity> activityRule =
         new IntentsTestRule<>(FileDisplayActivity.class, true, false);
 
@@ -62,7 +62,7 @@ public class DialogFragmentTest extends AbstractIT {
         Manifest.permission.WRITE_EXTERNAL_STORAGE);
 
     @Test
-    @ScreenshotTest
+//    @ScreenshotTest
     public void testRenameFileDialog() {
         RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(new OCFile("/Test/"));
         showDialog(dialog);
@@ -112,7 +112,7 @@ public class DialogFragmentTest extends AbstractIT {
     }
 
     @Test
-    @ScreenshotTest
+    // @ScreenshotTest
     public void testNewFolderDialog() {
         CreateFolderDialogFragment sut = CreateFolderDialogFragment.newInstance(new OCFile("/"));
         showDialog(sut);

+ 4 - 5
src/androidTest/java/com/owncloud/android/ui/fragment/OCFileListFragmentIT.kt

@@ -49,7 +49,6 @@ import com.owncloud.android.operations.RefreshFolderOperation
 import com.owncloud.android.operations.UploadFileOperation
 import com.owncloud.android.ui.activity.FileDisplayActivity
 import com.owncloud.android.utils.FileStorageUtils
-import com.owncloud.android.utils.ScreenshotTest
 import junit.framework.TestCase
 import org.junit.Assert.assertTrue
 import org.junit.Rule
@@ -89,7 +88,7 @@ class OCFileListFragmentIT : AbstractIT() {
     }
 
     @Test
-    @ScreenshotTest
+    // @ScreenshotTest // todo run without real server
     fun showRichWorkspace() {
         assertTrue(CreateFolderOperation("/test/", user, targetContext).execute(client, storageManager).isSuccess)
 
@@ -176,7 +175,7 @@ class OCFileListFragmentIT : AbstractIT() {
     }
 
     @Test
-    @ScreenshotTest
+    // @ScreenshotTest // todo run without real server
     fun createAndShowShareToUser() {
         val path = "/shareToAdmin/"
         TestCase.assertTrue(
@@ -207,7 +206,7 @@ class OCFileListFragmentIT : AbstractIT() {
     }
 
     @Test
-    @ScreenshotTest
+    // @ScreenshotTest // todo run without real server
     fun createAndShowShareToGroup() {
         val path = "/shareToGroup/"
         TestCase.assertTrue(
@@ -271,7 +270,7 @@ class OCFileListFragmentIT : AbstractIT() {
 //    }
 
     @Test
-    @ScreenshotTest
+    // @ScreenshotTest // todo run without real server
     fun createAndShowShareViaLink() {
         val path = "/shareViaLink/"
         TestCase.assertTrue(

+ 2 - 3
src/androidTest/java/com/owncloud/android/ui/preview/PreviewTextFileFragmentTest.java

@@ -30,7 +30,6 @@ import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.utils.FileStorageUtils;
 import com.owncloud.android.utils.MimeTypeUtil;
-import com.owncloud.android.utils.ScreenshotTest;
 
 import org.junit.Rule;
 import org.junit.Test;
@@ -51,7 +50,7 @@ public class PreviewTextFileFragmentTest extends AbstractIT {
         Manifest.permission.WRITE_EXTERNAL_STORAGE);
 
     @Test
-    @ScreenshotTest
+    // @ScreenshotTest // todo run without real server
     public void displaySimpleTextFile() {
         FileDisplayActivity sut = activityRule.launchActivity(null);
 
@@ -69,7 +68,7 @@ public class PreviewTextFileFragmentTest extends AbstractIT {
     }
 
     @Test
-    @ScreenshotTest
+    // @ScreenshotTest // todo run without real server
     public void displayJavaSnippetFile() throws IOException {
         FileDisplayActivity sut = activityRule.launchActivity(null);
 

+ 3 - 1
src/main/java/com/nextcloud/ui/ChooseAccountDialogFragment.kt

@@ -153,7 +153,9 @@ class ChooseAccountDialogFragment : DialogFragment(), AvatarGenerationListener,
     }
 
     override fun avatarGenerated(avatarDrawable: Drawable?, callContext: Any?) {
-        user_icon.setImageDrawable(avatarDrawable)
+        if (user_icon != null) {
+            user_icon.setImageDrawable(avatarDrawable)
+        }
     }
 
     override fun onAccountClicked(user: User?) {