Public Access
Harden CI-sensitive recording and taskbar tests
PR and Push Build/Test / build-and-test (push) Failing after 9m57s
PR and Push Build/Test / build-and-test (push) Failing after 9m57s
This commit is contained in:
@@ -17,7 +17,7 @@ public sealed class RecordingCoordinatorTests
|
|||||||
{
|
{
|
||||||
private static async Task WaitUntilAsync(Func<bool> condition)
|
private static async Task WaitUntilAsync(Func<bool> condition)
|
||||||
{
|
{
|
||||||
var deadline = DateTimeOffset.UtcNow.AddSeconds(5);
|
var deadline = DateTimeOffset.UtcNow.AddSeconds(15);
|
||||||
while (DateTimeOffset.UtcNow < deadline)
|
while (DateTimeOffset.UtcNow < deadline)
|
||||||
{
|
{
|
||||||
if (condition())
|
if (condition())
|
||||||
@@ -367,7 +367,7 @@ public sealed class RecordingCoordinatorTests
|
|||||||
|
|
||||||
clock.Advance(TimeSpan.FromSeconds(2));
|
clock.Advance(TimeSpan.FromSeconds(2));
|
||||||
await promptService.WaitForPromptAsync();
|
await promptService.WaitForPromptAsync();
|
||||||
await WaitUntilAsync(() => !coordinator.CurrentStatus.IsRecording);
|
await WaitUntilAsync(() => summaryPipeline.WasRun);
|
||||||
|
|
||||||
Assert.Single(promptService.Requests);
|
Assert.Single(promptService.Requests);
|
||||||
Assert.False(coordinator.CurrentStatus.IsRecording);
|
Assert.False(coordinator.CurrentStatus.IsRecording);
|
||||||
@@ -464,7 +464,7 @@ public sealed class RecordingCoordinatorTests
|
|||||||
await WaitUntilAsync(() => clock.PendingDelayCount > 0);
|
await WaitUntilAsync(() => clock.PendingDelayCount > 0);
|
||||||
|
|
||||||
clock.Advance(TimeSpan.FromSeconds(3));
|
clock.Advance(TimeSpan.FromSeconds(3));
|
||||||
await WaitUntilAsync(() => !coordinator.CurrentStatus.IsRecording);
|
await WaitUntilAsync(() => summaryPipeline.WasRun);
|
||||||
|
|
||||||
Assert.Single(promptService.Requests);
|
Assert.Single(promptService.Requests);
|
||||||
Assert.True(summaryPipeline.WasRun);
|
Assert.True(summaryPipeline.WasRun);
|
||||||
|
|||||||
@@ -52,10 +52,11 @@ internal static class TaskbarIconRenderer
|
|||||||
{
|
{
|
||||||
using var path = new GraphicsPath();
|
using var path = new GraphicsPath();
|
||||||
using var format = StringFormat.GenericTypographic;
|
using var format = StringFormat.GenericTypographic;
|
||||||
|
using var fontFamily = CreateGlyphFontFamily(out var fontStyle);
|
||||||
path.AddString(
|
path.AddString(
|
||||||
text,
|
text,
|
||||||
FontFamily.GenericSansSerif,
|
fontFamily,
|
||||||
(int)FontStyle.Bold,
|
(int)fontStyle,
|
||||||
9,
|
9,
|
||||||
Point.Empty,
|
Point.Empty,
|
||||||
format);
|
format);
|
||||||
@@ -69,6 +70,65 @@ internal static class TaskbarIconRenderer
|
|||||||
graphics.FillPath(textBrush, path);
|
graphics.FillPath(textBrush, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static FontFamily CreateGlyphFontFamily(out FontStyle fontStyle)
|
||||||
|
{
|
||||||
|
foreach (var name in new[] { "Segoe UI", "Arial", "DejaVu Sans", "Liberation Sans", "Noto Sans" })
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var family = new FontFamily(name);
|
||||||
|
if (TryGetUsableStyle(family, out fontStyle))
|
||||||
|
{
|
||||||
|
return family;
|
||||||
|
}
|
||||||
|
|
||||||
|
family.Dispose();
|
||||||
|
}
|
||||||
|
catch (ArgumentException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using var installedFonts = new InstalledFontCollection();
|
||||||
|
foreach (var installedFamily in installedFonts.Families)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var family = new FontFamily(installedFamily.Name);
|
||||||
|
if (TryGetUsableStyle(family, out fontStyle))
|
||||||
|
{
|
||||||
|
return family;
|
||||||
|
}
|
||||||
|
|
||||||
|
family.Dispose();
|
||||||
|
}
|
||||||
|
catch (ArgumentException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fontStyle = FontStyle.Bold;
|
||||||
|
return FontFamily.GenericSansSerif;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryGetUsableStyle(FontFamily family, out FontStyle fontStyle)
|
||||||
|
{
|
||||||
|
if (family.IsStyleAvailable(FontStyle.Bold))
|
||||||
|
{
|
||||||
|
fontStyle = FontStyle.Bold;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (family.IsStyleAvailable(FontStyle.Regular))
|
||||||
|
{
|
||||||
|
fontStyle = FontStyle.Regular;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
fontStyle = FontStyle.Regular;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
private static extern bool DestroyIcon(IntPtr hIcon);
|
private static extern bool DestroyIcon(IntPtr hIcon);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user