diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 8b94bec1..9f7dca88 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -63,6 +63,7 @@ CAUTION: Do not start the GUI as administrator. Some GUI functions do not operat
| Task | Command |
|---|---|
| Run the unit tests | `dotnet test CDPIUI.Tests/CDPIUI.Tests.csproj` |
+| Run real Windows Forms caption-font tests on Windows | `dotnet test CDPIUI.TrayIcon.Tests/CDPIUI.TrayIcon.Tests.csproj -c Release -p:Platform=x64` |
| Run the unit tests on Linux or macOS | `dotnet test CDPIUI.Tests/CDPIUI.Tests.csproj -p:EnableWindowsTargeting=true` |
| Build the release layout | `pwsh .github/scripts/build_portable.ps1` |
| Compare the installer file list with the release layout | `pwsh .github/scripts/check_setup_files.ps1` |
diff --git a/.github/CONTRIBUTING.ru.md b/.github/CONTRIBUTING.ru.md
index 390cd6c7..d1aeafc8 100644
--- a/.github/CONTRIBUTING.ru.md
+++ b/.github/CONTRIBUTING.ru.md
@@ -63,6 +63,7 @@ GUI не запускает компоненты. GUI отправляет за
| Задача | Команда |
|---|---|
| Запустить модульные тесты | `dotnet test CDPIUI.Tests/CDPIUI.Tests.csproj` |
+| Проверить шрифты подписей на настоящих Windows Forms-контролах в Windows | `dotnet test CDPIUI.TrayIcon.Tests/CDPIUI.TrayIcon.Tests.csproj -c Release -p:Platform=x64` |
| Запустить модульные тесты в Linux или macOS | `dotnet test CDPIUI.Tests/CDPIUI.Tests.csproj -p:EnableWindowsTargeting=true` |
| Собрать раскладку релиза | `pwsh .github/scripts/build_portable.ps1` |
| Сравнить список файлов установщика с раскладкой релиза | `pwsh .github/scripts/check_setup_files.ps1` |
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e18107e1..40bc0fbd 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -71,7 +71,10 @@ jobs:
dotnet build CDPIUI.TrayIcon/CDPIUI.TrayIcon.csproj -c Release -p:Platform=x64
- name: Test
- run: dotnet test CDPIUI.Tests/CDPIUI.Tests.csproj -c Release
+ run: |
+ dotnet test CDPIUI.Tests/CDPIUI.Tests.csproj -c Release
+ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
+ dotnet test CDPIUI.TrayIcon.Tests/CDPIUI.TrayIcon.Tests.csproj -c Release -p:Platform=x64
# Direct and transitive packages with a known vulnerability of moderate or higher severity fail the job.
- name: Check packages for known vulnerabilities
@@ -83,7 +86,8 @@ jobs:
@('CDPIUI.AddOns/CDPIUI.AddOns.csproj', ''),
@('CDPIUI.TrayIcon/CDPIUI.TrayIcon.csproj', '-p:Platform=x64'),
@('CDPIUI/CDPIUI.csproj', '-p:Platform=x64'),
- @('CDPIUI.Tests/CDPIUI.Tests.csproj', '')
+ @('CDPIUI.Tests/CDPIUI.Tests.csproj', ''),
+ @('CDPIUI.TrayIcon.Tests/CDPIUI.TrayIcon.Tests.csproj', '-p:Platform=x64')
)
foreach ($project in $projects) {
$extra = @($project[1] | Where-Object { $_ })
diff --git a/CDPIUI.TrayIcon.Tests/CDPIUI.TrayIcon.Tests.csproj b/CDPIUI.TrayIcon.Tests/CDPIUI.TrayIcon.Tests.csproj
new file mode 100644
index 00000000..409e2ec4
--- /dev/null
+++ b/CDPIUI.TrayIcon.Tests/CDPIUI.TrayIcon.Tests.csproj
@@ -0,0 +1,20 @@
+
+
+ net8.0-windows10.0.17763.0
+ true
+ x64
+ enable
+ enable
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CDPIUI.TrayIcon.Tests/ModernButtonFontLifetimeTests.cs b/CDPIUI.TrayIcon.Tests/ModernButtonFontLifetimeTests.cs
new file mode 100644
index 00000000..707cf1f0
--- /dev/null
+++ b/CDPIUI.TrayIcon.Tests/ModernButtonFontLifetimeTests.cs
@@ -0,0 +1,95 @@
+using System.Diagnostics;
+using System.Drawing;
+using System.Reflection;
+using System.Runtime.ExceptionServices;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using CDPIUI.TrayIcon.Controls;
+using Xunit.Abstractions;
+
+[assembly: CollectionBehavior(DisableTestParallelization = true)]
+
+namespace CDPIUI.TrayIcon.Tests;
+
+public sealed class ModernButtonFontLifetimeTests(ITestOutputHelper output)
+{
+ [Theory]
+ [InlineData("Exit", false, false, false)]
+ [InlineData("Выход", false, false, false)]
+ [InlineData("Exit", true, true, true)]
+ [InlineData("Выход", true, true, true)]
+ [InlineData("Exit", true, false, false)]
+ [InlineData("Выход", true, false, false)]
+ [InlineData("Exit", false, true, false)]
+ [InlineData("Выход", false, true, false)]
+ [InlineData("Exit", true, false, true)]
+ [InlineData("Выход", true, false, true)]
+ public void BoldAssignmentsKeepTheActualCaptionDrawable(string caption, bool first, bool second, bool third)
+ {
+ output.WriteLine(RuntimeInformation.FrameworkDescription);
+ WriteAssemblyIdentity(typeof(Control).Assembly);
+ WriteAssemblyIdentity(typeof(Font).Assembly);
+ WriteAssemblyIdentity(typeof(ModernButtonUserControl).Assembly);
+
+ RunOnStaThread(() =>
+ {
+ // Construct only this control. Do not run the tray entry point or create a visible window.
+ using var button = new ModernButtonUserControl { DisplayText = caption };
+ var label = Assert.Single(button.Controls.OfType