Test getFileCachedCopy returns absolute path#20441
Merged
david-allison merged 1 commit intoankidroid:mainfrom Mar 11, 2026
Merged
Test getFileCachedCopy returns absolute path#20441david-allison merged 1 commit intoankidroid:mainfrom
david-allison merged 1 commit intoankidroid:mainfrom
Conversation
In older code, `getFileCachedCopy` returned a URI-encoded filepath. Later, it was updated to return a regular absolute filepath. This test enforces that behavior. I used a filename with a space because these have a particular URI-encoding (`%20`), so it should catch any regression.
|
First PR! 🚀 We sincerely appreciate that you have taken the time to propose a change to AnkiDroid! Please have patience with us as we are all volunteers - we will get to this as soon as possible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose / Description
Regression test that ensures that
getFileCachedCopyinImportUtils.ktreturns a regular absolute path, as per the@NeedsTest.Fixes
Relates to #13283.
Approach
I looked at the older
getFileCachedCopy. It used to return a URI-encoded path. It was updated to return a regular absolute filepath. That's when@NeedsTestwas added.To discriminate between old/new behavior, I used a filename with a space, since they have a particular URI-encoding. If
getFileCachedCopywere to return a URI-encoded path again, the test would catch the regression.I used the already-implemented
TestFileImporterto handle method dependencies and isolate the behavior under test.How Has This Been Tested?
Learning
A couple of things I did that helped:
@NeedsTest.TestFileImporter) helped save time and keep the commit short.Checklist
You have commented your code, particularly in hard-to-understand areasNAUI changes: include screenshots of all affected screensNAUI Changes: You have tested your change using the Google Accessibility ScannerNA