From 1e80facfe8e67c03d83c3a0ca7c78e152097f3aa Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 14 Feb 2020 20:03:37 +0900 Subject: [PATCH] Add subscreen test scene --- .../Multiplayer/TestSceneMatchSubScreen.cs | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSubScreen.cs diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSubScreen.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSubScreen.cs new file mode 100644 index 0000000000..76d950b847 --- /dev/null +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSubScreen.cs @@ -0,0 +1,87 @@ +// 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.Collections.Generic; +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Game.Beatmaps; +using osu.Game.Online.Multiplayer; +using osu.Game.Rulesets; +using osu.Game.Screens.Multi.Match; +using osu.Game.Screens.Multi.Match.Components; +using osu.Game.Screens.Select; +using osu.Game.Users; + +namespace osu.Game.Tests.Visual.Multiplayer +{ + public class TestSceneMatchSubScreen : ScreenTestScene + { + protected override bool UseOnlineAPI => true; + + public override IReadOnlyList RequiredTypes => new[] + { + typeof(Screens.Multi.Multiplayer), + typeof(MatchSubScreen), + typeof(Header), + typeof(Footer) + }; + + [Cached] + private readonly Bindable currentRoom = new Bindable(); + + [Resolved] + private BeatmapManager beatmaps { get; set; } + + [Resolved] + private RulesetStore rulesets { get; set; } + + public TestSceneMatchSubScreen() + { + currentRoom.Value = new Room(); + } + + [Test] + public void TestShowRoom() + { + AddStep(@"show", () => + { + currentRoom.Value.RoomID.Value = 1; + currentRoom.Value.Availability.Value = RoomAvailability.Public; + currentRoom.Value.Duration.Value = TimeSpan.FromHours(24); + currentRoom.Value.Host.Value = new User { Username = "peppy", Id = 2 }; + currentRoom.Value.Name.Value = "super secret room"; + currentRoom.Value.Participants.AddRange(new[] + { + new User { Username = "peppy", Id = 2 }, + new User { Username = "smoogipoo", Id = 1040328 } + }); + currentRoom.Value.Playlist.Add(new PlaylistItem + { + Beatmap = { Value = beatmaps.GetAllUsableBeatmapSets()[0].Beatmaps[0] }, + Ruleset = { Value = rulesets.GetRuleset(2) }, + }); + + LoadScreen(new MatchSubScreen(currentRoom.Value)); + }); + } + + [Test] + public void TestShowSettings() + { + AddStep(@"show", () => + { + currentRoom.Value.RoomID.Value = null; + LoadScreen(new MatchSubScreen(currentRoom.Value)); + }); + } + + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) + { + var dependencies = new CachedModelDependencyContainer(base.CreateChildDependencies(parent)); + dependencies.Model.BindTo(currentRoom); + return dependencies; + } + } +}