Files
osu-framework/osu.Framework.Tests/Visual/Platform/TestSceneRaiseWindow.cs
2023-07-19 23:07:16 +02:00

37 lines
1.3 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Platform;
namespace osu.Framework.Tests.Visual.Platform
{
[Ignore("This test cannot be run in headless mode (a window instance is required).")]
public partial class TestSceneRaiseWindow : FrameworkTestScene
{
public override bool AutomaticallyRunFirstStep => false;
private IWindow window = null!;
[BackgroundDependencyLoader]
private void load(GameHost host)
{
window = host.Window!;
}
[TestCase(WindowMode.Windowed)]
[TestCase(WindowMode.Borderless)]
[TestCase(WindowMode.Fullscreen)]
public void TestRaise(WindowMode windowMode)
{
AddStep($"set mode to {windowMode}", () => window.WindowMode.Value = windowMode);
AddUntilStep("wait for window to lose focus", () => window.IsActive.Value, () => Is.False);
AddWaitStep("do nothing to give the WM breathing room", 5);
AddStep("raise window", () => window.Raise());
AddAssert("window has focus", () => window.IsActive.Value, () => Is.True);
}
}
}