// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; using osu.Framework.Platform; using osu.Framework.Screens; using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; using osu.Game.Screens.Multi; using osu.Game.Screens.Multi.Match; using osu.Game.Screens.Multi.Match.Components; using osu.Game.Tests.Beatmaps; using osu.Game.Users; using osuTK.Input; namespace osu.Game.Tests.Visual.Multiplayer { public class TestSceneMatchSubScreen : MultiplayerTestScene { protected override bool UseOnlineAPI => true; [Cached(typeof(IRoomManager))] private readonly TestRoomManager roomManager = new TestRoomManager(); private BeatmapManager manager; private RulesetStore rulesets; private TestMatchSubScreen match; [BackgroundDependencyLoader] private void load(GameHost host, AudioManager audio) { Dependencies.Cache(rulesets = new RulesetStore(ContextFactory)); Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default)); manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait(); } [SetUp] public void Setup() => Schedule(() => { Room = new Room(); }); [SetUpSteps] public void SetupSteps() { AddStep("load match", () => LoadScreen(match = new TestMatchSubScreen(Room))); AddUntilStep("wait for load", () => match.IsCurrentScreen()); } [Test] public void TestLoadSimpleMatch() { AddStep("set room properties", () => { Room.RoomID.Value = 1; Room.Name.Value = "my awesome room"; Room.Host.Value = new User { Id = 2, Username = "peppy" }; Room.RecentParticipants.Add(Room.Host.Value); Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo }, Ruleset = { Value = new OsuRuleset().RulesetInfo } }); }); } [Test] public void TestPlaylistItemSelectedOnCreate() { AddStep("set room properties", () => { Room.Name.Value = "my awesome room"; Room.Host.Value = new User { Id = 2, Username = "peppy" }; Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo }, Ruleset = { Value = new OsuRuleset().RulesetInfo } }); }); AddStep("move mouse to create button", () => { var footer = match.ChildrenOfType