Эх сурвалжийг харах

added tests

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 5 жил өмнө
parent
commit
a93313ca19

+ 31 - 1
src/androidTest/java/com/owncloud/android/ui/activity/FolderPickerActivityTest.java → src/androidTest/java/com/owncloud/android/ui/activity/FolderPickerActivityIT.java

@@ -34,7 +34,7 @@ import androidx.test.rule.ActivityTestRule;
 
 @RunWith(AndroidJUnit4.class)
 @LargeTest
-public class FolderPickerActivityTest {
+public class FolderPickerActivityIT {
     @Rule
     public ActivityTestRule<FolderPickerActivity> activityRule =
         new ActivityTestRule<>(FolderPickerActivity.class);
@@ -89,4 +89,34 @@ public class FolderPickerActivityTest {
         // Assert
         Assert.assertEquals(origin, target);
     }
+
+    @Test
+    public void nullFile() {
+        // Arrange
+        FolderPickerActivity targetActivity = activityRule.getActivity();
+        OCFile rootFolder = targetActivity.getStorageManager().getFileByPath(OCFile.ROOT_PATH);
+
+        // Act
+        targetActivity.setFile(null);
+        OCFile target = targetActivity.getCurrentFolder();
+
+        // Assert
+        Assert.assertEquals(rootFolder, target);
+    }
+
+    @Test
+    public void getParentFolder() {
+        // Arrange
+        FolderPickerActivity targetActivity = activityRule.getActivity();
+        OCFile origin = new OCFile("/test/file.test");
+        origin.setRemotePath("/test/file.test");
+
+        OCFile target = new OCFile("/test/");
+
+        // Act
+        targetActivity.setFile(origin);
+
+        // Assert
+        Assert.assertEquals(origin, target);
+    }
 }

+ 9 - 3
src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java

@@ -250,8 +250,13 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
         mSyncInProgress = true;
 
         // perform folder synchronization
-        RemoteOperation refreshFolderOperation = new RefreshFolderOperation(folder, currentSyncTime, false,
-                                                                            ignoreETag, getStorageManager(), getAccount(), getApplicationContext());
+        RemoteOperation refreshFolderOperation = new RefreshFolderOperation(folder,
+                                                                            currentSyncTime,
+                                                                            false,
+                                                                            ignoreETag,
+                                                                            getStorageManager(),
+                                                                            getAccount(),
+                                                                            getApplicationContext());
 
         refreshFolderOperation.execute(getAccount(), this, null, null);
         setIndeterminate(true);
@@ -501,7 +506,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
 
                         if (currentDir == null) {
                             // current folder was removed from the server
-                            DisplayUtils.showSnackMessage(getActivity(), R.string.sync_current_folder_was_removed,
+                            DisplayUtils.showSnackMessage(getActivity(),
+                                                          R.string.sync_current_folder_was_removed,
                                                           getCurrentFolder().getFileName());
                             browseToRoot();
                         } else {