Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/Spice86.Tests/UI/BreakpointUiTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ protected static void ShowWindowAndWait(Window window) {
ProcessUiEvents();
}

/// <summary>
/// Closes a window and processes any deferred UI events triggered by the close
/// (e.g., window state saving) before the test context is torn down.
/// </summary>
protected static void CloseWindowAndWait(Window window) {
window.Close();
ProcessUiEvents();
}

/// <summary>
/// Selects a breakpoint type tab by name and processes UI events.
/// </summary>
Expand Down
42 changes: 21 additions & 21 deletions tests/Spice86.Tests/UI/BreakpointsViewUiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void BreakpointsView_CanCreateExecutionBreakpoint() {
viewModel.IsExecutionBreakpointSelected.Should().BeTrue();

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -75,7 +75,7 @@ public void BreakpointsView_CanCreateExecutionBreakpointWithCondition() {
viewModel.CreatingBreakpoint.Should().BeFalse();

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -104,7 +104,7 @@ public void BreakpointsView_InvalidConditionExpression_ShowsError() {
}

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand All @@ -130,7 +130,7 @@ public void BreakpointsView_CancelCreation_ClearsCreatingState() {
viewModel.CreatingBreakpoint.Should().BeFalse();

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand All @@ -147,7 +147,7 @@ public void BreakpointsView_ShowsBreakpointTypeTabs() {
viewModel.BreakpointTabs.Should().NotBeEmpty();

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -180,7 +180,7 @@ public void BreakpointsView_AcceptsComparisonOperatorConditions() {
}

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -213,7 +213,7 @@ public void BreakpointsView_AcceptsLogicalOperatorConditions() {
}

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -241,7 +241,7 @@ public void BreakpointsView_CanCreateMemoryBreakpoint() {
}

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -276,7 +276,7 @@ public void BreakpointsView_CanCreateCyclesBreakpoint() {
}

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -311,7 +311,7 @@ public void BreakpointsView_CanCreateInterruptBreakpoint() {
}

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -346,7 +346,7 @@ public void BreakpointsView_CanCreateIoPortBreakpoint() {
}

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -379,7 +379,7 @@ public void BreakpointsView_AcceptsBitwiseOperatorConditions() {
}

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -412,7 +412,7 @@ public void BreakpointsView_AcceptsArithmeticOperatorConditions() {
}

// Cleanup
window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand All @@ -436,7 +436,7 @@ public void BreakpointsView_CanCreateInterruptBreakpointWithCondition() {
viewModel.Breakpoints.Should().ContainSingle(bp =>
bp.Type == BreakPointType.CPU_INTERRUPT && bp.ConditionExpression == "ah == 0x09");

window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand All @@ -461,7 +461,7 @@ public void BreakpointsView_InterruptBreakpoint_InvalidCondition_KeepsDialogOpen
viewModel.Breakpoints.Count.Should().Be(initialCount);
viewModel.CreatingBreakpoint.Should().BeTrue();

window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand All @@ -485,7 +485,7 @@ public void BreakpointsView_CanCreateIoPortBreakpointWithCondition() {
viewModel.Breakpoints.Should().ContainSingle(bp =>
bp.Type == BreakPointType.IO_ACCESS && bp.ConditionExpression == "al == 0x01");

window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand All @@ -508,7 +508,7 @@ public void BreakpointsView_InterruptBreakpoint_OutOfRange_BlocksConfirmation()
ProcessUiEvents();
viewModel.ConfirmBreakpointCreationCommand.CanExecute(null).Should().BeTrue();

window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand All @@ -531,7 +531,7 @@ public void BreakpointsView_IoPortBreakpoint_OutOfRange_BlocksConfirmation() {
ProcessUiEvents();
viewModel.ConfirmBreakpointCreationCommand.CanExecute(null).Should().BeTrue();

window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -565,7 +565,7 @@ public void BreakpointsView_InterruptBreakpoint_Wildcard_CreatesAndRoundTrips()
// Assert: edit restores "*" instead of casting -1 to 0xFFFFFFFF
viewModel.InterruptNumber.Should().Be("*");

window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand Down Expand Up @@ -597,7 +597,7 @@ public void BreakpointsView_IoPortBreakpoint_Wildcard_CreatesAndRoundTrips() {
// Assert: edit restores "*" instead of casting -1 to 0xFFFFFFFF
viewModel.IoPortNumber.Should().Be("*");

window.Close();
CloseWindowAndWait(window);
}

/// <summary>
Expand All @@ -619,6 +619,6 @@ public void BreakpointsView_BeginCreateBreakpoint_ClearsInterruptAndIoConditions
viewModel.InterruptConditionExpression.Should().BeNull();
viewModel.IoPortConditionExpression.Should().BeNull();

window.Close();
CloseWindowAndWait(window);
}
}
1 change: 1 addition & 0 deletions tests/Spice86.Tests/UI/HeadlessInfrastructureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void TestHeadlessWindowCanBeShown() {

// Cleanup
window.Close();
Avalonia.Threading.Dispatcher.UIThread.RunJobs();
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions tests/Spice86.Tests/UI/MemoryViewUiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task FirstOccurrence_Reinvoked_ReappliesSelectionOnFoundAddress() {
harness.HexEditor.Selection.Range.Start.ByteIndex.Should().Be(expectedByteIndex);

// Cleanup
harness.Window.Close();
CloseWindowAndWait(harness.Window);
}

[AvaloniaFact]
Expand Down Expand Up @@ -71,6 +71,6 @@ public async Task FirstOccurrence_WhenFoundAddressIsOutsideCurrentWindow_Reframe
harness.HexEditor.Selection.Range.Start.ByteIndex.Should().Be(0UL);

// Cleanup
harness.Window.Close();
CloseWindowAndWait(harness.Window);
}
}
Loading