1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-06 02:46:08 +08:00

Update ready button test scene with new logic

This commit is contained in:
Salman Ahmed 2021-01-16 23:04:28 +03:00
parent 59ae50b0e5
commit 63c0dc9bd9

View File

@ -6,6 +6,7 @@ using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Testing; using osu.Framework.Testing;
@ -26,8 +27,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
public class TestSceneMultiplayerReadyButton : MultiplayerTestScene public class TestSceneMultiplayerReadyButton : MultiplayerTestScene
{ {
private MultiplayerReadyButton button; private MultiplayerReadyButton button;
private MultiplayerBeatmapTracker beatmapTracker;
private BeatmapSetInfo importedSet; private BeatmapSetInfo importedSet;
private readonly Bindable<PlaylistItem> selectedItem = new Bindable<PlaylistItem>();
private BeatmapManager beatmaps; private BeatmapManager beatmaps;
private RulesetStore rulesets; private RulesetStore rulesets;
@ -39,6 +43,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory)); Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default)); Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
beatmaps.Import(TestResources.GetTestBeatmapForImport(true)).Wait(); beatmaps.Import(TestResources.GetTestBeatmapForImport(true)).Wait();
Add(beatmapTracker = new MultiplayerBeatmapTracker
{
SelectedItem = { BindTarget = selectedItem }
});
Dependencies.Cache(beatmapTracker);
} }
[SetUp] [SetUp]
@ -46,20 +57,20 @@ namespace osu.Game.Tests.Visual.Multiplayer
{ {
importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First(); importedSet = beatmaps.GetAllUsableBeatmapSetsEnumerable(IncludedDetails.All).First();
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First()); Beatmap.Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First());
selectedItem.Value = new PlaylistItem
{
Beatmap = { Value = Beatmap.Value.BeatmapInfo },
Ruleset = { Value = Beatmap.Value.BeatmapInfo.Ruleset },
};
Child = button = new MultiplayerReadyButton if (button != null)
Remove(button);
Add(button = new MultiplayerReadyButton
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(200, 50), Size = new Vector2(200, 50),
SelectedItem =
{
Value = new PlaylistItem
{
Beatmap = { Value = Beatmap.Value.BeatmapInfo },
Ruleset = { Value = Beatmap.Value.BeatmapInfo.Ruleset }
}
},
OnReadyClick = async () => OnReadyClick = async () =>
{ {
readyClickOperation = OngoingOperationTracker.BeginOperation(); readyClickOperation = OngoingOperationTracker.BeginOperation();
@ -73,7 +84,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
await Client.ToggleReady(); await Client.ToggleReady();
readyClickOperation.Dispose(); readyClickOperation.Dispose();
} }
}; });
}); });
[Test] [Test]