mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge branch 'master' of https://github.com/ppy/osu into present-recommended
Conflicts: osu.Game/Screens/Select/SongSelect.cs
This commit is contained in:
@ -5,13 +5,17 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Overlays.Toolbar;
|
||||
using osu.Game.Rulesets;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneToolbar : OsuTestScene
|
||||
public class TestSceneToolbar : OsuManualInputManagerTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
@ -21,24 +25,62 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
typeof(ToolbarNotificationButton),
|
||||
};
|
||||
|
||||
public TestSceneToolbar()
|
||||
private Toolbar toolbar;
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
Child = toolbar = new Toolbar { State = { Value = Visibility.Visible } };
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestNotificationCounter()
|
||||
{
|
||||
var toolbar = new Toolbar { State = { Value = Visibility.Visible } };
|
||||
ToolbarNotificationButton notificationButton = null;
|
||||
|
||||
AddStep("create toolbar", () =>
|
||||
{
|
||||
Add(toolbar);
|
||||
notificationButton = toolbar.Children.OfType<FillFlowContainer>().Last().Children.OfType<ToolbarNotificationButton>().First();
|
||||
});
|
||||
|
||||
void setNotifications(int count) => AddStep($"set notification count to {count}", () => notificationButton.NotificationCount.Value = count);
|
||||
AddStep("retrieve notification button", () => notificationButton = toolbar.ChildrenOfType<ToolbarNotificationButton>().Single());
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Ranking.Expanded;
|
||||
using osu.Game.Screens.Ranking.Expanded.Accuracy;
|
||||
using osu.Game.Screens.Ranking.Expanded.Statistics;
|
||||
@ -74,6 +75,8 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
var beatmap = new TestBeatmap(rulesetStore.GetRuleset(0));
|
||||
beatmap.Metadata.Author = author;
|
||||
beatmap.Metadata.Title = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap title";
|
||||
beatmap.Metadata.Artist = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap artist";
|
||||
|
||||
return new TestWorkingBeatmap(beatmap);
|
||||
}
|
||||
@ -114,7 +117,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
Size = new Vector2(500, 700);
|
||||
Size = new Vector2(ScorePanel.EXPANDED_WIDTH, 700);
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
|
@ -797,6 +797,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
{
|
||||
AddStep("create song select", () => LoadScreen(songSelect = new TestSongSelect()));
|
||||
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen());
|
||||
AddUntilStep("wait for carousel loaded", () => songSelect.Carousel.IsAlive);
|
||||
}
|
||||
|
||||
private void addManyTestMaps()
|
||||
|
@ -14,8 +14,6 @@ using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Overlays.Mods.Sections;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Mania.Mods;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
@ -117,8 +115,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
public void TestManiaMods()
|
||||
{
|
||||
changeRuleset(3);
|
||||
|
||||
testRankedText(new ManiaRuleset().GetModsFor(ModType.Conversion).First(m => m is ManiaModRandom));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -217,15 +213,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
checkLabelColor(() => Color4.White);
|
||||
}
|
||||
|
||||
private void testRankedText(Mod mod)
|
||||
{
|
||||
AddUntilStep("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0);
|
||||
selectNext(mod);
|
||||
AddUntilStep("check for unranked", () => modSelect.UnrankedLabel.Alpha != 0);
|
||||
selectPrevious(mod);
|
||||
AddUntilStep("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0);
|
||||
}
|
||||
|
||||
private void selectNext(Mod mod) => AddStep($"left click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext(1));
|
||||
|
||||
private void selectPrevious(Mod mod) => AddStep($"right click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext(-1));
|
||||
@ -272,7 +259,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
}
|
||||
|
||||
public new OsuSpriteText MultiplierLabel => base.MultiplierLabel;
|
||||
public new OsuSpriteText UnrankedLabel => base.UnrankedLabel;
|
||||
public new TriangleButton DeselectAllButton => base.DeselectAllButton;
|
||||
|
||||
public new Color4 LowMultiplierColour => base.LowMultiplierColour;
|
||||
|
@ -1,12 +1,15 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
@ -21,9 +24,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private NowPlayingOverlay nowPlayingOverlay;
|
||||
|
||||
private RulesetStore rulesets;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(AudioManager audio, GameHost host)
|
||||
{
|
||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
|
||||
|
||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
|
||||
nowPlayingOverlay = new NowPlayingOverlay
|
||||
@ -44,21 +52,43 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddStep(@"hide", () => nowPlayingOverlay.Hide());
|
||||
}
|
||||
|
||||
private BeatmapManager manager { get; set; }
|
||||
|
||||
private int importId;
|
||||
|
||||
[Test]
|
||||
public void TestPrevTrackBehavior()
|
||||
{
|
||||
AddStep(@"Play track", () =>
|
||||
// ensure we have at least two beatmaps available.
|
||||
AddRepeatStep("import beatmap", () => manager.Import(new BeatmapSetInfo
|
||||
{
|
||||
musicController.NextTrack();
|
||||
currentBeatmap = Beatmap.Value;
|
||||
});
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
{
|
||||
new BeatmapInfo
|
||||
{
|
||||
BaseDifficulty = new BeatmapDifficulty(),
|
||||
}
|
||||
},
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Artist = $"a test map {importId++}",
|
||||
Title = "title",
|
||||
}
|
||||
}).Wait(), 5);
|
||||
|
||||
AddStep(@"Next track", () => musicController.NextTrack());
|
||||
AddStep("Store track", () => currentBeatmap = Beatmap.Value);
|
||||
|
||||
AddStep(@"Seek track to 6 second", () => musicController.SeekTo(6000));
|
||||
AddUntilStep(@"Wait for current time to update", () => currentBeatmap.Track.CurrentTime > 5000);
|
||||
AddAssert(@"Check action is restart track", () => musicController.PreviousTrack() == PreviousTrackResult.Restart);
|
||||
AddUntilStep("Wait for current time to update", () => Precision.AlmostEquals(currentBeatmap.Track.CurrentTime, 0));
|
||||
AddAssert(@"Check track didn't change", () => currentBeatmap == Beatmap.Value);
|
||||
AddAssert(@"Check action is not restart", () => musicController.PreviousTrack() != PreviousTrackResult.Restart);
|
||||
|
||||
AddStep(@"Set previous", () => musicController.PreviousTrack());
|
||||
|
||||
AddAssert(@"Check beatmap didn't change", () => currentBeatmap == Beatmap.Value);
|
||||
AddUntilStep("Wait for current time to update", () => currentBeatmap.Track.CurrentTime < 5000);
|
||||
|
||||
AddStep(@"Set previous", () => musicController.PreviousTrack());
|
||||
AddAssert(@"Check beatmap did change", () => currentBeatmap != Beatmap.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user