2019-06-10 08:35:00 +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.
|
|
|
|
|
|
2019-06-25 19:27:29 +08:00
|
|
|
|
#nullable disable
|
2022-06-17 15:37:17 +08:00
|
|
|
|
|
2019-06-10 08:35:00 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Overlays.Toolbar;
|
|
|
|
|
using osu.Framework.Graphics;
|
2019-06-10 08:54:15 +08:00
|
|
|
|
using System.Linq;
|
2019-06-27 17:25:38 +08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
2020-01-09 12:43:44 +08:00
|
|
|
|
using osu.Framework.Utils;
|
2019-06-27 17:25:38 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
2019-06-10 08:35:00 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
{
|
|
|
|
|
public class TestSceneToolbarRulesetSelector : OsuTestScene
|
|
|
|
|
{
|
2019-06-27 17:25:38 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private RulesetStore rulesets { get; set; }
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDisplay()
|
2019-06-10 08:35:00 +08:00
|
|
|
|
{
|
2019-06-27 17:25:38 +08:00
|
|
|
|
ToolbarRulesetSelector selector = null;
|
2019-06-10 08:35:00 +08:00
|
|
|
|
|
2019-06-27 17:25:38 +08:00
|
|
|
|
AddStep("create selector", () =>
|
2019-06-10 08:35:00 +08:00
|
|
|
|
{
|
2019-06-27 17:25:38 +08:00
|
|
|
|
Child = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Height = Toolbar.HEIGHT,
|
|
|
|
|
Child = selector = new ToolbarRulesetSelector()
|
|
|
|
|
};
|
2019-06-10 08:54:15 +08:00
|
|
|
|
});
|
2019-06-10 08:35:00 +08:00
|
|
|
|
|
2019-06-10 08:54:15 +08:00
|
|
|
|
AddStep("Select random", () =>
|
|
|
|
|
{
|
2020-01-18 14:27:21 +08:00
|
|
|
|
selector.Current.Value = selector.Items.ElementAt(RNG.Next(selector.Items.Count));
|
2019-06-10 08:35:00 +08:00
|
|
|
|
});
|
2019-06-25 19:27:29 +08:00
|
|
|
|
AddStep("Toggle disabled state", () => selector.Current.Disabled = !selector.Current.Disabled);
|
2019-06-10 08:35:00 +08:00
|
|
|
|
}
|
2019-06-27 17:25:38 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestNonFirstRulesetInitialState()
|
|
|
|
|
{
|
|
|
|
|
TestSelector selector = null;
|
|
|
|
|
|
|
|
|
|
AddStep("create selector", () =>
|
|
|
|
|
{
|
|
|
|
|
Child = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Height = Toolbar.HEIGHT,
|
|
|
|
|
Child = selector = new TestSelector()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
selector.Current.Value = rulesets.GetRuleset(2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddAssert("mode line has moved", () => selector.ModeButtonLine.DrawPosition.X > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestSelector : ToolbarRulesetSelector
|
|
|
|
|
{
|
|
|
|
|
public new Drawable ModeButtonLine => base.ModeButtonLine;
|
|
|
|
|
}
|
2019-06-10 08:35:00 +08:00
|
|
|
|
}
|
|
|
|
|
}
|