Skip to content

Commit 4cb8996

Browse files
PhilLabalperozturk96
authored andcommitted
Fix that file renaming did not survive folder navigation
Signed-off-by: Philipp Hasper <vcs@hasper.info>
1 parent c2c2983 commit 4cb8996

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

app/src/androidTest/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivityIT.kt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,44 @@ class ReceiveExternalFilesActivityIT : AbstractIT() {
164164
onView(withText(R.string.uploader_btn_upload_text))
165165
.check(matches(isDisplayed()))
166166
.check(matches(isEnabled()))
167+
168+
// Enter the subfolder and verify that the text stays intact
169+
val expectedSubFolderTitle = (getCurrentActivity() as ToolbarActivity).getActionBarTitle(subFolder, false)
170+
onView(withText(expectedSubFolderTitle))
171+
.perform(ViewActions.click())
172+
onView(withId(R.id.toolbar))
173+
.check(matches(hasDescendant(withText(expectedSubFolderTitle))))
174+
onView(withId(R.id.user_input))
175+
.check(matches(withText(fourthFileName)))
176+
.perform(ViewActions.click())
177+
.check(matches(withSelectedText(fourthFileName.removeFileExtension())))
178+
179+
// Set a new, shorter file name
180+
val fifthFileName = "short.jpg"
181+
onView(withId(R.id.user_input))
182+
.perform(ViewActions.typeTextIntoFocusedView(fifthFileName.removeFileExtension()))
183+
.check(matches(withText(fifthFileName)))
184+
185+
// Start the upload, so the folder is stored in the preferences.
186+
// Even though the upload is expected to fail because the backend is not mocked (yet?)
187+
onView(withText(R.string.uploader_btn_upload_text))
188+
.check(matches(isDisplayed()))
189+
.check(matches(isEnabled()))
190+
.perform(ViewActions.click())
191+
}
192+
193+
// Start a new file receive flow. Should now start in the sub folder, but with the original filename again
194+
launchActivity<ReceiveExternalFilesActivity>(intent).use {
195+
val expectedMainFolderTitle = (getCurrentActivity() as ToolbarActivity).getActionBarTitle(subFolder, false)
196+
onView(withId(R.id.toolbar))
197+
.check(matches(hasDescendant(withText(expectedMainFolderTitle))))
198+
199+
onView(withText(R.string.uploader_btn_upload_text))
200+
.check(matches(isDisplayed()))
201+
.check(matches(isEnabled()))
202+
203+
onView(withId(R.id.user_input))
204+
.check(matches(withText(imageFile.name)))
167205
}
168206
}
169207
}

app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,9 +908,10 @@ private void setupFileNameInputField() {
908908
if (fileName == null) {
909909
return;
910910
}
911+
final String userProvidedFileName = Objects.requireNonNullElse(binding.userInput.getText(), "").toString();
911912

912913
binding.userInput.setVisibility(View.VISIBLE);
913-
binding.userInput.setText(fileName);
914+
binding.userInput.setText(userProvidedFileName.isEmpty() ? fileName : userProvidedFileName);
914915
binding.userInput.addTextChangedListener(this);
915916
mFileDisplayNameTransformer = uri ->
916917
Objects.requireNonNullElse(binding.userInput.getText(), fileName).toString();

0 commit comments

Comments
 (0)