mirror of
https://github.com/nextcloud/android.git
synced 2024-11-29 10:49:04 +03:00
Merge pull request #6560 from nextcloud/fixLargeTest
make sure to delete all uploads
This commit is contained in:
commit
c981833bc1
1 changed files with 20 additions and 7 deletions
|
@ -28,9 +28,9 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -49,7 +49,7 @@ public class UploadStorageManagerTest extends AbstractIT {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context instrumentationCtx = InstrumentationRegistry.getTargetContext();
|
||||
Context instrumentationCtx = ApplicationProvider.getApplicationContext();
|
||||
ContentResolver contentResolver = instrumentationCtx.getContentResolver();
|
||||
uploadsStorageManager = new UploadsStorageManager(currentAccountProvider, contentResolver);
|
||||
|
||||
|
@ -94,6 +94,7 @@ public class UploadStorageManagerTest extends AbstractIT {
|
|||
int size = 3000;
|
||||
ArrayList<OCUpload> uploads = new ArrayList<>();
|
||||
|
||||
deleteAllUploads();
|
||||
assertEquals(0, uploadsStorageManager.getAllStoredUploads().length);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
@ -156,8 +157,14 @@ public class UploadStorageManagerTest extends AbstractIT {
|
|||
}
|
||||
|
||||
private OCUpload createUpload(Account account) {
|
||||
OCUpload upload = new OCUpload(File.separator + "very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long LocalPath",
|
||||
OCFile.PATH_SEPARATOR + "very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long RemotePath",
|
||||
OCUpload upload = new OCUpload(File.separator + "very long long long long long long long long long long long " +
|
||||
"long long long long long long long long long long long long long long " +
|
||||
"long long long long long long long long long long long long long long " +
|
||||
"long long long long long long long LocalPath",
|
||||
OCFile.PATH_SEPARATOR + "very long long long long long long long long long " +
|
||||
"long long long long long long long long long long long long long long " +
|
||||
"long long long long long long long long long long long long long long " +
|
||||
"long long long long long long long long long long long long RemotePath",
|
||||
account.name);
|
||||
|
||||
upload.setFileSize(new Random().nextInt(20000) * 10000);
|
||||
|
@ -175,12 +182,18 @@ public class UploadStorageManagerTest extends AbstractIT {
|
|||
return upload;
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
private void deleteAllUploads() {
|
||||
for (Account account : getAllAccounts()) {
|
||||
uploadsStorageManager.removeAccountUploads(account);
|
||||
}
|
||||
|
||||
assertEquals(0, uploadsStorageManager.getAllStoredUploads().length);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
deleteAllUploads();
|
||||
|
||||
AccountManager platformAccountManager = AccountManager.get(targetContext);
|
||||
platformAccountManager.removeAccountExplicitly(account2);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue