Public Access
Add inactivity safeguard and speaker diagnostics
PR and Push Build/Test / build-and-test (push) Failing after 8m31s
PR and Push Build/Test / build-and-test (push) Failing after 8m31s
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using MeetingAssistant.LaunchProfiles;
|
||||
using MeetingAssistant.Recording;
|
||||
using MeetingAssistant.Taskbar;
|
||||
using System.Drawing;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace MeetingAssistant.Tests;
|
||||
|
||||
@@ -81,6 +83,29 @@ public sealed class TaskbarIconTests
|
||||
Assert.Equal(RecordingProcessState.Recording, menu.State);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SupportedOSPlatform("windows")]
|
||||
public void TaskbarIconGlyphsAreVisuallyCentered()
|
||||
{
|
||||
foreach (var state in new[]
|
||||
{
|
||||
RecordingProcessState.Idle,
|
||||
RecordingProcessState.Recording,
|
||||
RecordingProcessState.Summarizing
|
||||
})
|
||||
{
|
||||
using var bitmap = TaskbarIconRenderer.RenderBitmap(state);
|
||||
var bounds = GetVisibleGlyphBounds(bitmap);
|
||||
|
||||
Assert.True(
|
||||
IsCentered(GetCenter(bounds.Left, bounds.Right)),
|
||||
$"{state} glyph is horizontally off-center: {bounds}");
|
||||
Assert.True(
|
||||
IsCentered(GetCenter(bounds.Top, bounds.Bottom)),
|
||||
$"{state} glyph is vertically off-center: {bounds}");
|
||||
}
|
||||
}
|
||||
|
||||
private static LaunchProfile Profile(string name, string hotkey = "")
|
||||
{
|
||||
return new LaunchProfile(name, new MeetingAssistantOptions
|
||||
@@ -106,4 +131,42 @@ public sealed class TaskbarIconTests
|
||||
state,
|
||||
profile);
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
private static Rectangle GetVisibleGlyphBounds(Bitmap bitmap)
|
||||
{
|
||||
var left = bitmap.Width;
|
||||
var top = bitmap.Height;
|
||||
var right = -1;
|
||||
var bottom = -1;
|
||||
for (var y = 0; y < bitmap.Height; y++)
|
||||
{
|
||||
for (var x = 0; x < bitmap.Width; x++)
|
||||
{
|
||||
var pixel = bitmap.GetPixel(x, y);
|
||||
if (pixel.A < 32 || pixel.GetBrightness() < 0.58f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
left = Math.Min(left, x);
|
||||
top = Math.Min(top, y);
|
||||
right = Math.Max(right, x);
|
||||
bottom = Math.Max(bottom, y);
|
||||
}
|
||||
}
|
||||
|
||||
Assert.True(right >= left && bottom >= top, "Expected the icon to contain a visible white glyph.");
|
||||
return Rectangle.FromLTRB(left, top, right, bottom);
|
||||
}
|
||||
|
||||
private static double GetCenter(int start, int end)
|
||||
{
|
||||
return (start + end) / 2.0;
|
||||
}
|
||||
|
||||
private static bool IsCentered(double center)
|
||||
{
|
||||
return center is >= 7.25 and <= 8.75;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user