1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 04:32:53 +08:00
osu-lazer/osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs

77 lines
2.4 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
2018-04-13 17:19:50 +08:00
using osu.Game.Overlays.Toolbar;
using osu.Game.Rulesets;
using osuTK.Input;
2018-04-13 17:19:50 +08:00
2019-03-25 00:02:36 +08:00
namespace osu.Game.Tests.Visual.Menus
2018-04-13 17:19:50 +08:00
{
[TestFixture]
public class TestSceneToolbar : OsuManualInputManagerTestScene
2018-04-13 17:19:50 +08:00
{
private Toolbar toolbar;
[Resolved]
private RulesetStore rulesets { get; set; }
[SetUp]
public void SetUp() => Schedule(() =>
2018-04-13 17:19:50 +08:00
{
Child = toolbar = new Toolbar { State = { Value = Visibility.Visible } };
});
2018-04-13 17:19:50 +08:00
[Test]
public void TestNotificationCounter()
{
ToolbarNotificationButton notificationButton = null;
2018-04-13 17:19:50 +08:00
AddStep("retrieve notification button", () => notificationButton = toolbar.ChildrenOfType<ToolbarNotificationButton>().Single());
2018-04-13 17:19:50 +08:00
setNotifications(1);
setNotifications(2);
setNotifications(3);
setNotifications(0);
setNotifications(144);
void setNotifications(int count)
=> AddStep($"set notification count to {count}",
() => notificationButton.NotificationCount.Value = count);
}
[TestCase(false)]
[TestCase(true)]
public void TestRulesetSwitchingShortcut(bool toolbarHidden)
{
ToolbarRulesetSelector rulesetSelector = null;
if (toolbarHidden)
AddStep("hide toolbar", () => toolbar.Hide());
AddStep("retrieve ruleset selector", () => rulesetSelector = toolbar.ChildrenOfType<ToolbarRulesetSelector>().Single());
for (int i = 0; i < 4; i++)
{
var expected = rulesets.AvailableRulesets.ElementAt(i);
var numberKey = Key.Number1 + i;
AddStep($"switch to ruleset {i} via shortcut", () =>
{
InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(numberKey);
InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(numberKey);
});
AddUntilStep("ruleset switched", () => rulesetSelector.Current.Value.Equals(expected));
}
2018-04-13 17:19:50 +08:00
}
}
}