Bugfix and automated tests for #15636: deleting from slideshow#16297
Bugfix and automated tests for #15636: deleting from slideshow#16297
Conversation
57d95d5 to
d156ccb
Compare
|
@tobiasKaminsky @alperozturk96 Now I am concerned. I checked this PR's drone run and saw that the PreviewImageActivityIT.kt was checked out, but apparently did not actually run. I then created a PR to provoke a failure, #16329 (comment), and its drone test ran through: https://drone.nextcloud.com/nextcloud/android/27697 Where is the error? Update Seems this is a more general problem, as many more provoked failures are not catched in the CI. I created #16350 to track this. So it is more or less independent of the PR here, as it is a more widespread issue. |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
6d7d20a to
28eda97
Compare
There was a problem hiding this comment.
Hello
Thank you for the PR and for the updates.
I tested it with the latest master branch. I noticed that when a user deletes a picture from the preview, the next image appears not file listing as expected so I couldn't able to reproduce the bug.
Also, the onRemoveFileOperationFinish function updates the adapter and should trigger the UI updates, rather than handling it directly in RemoveFilesDialogFragment.kt.
As a side note, not directly related to this PR: the line fda?.refreshCurrentDirectory() may be unnecessary, since onRemoveFileOperationFinish already performs the update.
I suggest to remove unnecessary lines (refreshDirectory, initPager) from RemoveFilesDialogFragment.kt , test again and add tests for these scenarios.
Thanks again for your work on this.
Exactly. This is because this PR is a follow-up of the already merged bug fix, see the PR description:
I created the new PR to "guard" my fix 😅 against future regressions. If you want to experience the bug, you would need to revert the mentioned PR. Then, you'll also see the automated And you can reproduce
by checking out this branch here, locally reverting 74a9a3d and then run the Regarding your code suggestion: Trusting on I'd prefer to keep the changes as small as possible - a refactoring to have the file operation finish callback work for every type of deletion feels like a significantly larger scope. Maybe a follow-up of this PR? |
28eda97 to
be20164
Compare
I think adding a guard here isn’t the right direction. The fix should address the underlying bug directly, without needing additional defensive logic.
That’s actually what concerns me. It introduces more conditional and tightly coupled behavior into a dialog fragment.
If This approach would keep the architecture simpler and make the fix easier to maintain going forward. |
be20164 to
d4a690c
Compare
@alperozturk96 okay, take a look I just added two commits:
I used the EventBus, as I saw it being used elsewhere in the repository, so I would use the same here. |
d4a690c to
5604b0d
Compare
Testing the case of localOnly files. As the deletion logic differs per scenario, tests for the online scenario will also need to be added. Signed-off-by: Philipp Hasper <vcs@hasper.info>
Otherwise, the localOnly file deletion will not update the UI. Signed-off-by: Philipp Hasper <vcs@hasper.info>
The remote + offline test case had to be ignored due to two reasons 1) Broken App behavior - The UX is indeed broken, as from a user perspective, nothing happens with the file when deleting it. The offlineOperation is put on the worker stack, but the user doesn't see anything from it - Even when coming back online, it is completely unreliable when the deletion will be finally done. It might happen 5 or 10 minutes later 2) Broken test mock - The mocked connectivityService doesn't work as expected, because the OfflineOperationsWorker has its own service, and thus might still execute the deletion, but just at an unforseable time during the test execution - see problem 1). Signed-off-by: Philipp Hasper <vcs@hasper.info>
The existing test cases varied by configuration: local vs. remote, online vs. offline. This is now extended by also starting at different entry points: beginning, end and middle of the list. Signed-off-by: Philipp Hasper <vcs@hasper.info>
Towards a better decoupling of the RemoveFilesDialogFragment from any expectations about activities currently running. Signed-off-by: Philipp Hasper <vcs@hasper.info>
Reduces the coupling, using an already existing EventBus pattern. During registration, we need to first check if it is already registered. Otherwise, the app crashed directly at first start with the error org.greenrobot.eventbus.EventBusException: Subscriber class com.owncloud.android.ui.activity.FileDisplayActivity already registered to event class com.owncloud.android.ui.events.FilesRefreshEvent Signed-off-by: Philipp Hasper <vcs@hasper.info>
5604b0d to
09b5e7e
Compare
|
blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |
|
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/16297.apk |
There was a problem hiding this comment.
Hello
Thank you very much for your effort here, we truly appreciate the work you’ve put into this. Improving testability is very valuable for us, and your contribution definitely helps move things in that direction.
That said, we’ve previously aligned on gradually eliminating EventBus and LocalBroadcastManager usage over time. This PR appears to introduce additional usages, though I completely understand that you are not aware of it. @tobiasKaminsky fyi.
Please correct me if I’m misunderstanding, but as I see it, this PR does not fix a new issue and instead focuses on adding tests and making the current logic testable. Is that correct? As far as I can tell, the related bug was already addressed in #15669, and the loading dialog timing issue was handled in #16296.
If that is correct, I would suggest that we first align on how we want to approach improving testability in these areas without introducing new EventBus dependencies. I’d be very happy to hear other opinions and discuss possible alternatives so we can decide on the most appropriate approach.
If this PR does address a specific bug that is not covered by the previous fixes, could you please share the steps to reproduce it? That would help us better understand the context and evaluate the changes more accurately.
Once again, thank you for your contribution. It’s great to see the focus on improving testability, and we genuinely appreciate the effort you’ve put into this.
|
@alperozturk96 the second commit does fix a real issue with the local-only file deletion. This can be reproduced by running the test without the fix (checkout the first commit) |

Original PR: #16184
This tests the deletion behavior when deleting from slide show, fixed in #15636. It also fixes another bug which was uncovered during the automated tests, where the view pager was not correctly updated.
This PR requires #16296 to be merged first, as the automated tests also stumble upon the same timing issue fixed (and tested!) in said PR.