Compare commits

...
2 Commits
Author SHA1 Message Date
alperozturk96 d99e601a09 wip
Signed-off-by: alperozturk96 <[email protected]>
2026-05-06 09:02:15 +02:00
alperozturk96 85c047ee85 wip
Signed-off-by: alperozturk96 <[email protected]>
2026-05-06 08:20:30 +02:00
4 changed files with 17 additions and 17 deletions

No files matched your search

@@ -218,7 +218,7 @@ public abstract class AbstractIT {
@Before
public void enableAccessibilityChecks() {
androidx.test.espresso.accessibility.AccessibilityChecks.enable().setRunChecksFromRootView(true);
androidx.test.espresso.accessibility.AccessibilityChecks.enable().setRunChecksFromRootView(false);
}
@After
@@ -8,8 +8,6 @@
*/
package com.owncloud.android;
import android.net.Uri;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.db.OCUpload;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@@ -97,12 +95,7 @@ public class DownloadIT extends AbstractOnServerIT {
assertTrue(new File(file1.getStoragePath()).exists());
assertTrue(new File(file2.getStoragePath()).exists());
// test against hardcoded path to make sure that it is correct
assertEquals("/storage/emulated/0/Android/media/"+targetContext.getPackageName()+"/nextcloud/" +
Uri.encode(account.name, "@") + "/testUpload/nonEmpty.txt",
file1.getStoragePath());
assertEquals("/storage/emulated/0/Android/media/"+targetContext.getPackageName()+"/nextcloud/" +
Uri.encode(account.name, "@") + "/testUpload/nonEmpty2.txt",
file2.getStoragePath());
assertEquals(FileStorageUtils.getDefaultSavePathFor(account.name, file1), file1.getStoragePath());
assertEquals(FileStorageUtils.getDefaultSavePathFor(account.name, file2), file2.getStoragePath());
}
}
@@ -32,10 +32,12 @@ import com.owncloud.android.operations.UploadFileOperation
import org.junit.After
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.MockitoAnnotations
import org.mockito.junit.MockitoJUnit
import org.mockito.junit.MockitoRule
import java.io.File
import java.util.Random
import java.util.UUID
@@ -47,6 +49,9 @@ import java.util.function.Supplier
@RunWith(AndroidJUnit4::class)
@SmallTest
class UploadStorageManagerTest : AbstractIT() {
@get:Rule
val mockitoRule: MockitoRule = MockitoJUnit.rule()
private lateinit var uploadsStorageManager: UploadsStorageManager
@Mock
@@ -58,8 +63,6 @@ class UploadStorageManagerTest : AbstractIT() {
@Before
fun setUp() {
MockitoAnnotations.openMocks(this)
val instrumentationCtx = ApplicationProvider.getApplicationContext<Context>()
val contentResolver = instrumentationCtx.contentResolver
uploadsStorageManager = UploadsStorageManager(currentAccountProvider, contentResolver)
@@ -233,7 +236,11 @@ class UploadStorageManagerTest : AbstractIT() {
@After
fun tearDown() {
deleteAllUploads()
userAccountManager.removeUser(user2)
if (::uploadsStorageManager.isInitialized) {
deleteAllUploads()
}
if (::userAccountManager.isInitialized && ::user2.isInitialized) {
userAccountManager.removeUser(user2)
}
}
}
@@ -940,13 +940,13 @@ public class FileDataStorageManager {
String expectedPath = FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), ocFile);
if (!localPath.equalsIgnoreCase(expectedPath)) {
Log_OC.w(TAG, "removeLocalCopyIfNeeded: Path mismatch! Expected " + expectedPath
+ " but found " + localPath + ". Skipping deletion to prevent data loss.");
+ " but found " + localPath + ". Deleting from actual local path.");
}
Log_OC.d(TAG, "removeLocalCopyIfNeeded: deleting local file -> " + localPath);
boolean success = false;
try {
success = new File(expectedPath).delete();
success = new File(localPath).delete();
} catch (Exception e) {
Log_OC.e(TAG, "removeLocalCopyIfNeeded: deletion error: ", e);
}