2020-02-14 19:03:37 +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.
|
|
|
|
|
|
|
|
using System;
|
2020-02-14 22:39:39 +08:00
|
|
|
using System.Linq;
|
2020-02-14 19:03:37 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2020-06-02 16:02:01 +08:00
|
|
|
using osu.Framework.Audio;
|
2020-02-14 19:03:37 +08:00
|
|
|
using osu.Framework.Bindables;
|
2020-06-02 16:02:01 +08:00
|
|
|
using osu.Framework.Platform;
|
2020-02-14 22:39:39 +08:00
|
|
|
using osu.Framework.Screens;
|
|
|
|
using osu.Framework.Testing;
|
2020-02-14 19:03:37 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
2020-02-14 19:03:37 +08:00
|
|
|
using osu.Game.Rulesets;
|
2020-02-14 22:39:39 +08:00
|
|
|
using osu.Game.Rulesets.Osu;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Playlists;
|
2021-05-14 14:02:36 +08:00
|
|
|
using osu.Game.Screens.Play;
|
2020-02-14 22:39:39 +08:00
|
|
|
using osu.Game.Tests.Beatmaps;
|
2021-06-24 16:01:28 +08:00
|
|
|
using osu.Game.Tests.Visual.OnlinePlay;
|
2020-02-14 22:39:39 +08:00
|
|
|
using osuTK.Input;
|
2020-02-14 19:03:37 +08:00
|
|
|
|
2020-12-25 12:20:37 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Playlists
|
2020-02-14 19:03:37 +08:00
|
|
|
{
|
2021-06-25 12:02:19 +08:00
|
|
|
public class TestScenePlaylistsRoomSubScreen : OnlinePlayTestScene
|
2020-02-14 19:03:37 +08:00
|
|
|
{
|
2020-06-02 16:02:01 +08:00
|
|
|
private BeatmapManager manager;
|
|
|
|
private RulesetStore rulesets;
|
2020-02-14 19:03:37 +08:00
|
|
|
|
2020-12-25 12:11:21 +08:00
|
|
|
private TestPlaylistsRoomSubScreen match;
|
2020-02-14 22:39:39 +08:00
|
|
|
|
2020-06-02 16:02:01 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(GameHost host, AudioManager audio)
|
|
|
|
{
|
|
|
|
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
2021-05-31 17:37:32 +08:00
|
|
|
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default));
|
2020-06-02 16:02:01 +08:00
|
|
|
}
|
|
|
|
|
2020-02-14 22:39:39 +08:00
|
|
|
[SetUpSteps]
|
|
|
|
public void SetupSteps()
|
2020-02-14 19:03:37 +08:00
|
|
|
{
|
2021-06-24 18:09:31 +08:00
|
|
|
AddStep("set room", () => SelectedRoom.Value = new Room());
|
2021-06-24 12:29:06 +08:00
|
|
|
AddStep("ensure has beatmap", () => manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait());
|
2021-06-24 18:09:31 +08:00
|
|
|
AddStep("load match", () => LoadScreen(match = new TestPlaylistsRoomSubScreen(SelectedRoom.Value)));
|
2020-02-14 22:39:39 +08:00
|
|
|
AddUntilStep("wait for load", () => match.IsCurrentScreen());
|
2020-02-14 19:03:37 +08:00
|
|
|
}
|
|
|
|
|
2020-06-25 17:59:14 +08:00
|
|
|
[Test]
|
|
|
|
public void TestLoadSimpleMatch()
|
|
|
|
{
|
|
|
|
AddStep("set room properties", () =>
|
|
|
|
{
|
2021-06-24 18:09:31 +08:00
|
|
|
SelectedRoom.Value.RoomID.Value = 1;
|
|
|
|
SelectedRoom.Value.Name.Value = "my awesome room";
|
2021-08-18 15:35:18 +08:00
|
|
|
SelectedRoom.Value.Host.Value = API.LocalUser.Value;
|
2021-06-24 18:09:31 +08:00
|
|
|
SelectedRoom.Value.RecentParticipants.Add(SelectedRoom.Value.Host.Value);
|
|
|
|
SelectedRoom.Value.EndDate.Value = DateTimeOffset.Now.AddMinutes(5);
|
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
2020-06-25 17:59:14 +08:00
|
|
|
{
|
|
|
|
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
|
|
|
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
|
|
|
});
|
|
|
|
});
|
2021-05-14 14:02:36 +08:00
|
|
|
|
2021-08-04 16:27:44 +08:00
|
|
|
AddStep("start match", () => match.ChildrenOfType<PlaylistsReadyButton>().First().TriggerClick());
|
2021-05-14 14:02:36 +08:00
|
|
|
AddUntilStep("player loader loaded", () => Stack.CurrentScreen is PlayerLoader);
|
2020-06-25 17:59:14 +08:00
|
|
|
}
|
|
|
|
|
2020-02-14 19:03:37 +08:00
|
|
|
[Test]
|
2020-02-14 22:39:39 +08:00
|
|
|
public void TestPlaylistItemSelectedOnCreate()
|
2020-02-14 19:03:37 +08:00
|
|
|
{
|
2020-02-14 22:39:39 +08:00
|
|
|
AddStep("set room properties", () =>
|
2020-02-14 19:03:37 +08:00
|
|
|
{
|
2021-06-24 18:09:31 +08:00
|
|
|
SelectedRoom.Value.Name.Value = "my awesome room";
|
2021-08-18 15:35:18 +08:00
|
|
|
SelectedRoom.Value.Host.Value = API.LocalUser.Value;
|
2021-06-24 18:09:31 +08:00
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
2020-02-14 19:03:37 +08:00
|
|
|
{
|
2020-02-14 22:39:39 +08:00
|
|
|
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
|
|
|
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
2020-02-14 19:03:37 +08:00
|
|
|
});
|
2020-02-14 22:39:39 +08:00
|
|
|
});
|
2020-02-14 19:03:37 +08:00
|
|
|
|
2020-02-14 22:39:39 +08:00
|
|
|
AddStep("move mouse to create button", () =>
|
|
|
|
{
|
2021-08-17 16:14:21 +08:00
|
|
|
InputManager.MoveMouseTo(this.ChildrenOfType<PlaylistsRoomSettingsOverlay.CreateRoomButton>().Single());
|
2020-02-14 19:03:37 +08:00
|
|
|
});
|
2020-02-14 22:39:39 +08:00
|
|
|
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
2021-06-24 18:09:31 +08:00
|
|
|
AddAssert("first playlist item selected", () => match.SelectedItem.Value == SelectedRoom.Value.Playlist[0]);
|
2020-02-14 19:03:37 +08:00
|
|
|
}
|
|
|
|
|
2020-06-02 16:02:01 +08:00
|
|
|
[Test]
|
|
|
|
public void TestBeatmapUpdatedOnReImport()
|
|
|
|
{
|
|
|
|
BeatmapSetInfo importedSet = null;
|
2021-06-23 18:30:08 +08:00
|
|
|
TestBeatmap beatmap = null;
|
|
|
|
|
|
|
|
// this step is required to make sure the further imports actually get online IDs.
|
|
|
|
// all the playlist logic relies on online ID matching.
|
|
|
|
AddStep("remove all matching online IDs", () =>
|
|
|
|
{
|
|
|
|
beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo);
|
|
|
|
|
|
|
|
var existing = manager.QueryBeatmapSets(s => s.OnlineBeatmapSetID == beatmap.BeatmapInfo.BeatmapSet.OnlineBeatmapSetID).ToList();
|
|
|
|
|
|
|
|
foreach (var s in existing)
|
|
|
|
{
|
|
|
|
s.OnlineBeatmapSetID = null;
|
|
|
|
foreach (var b in s.Beatmaps)
|
|
|
|
b.OnlineBeatmapID = null;
|
|
|
|
manager.Update(s);
|
|
|
|
}
|
|
|
|
});
|
2020-06-02 16:02:01 +08:00
|
|
|
|
|
|
|
AddStep("import altered beatmap", () =>
|
|
|
|
{
|
|
|
|
beatmap.BeatmapInfo.BaseDifficulty.CircleSize = 1;
|
|
|
|
|
2021-09-30 18:33:12 +08:00
|
|
|
importedSet = manager.Import(beatmap.BeatmapInfo.BeatmapSet).Result.Value;
|
2020-06-02 16:02:01 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("load room", () =>
|
|
|
|
{
|
2021-06-24 18:09:31 +08:00
|
|
|
SelectedRoom.Value.Name.Value = "my awesome room";
|
2021-08-18 15:35:18 +08:00
|
|
|
SelectedRoom.Value.Host.Value = API.LocalUser.Value;
|
2021-06-24 18:09:31 +08:00
|
|
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
2020-06-02 16:02:01 +08:00
|
|
|
{
|
|
|
|
Beatmap = { Value = importedSet.Beatmaps[0] },
|
|
|
|
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("create room", () =>
|
|
|
|
{
|
2021-08-17 16:14:21 +08:00
|
|
|
InputManager.MoveMouseTo(match.ChildrenOfType<PlaylistsRoomSettingsOverlay.CreateRoomButton>().Single());
|
2020-06-02 16:02:01 +08:00
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
2021-10-02 11:34:29 +08:00
|
|
|
AddAssert("match has altered beatmap", () => match.Beatmap.Value.Beatmap.Difficulty.CircleSize == 1);
|
2020-06-02 16:02:01 +08:00
|
|
|
|
|
|
|
AddStep("re-import original beatmap", () => manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait());
|
|
|
|
|
2021-10-02 11:34:29 +08:00
|
|
|
AddAssert("match has original beatmap", () => match.Beatmap.Value.Beatmap.Difficulty.CircleSize != 1);
|
2020-06-02 16:02:01 +08:00
|
|
|
}
|
|
|
|
|
2020-12-25 12:11:21 +08:00
|
|
|
private class TestPlaylistsRoomSubScreen : PlaylistsRoomSubScreen
|
2020-02-14 19:03:37 +08:00
|
|
|
{
|
2020-02-14 22:39:39 +08:00
|
|
|
public new Bindable<PlaylistItem> SelectedItem => base.SelectedItem;
|
|
|
|
|
2020-06-02 16:02:01 +08:00
|
|
|
public new Bindable<WorkingBeatmap> Beatmap => base.Beatmap;
|
|
|
|
|
2020-12-25 12:11:21 +08:00
|
|
|
public TestPlaylistsRoomSubScreen(Room room)
|
2020-02-14 22:39:39 +08:00
|
|
|
: base(room)
|
2020-02-14 19:03:37 +08:00
|
|
|
{
|
2020-02-14 22:39:39 +08:00
|
|
|
}
|
2020-02-14 19:03:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|