From f4856cda7161125e0ce18aaaf5e0b023f94a1267 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Thu, 2 Jul 2026 15:31:54 +0700 Subject: [PATCH 01/17] Add Android device smoke tests via DeviceRunners Introduce a MAUI-based test host for on-device xUnit runs on Android, with a dotnet test script and xharness tool manifest for CI/local use. Co-authored-by: Cursor --- .config/dotnet-tools.json | 12 + scripts/run-android-tests.ps1 | 58 +++ source/icu.net.android.tests/App.xaml | 14 + source/icu.net.android.tests/App.xaml.cs | 16 + source/icu.net.android.tests/AppShell.xaml | 14 + source/icu.net.android.tests/AppShell.xaml.cs | 9 + source/icu.net.android.tests/MainPage.xaml | 36 ++ source/icu.net.android.tests/MainPage.xaml.cs | 23 + source/icu.net.android.tests/MauiProgram.cs | 26 ++ .../Platforms/Android/AndroidManifest.xml | 6 + .../Platforms/Android/MainActivity.cs | 15 + .../Platforms/Android/MainApplication.cs | 15 + .../Android/Resources/values/colors.xml | 6 + .../Platforms/MacCatalyst/AppDelegate.cs | 9 + .../Platforms/MacCatalyst/Entitlements.plist | 14 + .../Platforms/MacCatalyst/Info.plist | 40 ++ .../Platforms/MacCatalyst/Program.cs | 15 + .../Platforms/Windows/App.xaml | 8 + .../Platforms/Windows/App.xaml.cs | 24 + .../Platforms/Windows/Package.appxmanifest | 46 ++ .../Platforms/Windows/app.manifest | 17 + .../Platforms/iOS/AppDelegate.cs | 9 + .../Platforms/iOS/Info.plist | 32 ++ .../Platforms/iOS/Program.cs | 15 + .../iOS/Resources/PrivacyInfo.xcprivacy | 51 ++ .../Properties/launchSettings.json | 8 + .../Resources/AppIcon/appicon.svg | 4 + .../Resources/AppIcon/appiconfg.svg | 8 + .../Resources/Fonts/OpenSans-Regular.ttf | Bin 0 -> 107280 bytes .../Resources/Fonts/OpenSans-Semibold.ttf | Bin 0 -> 111204 bytes .../Resources/Images/dotnet_bot.png | Bin 0 -> 92532 bytes .../Resources/Raw/AboutAssets.txt | 15 + .../Resources/Splash/splash.svg | 8 + .../Resources/Styles/Colors.xaml | 44 ++ .../Resources/Styles/Styles.xaml | 434 ++++++++++++++++++ .../Tests/AndroidSmokeTests.cs | 18 + source/icu.net.android.tests/Usings.cs | 1 + .../icu.net.android.tests.csproj | 52 +++ source/icu.net.sln | 42 ++ 39 files changed, 1164 insertions(+) create mode 100644 .config/dotnet-tools.json create mode 100644 scripts/run-android-tests.ps1 create mode 100644 source/icu.net.android.tests/App.xaml create mode 100644 source/icu.net.android.tests/App.xaml.cs create mode 100644 source/icu.net.android.tests/AppShell.xaml create mode 100644 source/icu.net.android.tests/AppShell.xaml.cs create mode 100644 source/icu.net.android.tests/MainPage.xaml create mode 100644 source/icu.net.android.tests/MainPage.xaml.cs create mode 100644 source/icu.net.android.tests/MauiProgram.cs create mode 100644 source/icu.net.android.tests/Platforms/Android/AndroidManifest.xml create mode 100644 source/icu.net.android.tests/Platforms/Android/MainActivity.cs create mode 100644 source/icu.net.android.tests/Platforms/Android/MainApplication.cs create mode 100644 source/icu.net.android.tests/Platforms/Android/Resources/values/colors.xml create mode 100644 source/icu.net.android.tests/Platforms/MacCatalyst/AppDelegate.cs create mode 100644 source/icu.net.android.tests/Platforms/MacCatalyst/Entitlements.plist create mode 100644 source/icu.net.android.tests/Platforms/MacCatalyst/Info.plist create mode 100644 source/icu.net.android.tests/Platforms/MacCatalyst/Program.cs create mode 100644 source/icu.net.android.tests/Platforms/Windows/App.xaml create mode 100644 source/icu.net.android.tests/Platforms/Windows/App.xaml.cs create mode 100644 source/icu.net.android.tests/Platforms/Windows/Package.appxmanifest create mode 100644 source/icu.net.android.tests/Platforms/Windows/app.manifest create mode 100644 source/icu.net.android.tests/Platforms/iOS/AppDelegate.cs create mode 100644 source/icu.net.android.tests/Platforms/iOS/Info.plist create mode 100644 source/icu.net.android.tests/Platforms/iOS/Program.cs create mode 100644 source/icu.net.android.tests/Platforms/iOS/Resources/PrivacyInfo.xcprivacy create mode 100644 source/icu.net.android.tests/Properties/launchSettings.json create mode 100644 source/icu.net.android.tests/Resources/AppIcon/appicon.svg create mode 100644 source/icu.net.android.tests/Resources/AppIcon/appiconfg.svg create mode 100644 source/icu.net.android.tests/Resources/Fonts/OpenSans-Regular.ttf create mode 100644 source/icu.net.android.tests/Resources/Fonts/OpenSans-Semibold.ttf create mode 100644 source/icu.net.android.tests/Resources/Images/dotnet_bot.png create mode 100644 source/icu.net.android.tests/Resources/Raw/AboutAssets.txt create mode 100644 source/icu.net.android.tests/Resources/Splash/splash.svg create mode 100644 source/icu.net.android.tests/Resources/Styles/Colors.xaml create mode 100644 source/icu.net.android.tests/Resources/Styles/Styles.xaml create mode 100644 source/icu.net.android.tests/Tests/AndroidSmokeTests.cs create mode 100644 source/icu.net.android.tests/Usings.cs create mode 100644 source/icu.net.android.tests/icu.net.android.tests.csproj diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 00000000..f3227c98 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "microsoft.dotnet.xharness.cli": { + "version": "11.0.0-prerelease.26217.1", + "commands": [ + "xharness" + ] + } + } +} diff --git a/scripts/run-android-tests.ps1 b/scripts/run-android-tests.ps1 new file mode 100644 index 00000000..b86d1888 --- /dev/null +++ b/scripts/run-android-tests.ps1 @@ -0,0 +1,58 @@ +#Requires -Version 5.1 +<# +.SYNOPSIS + Run icu.net Android device smoke tests via dotnet test. + +.DESCRIPTION + Prerequisites: + - .NET 10 SDK with MAUI Android workload: dotnet workload install maui-android + - Android SDK (ANDROID_HOME set) with an emulator running or USB device attached + - Verify device connectivity: adb devices + +.EXAMPLE + .\scripts\run-android-tests.ps1 + .\scripts\run-android-tests.ps1 -Configuration Debug +#> +[CmdletBinding()] +param( + [ValidateSet('Debug', 'Release')] + [string] $Configuration = 'Release' +) + +$ErrorActionPreference = 'Stop' +$repoRoot = Split-Path -Parent $PSScriptRoot +$project = Join-Path $repoRoot 'source\icu.net.android.tests\icu.net.android.tests.csproj' + +function Find-Adb { + if ($env:ANDROID_HOME) { + $adb = Join-Path $env:ANDROID_HOME 'platform-tools\adb.exe' + if (Test-Path $adb) { return $adb } + } + $adbOnPath = Get-Command adb -ErrorAction SilentlyContinue + if ($adbOnPath) { return $adbOnPath.Source } + return $null +} + +$adb = Find-Adb +if (-not $adb) { + Write-Error @" +adb not found. Install the Android SDK and set ANDROID_HOME, or add platform-tools to PATH. +Example: dotnet workload install maui-android +"@ +} + +$devices = & $adb devices 2>&1 | Select-Object -Skip 1 | Where-Object { $_ -match '\t' -and $_ -notmatch 'offline' } +if (-not $devices) { + Write-Error @" +No Android emulator or device detected. Start an emulator or connect a device, then run: + adb devices +"@ +} + +Write-Host "Using adb: $adb" +Write-Host "Connected devices:" +$devices | ForEach-Object { Write-Host " $_" } + +Write-Host "Running Android device tests ($Configuration)..." +dotnet test $project -f net10.0-android -c $Configuration +exit $LASTEXITCODE diff --git a/source/icu.net.android.tests/App.xaml b/source/icu.net.android.tests/App.xaml new file mode 100644 index 00000000..7c7704a7 --- /dev/null +++ b/source/icu.net.android.tests/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/source/icu.net.android.tests/App.xaml.cs b/source/icu.net.android.tests/App.xaml.cs new file mode 100644 index 00000000..1a3ea98a --- /dev/null +++ b/source/icu.net.android.tests/App.xaml.cs @@ -0,0 +1,16 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace icu.net.android.tests; + +public partial class App : Application +{ + public App() + { + InitializeComponent(); + } + + protected override Window CreateWindow(IActivationState? activationState) + { + return new Window(new AppShell()); + } +} \ No newline at end of file diff --git a/source/icu.net.android.tests/AppShell.xaml b/source/icu.net.android.tests/AppShell.xaml new file mode 100644 index 00000000..1e8dd76d --- /dev/null +++ b/source/icu.net.android.tests/AppShell.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/source/icu.net.android.tests/AppShell.xaml.cs b/source/icu.net.android.tests/AppShell.xaml.cs new file mode 100644 index 00000000..e8c843cc --- /dev/null +++ b/source/icu.net.android.tests/AppShell.xaml.cs @@ -0,0 +1,9 @@ +namespace icu.net.android.tests; + +public partial class AppShell : Shell +{ + public AppShell() + { + InitializeComponent(); + } +} diff --git a/source/icu.net.android.tests/MainPage.xaml b/source/icu.net.android.tests/MainPage.xaml new file mode 100644 index 00000000..a71267f7 --- /dev/null +++ b/source/icu.net.android.tests/MainPage.xaml @@ -0,0 +1,36 @@ + + + + + + + +