Skip to content

[net11.0][Android][Testing] Use valid file-URI picker recovery fixtures - #39569

Closed
kubaflo wants to merge 1 commit into
net11.0from
kubaflo-net11-media-recovery-fixtures
Closed

kubaflo wants to merge 1 commit into
net11.0from
kubaflo-net11-media-recovery-fixtures

Conversation

@kubaflo

@kubaflo kubaflo commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Superseded by #39536. This exact test-only fix is now included in the consolidated PR at 63ef2602a7b7350595f10236097056991a55550e, with identical file contents and preserved attribution. This standalone PR is being closed without merging. The per-fix evidence below remains historical evidence for this PR's original head, not new native validation of the combined head; combined-head checks and pending CI are documented in #39536.

Correct five Android MediaPickerRecovery_Tests cases (four methods, including a two-value theory) that supplied private app-cache file:// URIs as successful incoming picker results.

FileSystemUtils.TryGetValidatedPhysicalPath intentionally rejects file paths beneath the receiving app's credential-protected or device-protected data directory, even when readable. That validation, introduced by #38127, must remain unchanged. The accepted-path case consequently throws FileNotFoundException; the four orphaned-pick cases correctly receive no recovered results after materialization fails.

Use a dedicated fixture helper to create canonical file paths under external app cache only for these successful incoming file-URI cases. Track and delete precisely those fixture-owned files during test disposal. Preserve every existing result/path/state assertion and leave private capture fixtures, content-URI fixtures, and production code unchanged.

Add Accepted_Pick_Private_File_Uri_Is_Rejected_Without_Deleting_Source to explicitly require rejection, cleared active state, no recovered results, and preservation of the private source file. Existing Android_FileSystemUtils_Tests also continue to cover credential-protected and device-protected rejection and external-cache acceptance.

This intentionally targets net11.0, where the baseline failures were observed. No production, public API, dependency, pipeline, GC, timeout, sleep, or skip changes. Open and recently merged PR searches by exact case, fixture file, and external-cache mechanism found no equivalent fixture correction.

Native validation: headless Android API 33 arm64 emulator; .NET SDK 11.0.100 and Android workload 37.2.15; Release builds. Temporary class-filter injection uses the run-device-tests skill's runner-module-initializer mechanism to set XHarness's NUNIT_SKIPPED_CLASSES include list to the entire MediaPickerRecovery_Tests and Android_FileSystemUtils_Tests classes. No method filtering or test-source exclusion. The injection is not committed.

Runtime / fixture state Repetitions Passed / total per run Failed
Mono, exact original baseline 3 82 / 87 Same 5
Mono, corrected fixtures + new private-URI control 3 88 / 88 0
Mono, only successful fixture inputs reverted 3 83 / 88 Same 5
Mono, corrected inputs restored 3 88 / 88 0
CoreCLR, original successful fixture inputs + new control 3 83 / 88 Same 5
CoreCLR, corrected inputs 3 88 / 88 0

All 18 native xUnit XML files were checked for exact test-name inventory, the two theory rows, class isolation, aggregate/count consistency, intended failure messages, and zero skipped tests or fixture errors. The original inventory is 81 recovery cases plus 6 filesystem cases; the new negative control increases it to 88. Content-URI, waiter, retained-state, and private-path controls run in every full-class pass. Packaged native libraries confirm Mono (libmonosgen-2.0.so) versus CoreCLR (libcoreclr.so).

Validation commands and results

Commands below use dotnet from the private pinned SDK. $OUT represents the local evidence directory containing the temporary MediaClassFilter.targets injection; no SDK/workload or repository configuration was changed.

Prerequisite build — passed:

dotnet build Microsoft.Maui.BuildTasks.slnf -c Release \
  -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false \
  -p:IncludeTizenTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false \
  -p:TreatWarningsAsErrors=false -v:q -bl:"$OUT/buildtasks.binlog"

Device build — passed for every table row, with mono=true for Mono and mono=false for CoreCLR, and a distinct $phase for each row:

dotnet build src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj \
  -c Release -f net11.0-android \
  -p:RuntimeIdentifierOverride=android-arm64 \
  -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false \
  -p:IncludeTizenTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false \
  -p:UseMonoRuntime="$mono" -p:_DisableCheckForUnsupportedMonoMobileRuntime=true \
  -p:AndroidPackageFormat=apk -p:TreatWarningsAsErrors=false \
  -p:CustomAfterMicrosoftCSharpTargets="$OUT/MediaClassFilter.targets" \
  -bl:"$OUT/$phase-build.binlog" -v:q

Native execution — run three times per table row, each with a unique $name; results as shown above. Expected-red arms returned exit code 1 and the same five intended assertion/materialization failures; green arms returned 0:

dotnet xharness android test \
  --app artifacts/bin/Essentials.DeviceTests/Release/net11.0-android/com.microsoft.maui.essentials.devicetests-Signed.apk \
  --package-name com.microsoft.maui.essentials.devicetests \
  --device-id emulator-5692 --output-directory "$OUT/$name" \
  --timeout 00:05:00 --arg "results-file-name=$name.xml"

Formatting — passed:

dotnet format Microsoft.Maui.sln --no-restore \
  --include src/Essentials/test/DeviceTests/Tests/Android/MediaPickerRecovery_Tests.cs \
  --exclude Templates/src --exclude-diagnostics CA1822 --verbosity quiet

git diff --check — passed. Base: 7b0ea7800db3f3faccbaecb665d32b7c61eaf932.

Coverage limits: local runtime validation is Android API 33 arm64 only; no real external camera/picker launches, other Android API levels, Apple/Windows runtime runs, or full repository suite. CI results are separate from this local causal evidence.

Issues Fixed

N/A — test-fixture baseline correction identified while investigating #39536. This PR does not modify that PR or its GC changes.

Use canonical external-cache inputs only for incoming file-URI picker recovery success cases. Keep private capture/content fixtures and production validation unchanged, clean up owned external inputs, and assert private picker URI rejection preserves its source.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4e45178d-49ea-4de1-85ae-905502e5811e
Copilot AI balanced review requested due to automatic review settings October 22, 2026 18:03
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool October 22, 2026 18:04 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39569

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39569"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool October 22, 2026 18:04 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool October 22, 2026 18:05 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool October 22, 2026 18:07 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool October 22, 2026 18:09 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool October 22, 2026 18:10 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

No blocking defects were identified, but required CI status and reported native validation remain independently unverified.

No open issues 🎉

What changed in this PR

Corrects Android MediaPicker recovery test fixtures on net11.0 to respect the private-path validation introduced by #38127, without changing production behavior.

Changes:

  • Uses canonical external-cache files for five successful file-URI picker cases, preserving existing assertions.
  • Tracks fixture-owned external files and deletes them during disposal.
  • Adds a negative test verifying private file-URI rejection, cleared recovery state, and preservation of the source file.
File Description
src/​Essentials/​test/​DeviceTests/​Tests/​Android/​MediaPickerRecovery_Tests.cs Corrects successful picker fixtures, adds cleanup, and tests private-file rejection.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 9a12d346 Deployed Oct 22, 2026 by kubaflo via conclusion #2468
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s/agent-review-in-progress AI review is currently running for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants