osu/osu.Game.Tests/Visual/UserInterface/TestSceneModsEffectDisplay.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 lines
2.4 KiB
C#
Raw Normal View History

2022-08-27 17:12:45 +00: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.
2022-08-27 23:59:38 +00:00
using System.Linq;
2022-08-27 17:12:45 +00:00
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
2022-08-27 23:59:38 +00:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2022-08-27 17:12:45 +00:00
using osu.Framework.Localisation;
2022-08-27 23:59:38 +00:00
using osu.Framework.Testing;
2022-08-27 17:12:45 +00:00
using osu.Game.Graphics;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
2022-08-27 23:59:38 +00:00
using osu.Game.Rulesets.Mods;
using osuTK.Graphics;
2022-08-27 17:12:45 +00:00
namespace osu.Game.Tests.Visual.UserInterface
{
2022-08-27 23:59:38 +00:00
[TestFixture]
2022-08-27 17:12:45 +00:00
public partial class TestSceneModsEffectDisplay : OsuTestScene
{
[Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
2022-08-27 23:59:38 +00:00
[Resolved]
private OsuColour colours { get; set; } = null!;
2022-08-27 17:12:45 +00:00
[Test]
2022-08-27 23:59:38 +00:00
public void TestModsEffectDisplay()
2022-08-27 17:12:45 +00:00
{
2022-08-27 23:59:38 +00:00
TestDisplay testDisplay = null!;
Box background = null!;
AddStep("add display", () =>
2022-08-27 17:12:45 +00:00
{
2022-08-27 23:59:38 +00:00
Add(testDisplay = new TestDisplay
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
var boxes = testDisplay.ChildrenOfType<Box>();
background = boxes.First();
2022-08-27 17:12:45 +00:00
});
2022-08-27 23:59:38 +00:00
2022-08-29 19:48:45 +00:00
AddStep("set value to default", () => testDisplay.Current.Value = 50);
2022-08-27 23:59:38 +00:00
AddUntilStep("colours are correct", () => testDisplay.Container.Colour == Color4.White && background.Colour == colourProvider.Background3);
2022-08-29 19:48:45 +00:00
AddStep("set value to less", () => testDisplay.Current.Value = 40);
2022-08-27 23:59:38 +00:00
AddUntilStep("colours are correct", () => testDisplay.Container.Colour == colourProvider.Background5 && background.Colour == colours.ForModType(ModType.DifficultyReduction));
2022-08-29 19:48:45 +00:00
AddStep("set value to bigger", () => testDisplay.Current.Value = 60);
2022-08-27 23:59:38 +00:00
AddUntilStep("colours are correct", () => testDisplay.Container.Colour == colourProvider.Background5 && background.Colour == colours.ForModType(ModType.DifficultyIncrease));
2022-08-27 17:12:45 +00:00
}
private partial class TestDisplay : ModCounterDisplay
2022-08-27 17:12:45 +00:00
{
2022-08-27 23:59:38 +00:00
public Container<Drawable> Container => Content;
2022-08-27 17:12:45 +00:00
protected override LocalisableString Label => "Test display";
public TestDisplay()
{
2022-09-10 20:18:59 +00:00
Current.Default = 50;
2022-08-29 19:48:45 +00:00
}
2022-08-27 17:12:45 +00:00
}
}
}