mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:12:57 +08:00
Expand test coverage for different scaling modes
Intentionally not using `[Values]` as the scale modes can be applied to the running game instance directly, rather than recreating it all over again. The same could be said for the notification overlay but not sure, seems like something that should be considered at an `OsuGameTestScene` level instead (whether the same game instance can be reused for further testing).
This commit is contained in:
parent
20f193c1c2
commit
318f830cd2
@ -1,8 +1,12 @@
|
||||
// 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 System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
@ -21,21 +25,48 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
[Test]
|
||||
public void TestScreenOffsettingOnSettingsOverlay()
|
||||
{
|
||||
AddStep("open settings", () => Game.Settings.Show());
|
||||
AddUntilStep("right screen offset applied", () => Game.ScreenOffsetContainer.X == SettingsPanel.WIDTH * TestOsuGame.SIDE_OVERLAY_OFFSET_RATIO);
|
||||
foreach (var scalingMode in Enum.GetValues(typeof(ScalingMode)).Cast<ScalingMode>())
|
||||
{
|
||||
AddStep($"set scaling mode to {scalingMode}", () =>
|
||||
{
|
||||
Game.LocalConfig.SetValue(OsuSetting.Scaling, scalingMode);
|
||||
|
||||
AddStep("hide settings", () => Game.Settings.Hide());
|
||||
AddUntilStep("screen offset removed", () => Game.ScreenOffsetContainer.X == 0f);
|
||||
if (scalingMode != ScalingMode.Off)
|
||||
{
|
||||
Game.LocalConfig.SetValue(OsuSetting.ScalingSizeX, 0.5f);
|
||||
Game.LocalConfig.SetValue(OsuSetting.ScalingSizeY, 0.5f);
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("open settings", () => Game.Settings.Show());
|
||||
AddUntilStep("right screen offset applied", () => Precision.AlmostEquals(Game.ScreenOffsetContainer.X, SettingsPanel.WIDTH * TestOsuGame.SIDE_OVERLAY_OFFSET_RATIO));
|
||||
|
||||
AddStep("hide settings", () => Game.Settings.Hide());
|
||||
AddUntilStep("screen offset removed", () => Game.ScreenOffsetContainer.X == 0f);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestScreenOffsettingOnNotificationOverlay()
|
||||
{
|
||||
AddStep("open notifications", () => Game.Notifications.Show());
|
||||
AddUntilStep("right screen offset applied", () => Game.ScreenOffsetContainer.X == -NotificationOverlay.WIDTH * TestOsuGame.SIDE_OVERLAY_OFFSET_RATIO);
|
||||
foreach (var scalingMode in Enum.GetValues(typeof(ScalingMode)).Cast<ScalingMode>())
|
||||
{
|
||||
if (scalingMode != ScalingMode.Off)
|
||||
{
|
||||
AddStep($"set scaling mode to {scalingMode}", () =>
|
||||
{
|
||||
Game.LocalConfig.SetValue(OsuSetting.Scaling, scalingMode);
|
||||
Game.LocalConfig.SetValue(OsuSetting.ScalingSizeX, 0.5f);
|
||||
Game.LocalConfig.SetValue(OsuSetting.ScalingSizeY, 0.5f);
|
||||
});
|
||||
}
|
||||
|
||||
AddStep("hide notifications", () => Game.Notifications.Hide());
|
||||
AddUntilStep("screen offset removed", () => Game.ScreenOffsetContainer.X == 0f);
|
||||
AddStep("open notifications", () => Game.Notifications.Show());
|
||||
AddUntilStep("right screen offset applied", () => Precision.AlmostEquals(Game.ScreenOffsetContainer.X, -NotificationOverlay.WIDTH * TestOsuGame.SIDE_OVERLAY_OFFSET_RATIO));
|
||||
|
||||
AddStep("hide notifications", () => Game.Notifications.Hide());
|
||||
AddUntilStep("screen offset removed", () => Game.ScreenOffsetContainer.X == 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user