Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
They are all visual tests, so assume that Display is not null.
  • Loading branch information
hwsmm committed Jan 21, 2025
1 parent 55befe3 commit 0dbd670
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions osu.Framework.Tests/Visual/Platform/TestSceneBorderless.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ private void load(FrameworkConfigManager config, GameHost host)
AddStep("switch to borderless", () => windowMode.Value = WindowMode.Borderless);
AddAssert("check window position", () => new Point(window.Position.X, window.Position.Y) == display.Bounds.Location);
AddAssert("check window size", () => new Size(window.Size.Width, window.Size.Height) == display.Bounds.Size, desc2);
AddAssert("check current screen", () => window.CurrentDisplayBindable.Value.Index == display.Index);
AddAssert("check current screen", () => window.CurrentDisplayBindable.Value!.Index == display.Index);

// verify the window size is restored correctly
AddStep("switch to windowed", () => windowMode.Value = WindowMode.Windowed);
AddAssert("check client size", () => window.ClientSize == new Size(1280, 720));
AddAssert("check window position", () => originalWindowPosition == window.Position);
AddAssert("check current screen", () => window.CurrentDisplayBindable.Value.Index == display.Index);
AddAssert("check current screen", () => window.CurrentDisplayBindable.Value!.Index == display.Index);
}
}

Expand All @@ -107,7 +107,7 @@ protected override void Update()

currentActualSize.Text = $"Window size: {window?.Size}";
currentClientSize.Text = $"Client size: {window?.ClientSize}";
currentDisplay.Text = $"Current Display: {window?.CurrentDisplayBindable.Value.Name}";
currentDisplay.Text = $"Current Display: {window?.CurrentDisplayBindable.Value!.Name}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void TestChangeCurrentDisplay(WindowState startingState)
AddStep($"switch to {startingState}", () => window.WindowState = startingState);
AddStep("fetch a different display", () =>
{
int current = window.CurrentDisplayBindable.Value.Index;
int current = window.CurrentDisplayBindable.Value!.Index;
display = window.Displays.First(d => d.Index != current);
});
AddStep("change to that display", () => window.CurrentDisplayBindable.Value = display);
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework.Tests/Visual/Platform/TestSceneFullscreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void TestScreenModeSwitch()
if (window.SupportedWindowModes.Contains(WindowMode.Fullscreen))
{
AddStep("change to fullscreen", () => windowMode.Value = WindowMode.Fullscreen);
AddAssert("window position updated", () => window.Position, () => Is.EqualTo(window.CurrentDisplayBindable.Value.Bounds.Location));
AddAssert("window position updated", () => window.Position, () => Is.EqualTo(window.CurrentDisplayBindable.Value!.Bounds.Location));
testResolution(1920, 1080);
testResolution(1280, 960);
testResolution(9999, 9999);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void TestModeSwitchWindowed([Values] WindowMode startingMode, [Values] Wi
if (finalMode == WindowMode.Windowed)
AddAssert("resized to windowed size", () => resizeInvokes.Dequeue(), () => Is.EqualTo(windowed_size));
else
AddAssert("resized to display size", () => resizeInvokes.Dequeue(), () => Is.EqualTo(window.CurrentDisplayBindable.Value.Bounds.Size));
AddAssert("resized to display size", () => resizeInvokes.Dequeue(), () => Is.EqualTo(window.CurrentDisplayBindable.Value!.Bounds.Size));
}

protected override void Dispose(bool isDisposing)
Expand Down
6 changes: 3 additions & 3 deletions osu.Framework.Tests/Visual/Platform/WindowDisplaysPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public partial class WindowDisplaysPreview : Container

private IWindow? window;
private readonly Bindable<WindowMode> windowMode = new Bindable<WindowMode>();
private readonly Bindable<Display> currentDisplay = new Bindable<Display>();
private readonly Bindable<Display?> currentDisplay = new Bindable<Display?>();

public WindowDisplaysPreview()
{
Expand Down Expand Up @@ -116,7 +116,7 @@ private void refreshScreens(IEnumerable<Display> displays)

foreach (var display in displays)
{
screenContainer.Add(createScreen(display, window.AsNonNull().CurrentDisplayBindable.Value.Index));
screenContainer.Add(createScreen(display, window.AsNonNull().CurrentDisplayBindable.Value!.Index));
bounds = RectangleI.Union(bounds, new RectangleI(display.Bounds.X, display.Bounds.Y, display.Bounds.Width, display.Bounds.Height));
}

Expand Down Expand Up @@ -175,7 +175,7 @@ private void updateWindowContainer()
if (window == null) return;

bool fullscreen = window.WindowMode.Value == WindowMode.Fullscreen;
var currentBounds = window.CurrentDisplayBindable.Value.Bounds;
var currentBounds = window.CurrentDisplayBindable.Value!.Bounds;

windowContainer.X = window.Position.X;
windowContainer.Y = window.Position.Y;
Expand Down

0 comments on commit 0dbd670

Please sign in to comment.