2021-08-07 03:36:40 +08:00
|
|
|
// 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.
|
|
|
|
|
2021-08-21 09:18:03 +08:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
2021-08-07 03:36:40 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Testing;
|
2021-08-21 09:18:03 +08:00
|
|
|
using osu.Framework.Utils;
|
|
|
|
using osu.Game.Configuration;
|
2021-08-07 03:36:40 +08:00
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Menus
|
|
|
|
{
|
|
|
|
public class TestSceneSideOverlays : OsuGameTestScene
|
|
|
|
{
|
|
|
|
[SetUpSteps]
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
|
|
|
|
|
|
|
AddAssert("no screen offset applied", () => Game.ScreenOffsetContainer.X == 0f);
|
2021-08-07 05:36:52 +08:00
|
|
|
AddUntilStep("wait for overlays", () => Game.Settings.IsLoaded && Game.Notifications.IsLoaded);
|
2021-08-07 03:36:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestScreenOffsettingOnSettingsOverlay()
|
|
|
|
{
|
2021-08-21 09:18:03 +08:00
|
|
|
foreach (var scalingMode in Enum.GetValues(typeof(ScalingMode)).Cast<ScalingMode>())
|
|
|
|
{
|
|
|
|
AddStep($"set scaling mode to {scalingMode}", () =>
|
|
|
|
{
|
|
|
|
Game.LocalConfig.SetValue(OsuSetting.Scaling, scalingMode);
|
2021-08-07 03:36:40 +08:00
|
|
|
|
2021-08-21 09:18:03 +08:00
|
|
|
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);
|
|
|
|
}
|
2021-08-07 03:36:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestScreenOffsettingOnNotificationOverlay()
|
|
|
|
{
|
2021-08-21 09:18:03 +08:00
|
|
|
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("open notifications", () => Game.Notifications.Show());
|
|
|
|
AddUntilStep("right screen offset applied", () => Precision.AlmostEquals(Game.ScreenOffsetContainer.X, -NotificationOverlay.WIDTH * TestOsuGame.SIDE_OVERLAY_OFFSET_RATIO));
|
2021-08-07 03:36:40 +08:00
|
|
|
|
2021-08-21 09:18:03 +08:00
|
|
|
AddStep("hide notifications", () => Game.Notifications.Hide());
|
|
|
|
AddUntilStep("screen offset removed", () => Game.ScreenOffsetContainer.X == 0f);
|
|
|
|
}
|
2021-08-07 03:36:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|