diff --git a/docs/engineering/a11y-safety.md b/docs/engineering/a11y-safety.md index 8e1e594..4bdc9f2 100644 --- a/docs/engineering/a11y-safety.md +++ b/docs/engineering/a11y-safety.md @@ -1,5 +1,9 @@ # A11y 無障礙與視覺安全 (A11y & Visual Safety) +- **數值編輯區尺寸**:保留 Latest 原生樣式,依 `NumericUpDown.PreferredHeight` 在字型、Handle、DPI 與系統色更新後同步高度;不得假設原生渲染器會隨大字型自動增高。寬度依有效範圍的完整格式化數字與原生微調按鈕預留,不在數值或焦點變更時改變尺寸。驗證內部編輯區能容納完整數字字形(非字型行距留白),涵蓋負數、小數、三主題及多 DPI。 +- **回饋生命週期**:直接 `Dispose` 與正常關閉都必須解除控制器及系統事件、取消表單權杖;取消關閉則保留資源。已處置的控制項不得再註冊外部權杖、事件或保留呼叫端回呼;共享字型與借用控制器不得由對話框處置。 +- **數值框重新啟用**:DPI/主題更新期間若清除焦點配色,對話框重新啟用後須依原生還原完成的實際焦點,同步套用數值框反轉、游標與預設動作提示;不得強制改變焦點或重設輸入內容。 + - **廣播與避讓 (Announce)**: - 廣播前保留 200ms 延遲 (於非 UI 執行緒執行),避開 Audio Ducking。 - 重複訊息末尾交替附加 `\u200B` (ZWSP) 或 `\u200C` (ZWNJ)。 diff --git a/src/InputBox/Core/Controls/FeedbackButton.cs b/src/InputBox/Core/Controls/FeedbackButton.cs index d92841b..ec8271b 100644 --- a/src/InputBox/Core/Controls/FeedbackButton.cs +++ b/src/InputBox/Core/Controls/FeedbackButton.cs @@ -53,6 +53,7 @@ public FeedbackButton() internal void ConfigureFeedback(string description, Font? regular, Font? bold, Action? onFocusStateChanged, CancellationToken formToken) { + if (IsDisposed || Disposing) { return; } _regular = regular ?? Font; _bold = bold; _description = description; @@ -95,12 +96,14 @@ public override Size GetPreferredSize(Size proposedSize) /// 更新呼叫端提供的共享字型,保留描述、回呼與正在進行的互動。 internal void UpdateFeedbackFonts(Font regular, Font? bold) { + if (IsDisposed || Disposing) { return; } _regular = regular; _bold = bold; Reconcile(); } internal void CancelDwell() { + if (IsDisposed || Disposing) { return; } ++_interactionVersion; StopDwell(); Reconcile(); @@ -109,6 +112,7 @@ internal void CancelDwell() /// 點擊結束後依實際游標重接視線;新的互動會使舊接合失效。 internal async Task ReGazeAfterClickAsync() { + if (IsDisposed || Disposing) { return; } int version = ++_interactionVersion; StopDwell(); Invalidate(); diff --git a/src/InputBox/Core/Controls/GamepadMessageBox.cs b/src/InputBox/Core/Controls/GamepadMessageBox.cs index 1827c42..090fe24 100644 --- a/src/InputBox/Core/Controls/GamepadMessageBox.cs +++ b/src/InputBox/Core/Controls/GamepadMessageBox.cs @@ -36,7 +36,7 @@ public IGamepadController? GamepadController get => _gamepadController; set { - if (ReferenceEquals(_gamepadController, value)) + if (IsDisposed || Disposing || _cts == null || ReferenceEquals(_gamepadController, value)) { return; } @@ -722,7 +722,15 @@ protected override void OnFormClosing(FormClosingEventArgs e) return; } + ReleaseRuntimeResources(); + } + + /// 正常關閉及直接處置共用清理;控制器與共享字型不屬於此視窗。 + private void ReleaseRuntimeResources() + { UnsubscribeGamepadEvents(); + _gamepadController = null; + SystemEvents.UserPreferenceChanged -= SystemEvents_UserPreferenceChanged; Interlocked.Exchange(ref _announcer, null)?.Dispose(); @@ -740,6 +748,22 @@ protected override void OnFormClosing(FormClosingEventArgs e) _buttonFlow = null; } + /// 未顯示或未經 FormClosing 的對話框也必須解除外部訂閱。 + protected override void Dispose(bool disposing) + { + try + { + if (disposing) + { + ReleaseRuntimeResources(); + } + } + finally + { + base.Dispose(disposing); + } + } + /// /// Handle 銷毀時確保靜態系統事件訂閱被絕對釋放。 /// @@ -1175,4 +1199,4 @@ public static DialogResult Show( MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1, IGamepadController? gamepad = null) => Show(null, text, caption, buttons, icon, defaultButton, gamepad); -} \ No newline at end of file +} diff --git a/src/InputBox/Core/Controls/NumericInputDialog.AccessibleNumericUpDown.cs b/src/InputBox/Core/Controls/NumericInputDialog.AccessibleNumericUpDown.cs index 00b1de9..505c171 100644 --- a/src/InputBox/Core/Controls/NumericInputDialog.AccessibleNumericUpDown.cs +++ b/src/InputBox/Core/Controls/NumericInputDialog.AccessibleNumericUpDown.cs @@ -22,6 +22,47 @@ private sealed class AccessibleNumericUpDown(NumericInputDialog parent) : Numeri /// private readonly NumericInputDialog _parent = parent; + /// 依原生行高及有效範圍預留完整字形,僅在字型、DPI 或系統樣式更新時調整。 + protected override void OnFontChanged(EventArgs e) + { + base.OnFontChanged(e); + UpdateEditorSize(); + } + + protected override void OnHandleCreated(EventArgs e) + { + base.OnHandleCreated(e); + UpdateEditorSize(); + } + + protected override void OnDpiChangedAfterParent(EventArgs e) + { + base.OnDpiChangedAfterParent(e); + UpdateEditorSize(); + } + + protected override void OnSystemColorsChanged(EventArgs e) + { + base.OnSystemColorsChanged(e); + UpdateEditorSize(); + } + + private void UpdateEditorSize() + { + if (!IsDisposed && !Disposing) + { + string format = $"{(ThousandsSeparator ? 'N' : 'F')}{DecimalPlaces}"; + int textWidth = Math.Max(TextRenderer.MeasureText(Minimum.ToString(format), Font).Width, + TextRenderer.MeasureText(Maximum.ToString(format), Font).Width); + int buttonsWidth = Controls.Cast().Where(control => control is not TextBox) + .Select(control => control.Width).DefaultIfEmpty().Max(); + int inset = (int)Math.Ceiling(12 * (DeviceDpi / 96.0f)); + MinimumSize = new Size(textWidth + buttonsWidth + inset, 0); + Width = Math.Max((int)Math.Ceiling(220 * (DeviceDpi / 96.0f)), MinimumSize.Width); + Height = PreferredHeight; + } + } + /// /// 遞增數值,若已達上限則通知父對話框播放邊界回饋。 /// diff --git a/src/InputBox/Core/Controls/NumericInputDialog.Gamepad.cs b/src/InputBox/Core/Controls/NumericInputDialog.Gamepad.cs index 2692e92..dcb35b8 100644 --- a/src/InputBox/Core/Controls/NumericInputDialog.Gamepad.cs +++ b/src/InputBox/Core/Controls/NumericInputDialog.Gamepad.cs @@ -30,7 +30,7 @@ public IGamepadController? GamepadController set { // 如果控制器相同,不執行任何操作。 - if (ReferenceEquals(_gamepadController, value)) + if (IsDisposed || Disposing || _cts == null || ReferenceEquals(_gamepadController, value)) { return; } diff --git a/src/InputBox/Core/Controls/NumericInputDialog.Layout.cs b/src/InputBox/Core/Controls/NumericInputDialog.Layout.cs index 64c0f94..78f6a62 100644 --- a/src/InputBox/Core/Controls/NumericInputDialog.Layout.cs +++ b/src/InputBox/Core/Controls/NumericInputDialog.Layout.cs @@ -18,6 +18,19 @@ partial class DesignerBlocker { }; /// internal sealed partial class NumericInputDialog { + protected override void OnActivated(EventArgs e) + { + base.OnActivated(e); + // 等原生焦點還原完成,再重接 DPI/主題更新期間清除的焦點反轉。 + this.SafeBeginInvoke(() => + { + if (ContainsFocus) + { + UpdateFocusVisuals(_nud?.Focused == true || _nud?.ContainsFocus == true); + } + }); + } + protected override void OnResizeEnd(EventArgs e) { try @@ -221,6 +234,7 @@ private void UpdateFocusVisuals(bool isFocused) { UpdateCaretWidth(); } + _btnOk?.Invalidate(); } catch (Exception ex) { diff --git a/src/InputBox/Core/Controls/NumericInputDialog.cs b/src/InputBox/Core/Controls/NumericInputDialog.cs index 2892132..61ad95c 100644 --- a/src/InputBox/Core/Controls/NumericInputDialog.cs +++ b/src/InputBox/Core/Controls/NumericInputDialog.cs @@ -154,6 +154,7 @@ protected override void Dispose(bool disposing) // 優先解除控制器事件訂閱,確保事件解除先於控制項處置, // 防止控制器輪詢在 UI 控制項釋放後仍觸發事件。 UnsubscribeGamepadEvents(); + _gamepadController = null; // 處置取消權杖來源(主要任務與 Flash Alert 各自獨立處置)。 Interlocked.Exchange(ref _cts, null)?.CancelAndDispose(); @@ -420,7 +421,7 @@ public NumericInputDialog( // 使用 Math.Clamp 確保數值在有效範圍內,防止異常。 Value = Math.Clamp(currentValue, minimum, maximum), TextAlign = HorizontalAlignment.Center, - // 動態縮放寬度,高度則由 Font 自動決定。 + // 動態縮放寬度;AccessibleNumericUpDown 依原生偏好高度同步字型與 DPI。 Width = (int)(220 * scale), Font = _nudFont, BackColor = Color.Empty, diff --git a/tests/InputBox.Tests/BlinkFrameRenderingTests.cs b/tests/InputBox.Tests/BlinkFrameRenderingTests.cs index 1fc0734..929cbce 100644 --- a/tests/InputBox.Tests/BlinkFrameRenderingTests.cs +++ b/tests/InputBox.Tests/BlinkFrameRenderingTests.cs @@ -2,7 +2,9 @@ using InputBox.Core.Extensions; using InputBox.Core.Feedback; using InputBox.Core.Interop; +using InputBox.Core.Services; using System.Runtime.ExceptionServices; +using System.Runtime.InteropServices; using Xunit; namespace InputBox.Tests; @@ -10,7 +12,7 @@ namespace InputBox.Tests; /// 以實際畫面驗證 Blink 完成/取消後的非客戶區框架,不以重新繪圖的截圖 API 掩蓋殘影。 [Collection(UiSmokeTestRequirements.CollectionName)] [Trait("Category", "UI")] -public sealed class BlinkFrameRenderingTests +public sealed partial class BlinkFrameRenderingTests { /// 以明確色彩模式建立獨立驗證程序,保留實際 Windows 高對比判斷。 static BlinkFrameRenderingTests() @@ -51,6 +53,10 @@ public void Blink_Finally_RestoresFrameWithoutChangingInputState(bool focused, b { try { + _ = User32.ShowWindow(form.Handle, User32.ShowWindowCommand.Restore); + _ = await WindowFocusService.RestoreWindowAsync(form.Handle, TestContext.Current.CancellationToken); + form.Activate(); + Assert.Equal(form.Handle, User32.GetForegroundWindow()); if (focused) { Assert.True(input.Focus()); @@ -102,6 +108,8 @@ await FlashAlertAnimator.RunAsync(form, intensity => } await Task.Delay(500, TestContext.Current.CancellationToken); using Bitmap after = Capture(input); + SaveCapture(before, $"blink-{focused}-{cancel}-before"); + SaveCapture(after, $"blink-{focused}-{cancel}-after"); Assert.True(framePaintedDuringAlert); Assert.Equal(expectedBack, input.BackColor); Assert.Equal(expectedFore, input.ForeColor); @@ -146,9 +154,16 @@ await FlashAlertAnimator.RunAsync(form, intensity => /// 容許螢幕合成的兩階 RGB 量化差;警示殘色仍會產生遠大於此值的差異。 private static void AssertFramePixel(Color expected, Color actual) { - Assert.InRange(Math.Abs(expected.R - actual.R), 0, 2); - Assert.InRange(Math.Abs(expected.G - actual.G), 0, 2); - Assert.InRange(Math.Abs(expected.B - actual.B), 0, 2); + Assert.True(Math.Abs(expected.R - actual.R) <= 2 && Math.Abs(expected.G - actual.G) <= 2 && + Math.Abs(expected.B - actual.B) <= 2, $"Frame pixel expected {expected}, actual {actual}."); + } + + private static void SaveCapture(Bitmap image, string name) + { + string? path = Environment.GetEnvironmentVariable("INPUTBOX_BUTTON_ARTIFACTS"); + if (path is null) { return; } + Directory.CreateDirectory(path); + image.Save(Path.Combine(path, name + ".png")); } /// 依與主視窗相同的還原順序先重設主題,再套用焦點背景與外框。 private static void Restore(Panel host, TextBox input) @@ -167,10 +182,38 @@ private static void Restore(Panel host, TextBox input) /// 只讀取自家控制項所在的螢幕像素,不透過 DrawToBitmap 觸發額外框架重繪。 private static Bitmap Capture(Control control) { - Point origin = control.Parent!.PointToScreen(control.Location); - var bitmap = new Bitmap(control.Width, control.Height); - using Graphics graphics = Graphics.FromImage(bitmap); - graphics.CopyFromScreen(origin, Point.Empty, control.Size); - return bitmap; + Assert.Equal(control.FindForm()!.Handle, User32.GetForegroundWindow()); + // Classic/高對比的游標會碰到首列像素;只在擷取期間隱藏並成對還原, + // 避免把游標閃爍的相位差誤當成框架殘色,不重繪或修改框架像素。 + bool caretHidden = control.Focused && HideCaret(control.Handle); + try + { + Assert.Equal(0, DwmFlush()); + Point origin = control.Parent!.PointToScreen(control.Location); + var bitmap = new Bitmap(control.Width, control.Height); + try + { + using Graphics graphics = Graphics.FromImage(bitmap); + graphics.CopyFromScreen(origin, Point.Empty, control.Size); + AssertFramePixel(control.BackColor, bitmap.GetPixel(bitmap.Width / 2, bitmap.Height / 2)); + return bitmap; + } + catch + { + bitmap.Dispose(); + throw; + } + } + finally + { + if (caretHidden) { _ = User32.ShowCaret(control.Handle); } + } } -} \ No newline at end of file + + [LibraryImport("user32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + private static partial bool HideCaret(nint window); + + [LibraryImport("dwmapi.dll")] + private static partial int DwmFlush(); +} diff --git a/tests/InputBox.Tests/FeedbackButtonLifetimeTests.cs b/tests/InputBox.Tests/FeedbackButtonLifetimeTests.cs new file mode 100644 index 0000000..4220190 --- /dev/null +++ b/tests/InputBox.Tests/FeedbackButtonLifetimeTests.cs @@ -0,0 +1,30 @@ +using InputBox.Core.Controls; +using InputBox.Core.Extensions; +using System.Runtime.CompilerServices; +using Xunit; + +namespace InputBox.Tests; + +public sealed class FeedbackButtonLifetimeTests +{ + [Fact] + public void AttachAfterDispose_DoesNotRetainButtonThroughLiveToken() + { + using CancellationTokenSource lifetime = new(); + WeakReference reference = CreateDisposedButton(lifetime.Token); + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + Assert.False(reference.IsAlive); + GC.KeepAlive(lifetime); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static WeakReference CreateDisposedButton(CancellationToken token) + { + FeedbackButton button = new(); + button.Dispose(); + button.AttachEyeTrackerFeedback("disposed", null, null, token); + return new WeakReference(button); + } +} diff --git a/tests/InputBox.Tests/GamepadMessageBoxTests.cs b/tests/InputBox.Tests/GamepadMessageBoxTests.cs index df39360..e841bdd 100644 --- a/tests/InputBox.Tests/GamepadMessageBoxTests.cs +++ b/tests/InputBox.Tests/GamepadMessageBoxTests.cs @@ -14,6 +14,42 @@ namespace InputBox.Tests; /// public sealed class GamepadMessageBoxTests { + [Fact] + public void NumericDialog_Dispose_DetachesControllerAndRejectsRebinding() + { + StubGamepadController controller = new(); + using NumericInputDialog dialog = new("number", 100, 100, 0, 1, 1, 10000); + dialog.GamepadController = controller; + FieldInfo[] events = [.. typeof(StubGamepadController).GetFields(BindingFlags.Instance | BindingFlags.NonPublic).Where(field => typeof(Delegate).IsAssignableFrom(field.FieldType))]; + Assert.Contains(events, field => field.GetValue(controller) != null); + + dialog.Dispose(); + dialog.GamepadController = controller; + + Assert.Null(dialog.GamepadController); + Assert.All(events, field => Assert.Null(field.GetValue(controller))); + } + + [Fact] + public void Dispose_WithoutClosing_DetachesControllerAndRejectsRebinding() + { + StubGamepadController controller = new(); + using GamepadMessageBox dialog = new("message", "caption", MessageBoxButtons.OK, MessageBoxIcon.None); + dialog.GamepadController = controller; + FieldInfo[] events = [.. typeof(StubGamepadController).GetFields(BindingFlags.Instance | BindingFlags.NonPublic).Where(field => typeof(Delegate).IsAssignableFrom(field.FieldType))]; + Assert.Contains(events, field => field.GetValue(controller) != null); + CancellationToken token = ((CancellationTokenSource)typeof(GamepadMessageBox) + .GetField("_cts", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(dialog)!).Token; + + dialog.Dispose(); + dialog.GamepadController = controller; + dialog.Dispose(); + + Assert.True(token.IsCancellationRequested); + Assert.Null(dialog.GamepadController); + Assert.All(events, field => Assert.Null(field.GetValue(controller))); + } + /// /// 測試替身控制器:可指定連線狀態,供對話框初始化提示列與事件綁定驗證使用。 /// @@ -334,4 +370,4 @@ public void GamepadButtons_NintendoMode_SwapsPhysicalConfirmAndCancelBehavior() AppSettings.Current.GamepadFaceButtonModeType = previousMode; } } -} \ No newline at end of file +} diff --git a/tests/InputBox.Tests/NumericInputLayoutTests.cs b/tests/InputBox.Tests/NumericInputLayoutTests.cs new file mode 100644 index 0000000..1fe1834 --- /dev/null +++ b/tests/InputBox.Tests/NumericInputLayoutTests.cs @@ -0,0 +1,126 @@ +using InputBox.Core.Controls; +using InputBox.Core.Extensions; +using InputBox.Core.Services; +using System.Reflection; +using System.Runtime.ExceptionServices; +using Xunit; + +namespace InputBox.Tests; + +[Collection(UiSmokeTestRequirements.CollectionName)] +[Trait("Category", "UI")] +public sealed class NumericInputLayoutTests +{ + static NumericInputLayoutTests() + { + Application.SetHighDpiMode(Environment.GetEnvironmentVariable("INPUTBOX_BUTTON_TEST_96DPI") == "1" ? HighDpiMode.DpiUnaware : HighDpiMode.PerMonitorV2); + Application.EnableVisualStyles(); + Application.SetColorMode(Environment.GetEnvironmentVariable("INPUTBOX_BUTTON_TEST_DARK") == "1" ? SystemColorMode.Dark : SystemColorMode.Classic); + Application.SetDefaultVisualStylesMode(VisualStylesMode.Latest); + } + + [Theory(Skip = "Requires explicit UI test opt-in.", SkipUnless = nameof(UiSmokeTestRequirements.IsEnabled), SkipType = typeof(UiSmokeTestRequirements))] + [InlineData(24)] + [InlineData(35)] + [InlineData(48)] + public void LatestNumericEditor_LargeFont_FitsCompleteLine(float size) + { + using NumericInputDialog dialog = new("number", 100, 100, 2, 1, -10000, 10000); + NumericUpDown number = (NumericUpDown)typeof(NumericInputDialog) + .GetField("_nud", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(dialog)!; + _ = number.Handle; + Control editor = Assert.Single(number.Controls.Cast(), control => control is TextBox); + Assert.True(editor.ClientSize.Height >= MeasureNumericGlyphHeight(number.Font, number.DeviceDpi), + $"Initial editor {editor.ClientSize.Height}px, font {number.Font.Height}px, control {number.Height}px, preferred {number.PreferredHeight}px at {number.DeviceDpi} DPI."); + using Font font = new(number.Font.FontFamily, size, FontStyle.Bold); + number.Font = font; + number.PerformLayout(); + + Assert.True(editor.ClientSize.Height >= MeasureNumericGlyphHeight(font, number.DeviceDpi), + $"Editor {editor.ClientSize.Height}px must fit font {font.Height}px at {number.DeviceDpi} DPI."); + Assert.True(editor.ClientSize.Width >= TextRenderer.MeasureText(number.Minimum.ToString("F2"), font).Width); + Assert.True(editor.ClientSize.Width >= TextRenderer.MeasureText(number.Maximum.ToString("F2"), font).Width); + Size stableSize = number.Size; + number.Value = number.Minimum; + Assert.Equal(stableSize, number.Size); + number.Value = number.Maximum; + Assert.Equal(stableSize, number.Size); + number.Value = 100; + Assert.Equal(100, number.Value); + } + + [Fact(Skip = "Requires explicit UI test opt-in.", SkipUnless = nameof(UiSmokeTestRequirements.IsEnabled), SkipType = typeof(UiSmokeTestRequirements))] + public void Reactivation_AfterInactiveThemeReset_RestoresInputFocusColors() + { + Exception? failure = null; + Thread thread = new(() => + { + try + { + using NumericInputDialog dialog = new("number", 100, 100, 0, 1, 1, 10000); + using Form other = new() { Location = new Point(850, 550), StartPosition = FormStartPosition.Manual }; + NumericUpDown number = (NumericUpDown)typeof(NumericInputDialog) + .GetField("_nud", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(dialog)!; + dialog.Shown += async (_, _) => + { + try + { + _ = await WindowFocusService.RestoreWindowAsync(dialog.Handle, TestContext.Current.CancellationToken); + number.Focus(); + await Task.Delay(80); + Color background = number.BackColor; + Color foreground = number.ForeColor; + Size size = number.Size; + other.Show(); + _ = await WindowFocusService.RestoreWindowAsync(other.Handle, TestContext.Current.CancellationToken); + Assert.False(dialog.ContainsFocus); + number.ResetThemeRecursive(); + Assert.NotEqual(background, number.BackColor); + + _ = await WindowFocusService.RestoreWindowAsync(dialog.Handle, TestContext.Current.CancellationToken); + await Task.Delay(80); + Assert.True(number.ContainsFocus); + Assert.Equal(background, number.BackColor); + Assert.Equal(foreground, number.ForeColor); + Assert.Equal(size, number.Size); + } + catch (Exception ex) { failure = ex; } + finally { other.Close(); dialog.Close(); } + }; + Application.Run(dialog); + } + catch (Exception ex) { failure = ex; } + }); + thread.SetApartmentState(ApartmentState.STA); + thread.Start(); + thread.Join(); + if (failure is not null) { ExceptionDispatchInfo.Capture(failure).Throw(); } + } + + private static int MeasureNumericGlyphHeight(Font font, int dpi) + { + // 原生 Classic 的行距可能含編輯區外的留白;驗證完整數字字形而非空白行距。 + using Bitmap bitmap = new(1000, font.Height * 3); + bitmap.SetResolution(dpi, dpi); + using Graphics graphics = Graphics.FromImage(bitmap); + graphics.Clear(Color.Black); + TextRenderer.DrawText(graphics, "-0123456789.,", font, new Point(0, font.Height), Color.White, + TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine); + int top = bitmap.Height; + int bottom = -1; + for (int y = 0; y < bitmap.Height; y++) + { + for (int x = 0; x < bitmap.Width; x++) + { + if (bitmap.GetPixel(x, y).ToArgb() != Color.Black.ToArgb()) + { + top = Math.Min(top, y); + bottom = y; + break; + } + } + } + Assert.True(bottom >= top, "Numeric glyph reference must contain visible pixels."); + return bottom - top + 1; + } +} diff --git a/tests/InputBox.Tests/README.md b/tests/InputBox.Tests/README.md index eb9df0b..a5f7636 100644 --- a/tests/InputBox.Tests/README.md +++ b/tests/InputBox.Tests/README.md @@ -34,7 +34,9 @@ | `GamepadRepeatStateMachineTests` | `GamepadRepeatStateMachine.AdvanceDirectionRepeat` / `AdvanceHeldRepeat` | 11 | | `GamepadSignalEvaluatorTests` | `GamepadSignalEvaluator.IsActive` / `IsIdle`(int / float 多載) | 13 | | `GaussianDelayHelperTests` | `GaussianDelayHelper` 延遲計算 | 5 | -| `GamepadMessageBoxTests` | `GamepadMessageBox` 關閉取消、生命週期資源保護與已連線控制器提示同步 | 5 | +| `GamepadMessageBoxTests` | 訊息框/數值框直接 Dispose 解除事件及拒絕重新綁定、訊息框關閉取消、生命週期資源保護與已連線控制器提示同步 | 7 | +| `FeedbackButtonLifetimeTests` | 已處置按鈕不得由重新綁定的長生命週期權杖持有 | 1 | +| `NumericInputLayoutTests` | Latest 大字型完整數字字形與有效範圍寬度(24/35/48 pt)、數值更新零抖動、重新啟用後焦點配色還原 | 4 | | `InputBoxLayoutManagerTests` | `InputBoxLayoutManager` 版面管理 | 4 | | `InputHistoryServiceTests` | `InputHistoryService` 歷程記錄 CRUD 與 5 筆翻頁導覽 | 15 | | `LoggerServiceTests` | `LoggerService` 測試環境專屬日誌分流、Release-like 日誌門檻、環境變數覆寫與正式日誌隔離保護 | 8 | @@ -51,8 +53,8 @@ | `VibrationPatternsTests` | `VibrationPatterns` 與方向性震動設定、語意情境解析、能力感知的多段式微震動序列,以及歷程滾輪阻尼感、字數上限硬牆、震動強度預覽、右搖桿選取粒度、組合鍵進入提示與喚起握手回饋的回歸保護 | 37 | | `VibrationSafetyLimiterTests` | `VibrationSafetyLimiter` 熱保護、Duty Cycle 限制器與極端邊界保護;馬達數量熱成本倍率正規化,以及所有內建震動模式在冷啟動下不得被拒絕、單次超出預算改為降強度,以及Critical 自動連發(含不同模式交錯)降級、熱負載不失控,以及冷啟動短序列仍完整送出的回歸保護 | 20 | | `ButtonFeedbackRenderingTests` | Standard/Latest 原生色彩、焦點與高對比按壓、Dwell 可見襯底與全進度、Space/滑鼠交錯、Capture 取消、生命週期、字型更新、過期點擊接合、三主題過渡、七語系/RTL | 72 | -| `BlinkFrameRenderingTests` | 實際螢幕非客戶區像素:Blink 完成/取消、有/無焦點還原;HWND、選取範圍及尺寸不變 | 4 | -| **合計** | | **543** | +| `BlinkFrameRenderingTests` | 實際螢幕非客戶區像素:前景視窗與背景色守門、擷取時平衡隱藏/還原游標以排除相位差、保留原始前後圖;Blink 完成/取消、有/無焦點還原,HWND、選取範圍及尺寸不變 | 4 | +| **合計** | | **550** | ## 二、執行方式 🚀