1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 00:02:54 +08:00
osu-lazer/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-28 01:12:45 +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.
2022-08-28 07:59:38 +08:00
using System.Linq;
2022-08-28 01:12:45 +08:00
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
2022-08-28 07:59:38 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2022-08-28 01:12:45 +08:00
using osu.Framework.Localisation;
2022-08-28 07:59:38 +08:00
using osu.Framework.Testing;
2022-08-28 01:12:45 +08:00
using osu.Game.Graphics;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
2022-08-28 07:59:38 +08:00
using osu.Game.Rulesets.Mods;
using osuTK.Graphics;
2022-08-28 01:12:45 +08:00
namespace osu.Game.Tests.Visual.UserInterface
{
2022-08-28 07:59:38 +08:00
[TestFixture]
2022-08-28 01:12:45 +08:00
public class TestSceneModsEffectDisplay : OsuTestScene
{
[Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
2022-08-28 07:59:38 +08:00
[Resolved]
private OsuColour colours { get; set; } = null!;
2022-08-28 01:12:45 +08:00
[Test]
2022-08-28 07:59:38 +08:00
public void TestModsEffectDisplay()
2022-08-28 01:12:45 +08:00
{
2022-08-28 07:59:38 +08:00
TestDisplay testDisplay = null!;
Box background = null!;
AddStep("add display", () =>
2022-08-28 01:12:45 +08:00
{
2022-08-28 07:59:38 +08:00
Add(testDisplay = new TestDisplay
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
var boxes = testDisplay.ChildrenOfType<Box>();
background = boxes.First();
2022-08-28 01:12:45 +08:00
});
2022-08-28 07:59:38 +08:00
2022-08-30 03:48:45 +08:00
AddStep("set value to default", () => testDisplay.Current.Value = 50);
2022-08-28 07:59:38 +08:00
AddUntilStep("colours are correct", () => testDisplay.Container.Colour == Color4.White && background.Colour == colourProvider.Background3);
2022-08-30 03:48:45 +08:00
AddStep("set value to less", () => testDisplay.Current.Value = 40);
2022-08-28 07:59:38 +08:00
AddUntilStep("colours are correct", () => testDisplay.Container.Colour == colourProvider.Background5 && background.Colour == colours.ForModType(ModType.DifficultyReduction));
2022-08-30 03:48:45 +08:00
AddStep("set value to bigger", () => testDisplay.Current.Value = 60);
2022-08-28 07:59:38 +08:00
AddUntilStep("colours are correct", () => testDisplay.Container.Colour == colourProvider.Background5 && background.Colour == colours.ForModType(ModType.DifficultyIncrease));
2022-08-28 01:12:45 +08:00
}
2022-09-11 04:18:59 +08:00
private class TestDisplay : ModsEffectDisplay
2022-08-28 01:12:45 +08:00
{
2022-08-28 07:59:38 +08:00
public Container<Drawable> Container => Content;
2022-08-28 01:12:45 +08:00
protected override LocalisableString Label => "Test display";
public TestDisplay()
{
2022-09-11 04:18:59 +08:00
Current.Default = 50;
2022-08-30 03:48:45 +08:00
}
2022-08-28 01:12:45 +08:00
}
}
}