2020-02-14 11:03:37 +00: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 14:39:39 +00:00
|
|
|
using System.Linq;
|
2020-02-14 11:03:37 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
2020-02-14 14:39:39 +00:00
|
|
|
using osu.Framework.Screens;
|
|
|
|
using osu.Framework.Testing;
|
2020-02-14 11:03:37 +00:00
|
|
|
using osu.Game.Beatmaps;
|
2020-02-14 14:39:39 +00:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2020-02-14 11:03:37 +00:00
|
|
|
using osu.Game.Online.Multiplayer;
|
|
|
|
using osu.Game.Rulesets;
|
2020-02-14 14:39:39 +00:00
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
using osu.Game.Screens.Multi;
|
2020-02-14 11:03:37 +00:00
|
|
|
using osu.Game.Screens.Multi.Match;
|
|
|
|
using osu.Game.Screens.Multi.Match.Components;
|
2020-02-14 14:39:39 +00:00
|
|
|
using osu.Game.Tests.Beatmaps;
|
2020-02-14 11:03:37 +00:00
|
|
|
using osu.Game.Users;
|
2020-02-14 14:39:39 +00:00
|
|
|
using osuTK.Input;
|
2020-02-14 11:03:37 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
|
|
|
{
|
2020-02-14 14:39:39 +00:00
|
|
|
public class TestSceneMatchSubScreen : MultiplayerTestScene
|
2020-02-14 11:03:37 +00:00
|
|
|
{
|
|
|
|
protected override bool UseOnlineAPI => true;
|
|
|
|
|
2020-02-14 14:39:39 +00:00
|
|
|
[Cached(typeof(IRoomManager))]
|
|
|
|
private readonly TestRoomManager roomManager = new TestRoomManager();
|
2020-02-14 11:03:37 +00:00
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmaps { get; set; }
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private RulesetStore rulesets { get; set; }
|
|
|
|
|
2020-02-14 14:39:39 +00:00
|
|
|
private TestMatchSubScreen match;
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup() => Schedule(() =>
|
|
|
|
{
|
|
|
|
Room.CopyFrom(new Room());
|
|
|
|
});
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
public void SetupSteps()
|
2020-02-14 11:03:37 +00:00
|
|
|
{
|
2020-02-14 14:39:39 +00:00
|
|
|
AddStep("load match", () => LoadScreen(match = new TestMatchSubScreen(Room)));
|
|
|
|
AddUntilStep("wait for load", () => match.IsCurrentScreen());
|
2020-02-14 11:03:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2020-02-14 14:39:39 +00:00
|
|
|
public void TestPlaylistItemSelectedOnCreate()
|
2020-02-14 11:03:37 +00:00
|
|
|
{
|
2020-02-14 14:39:39 +00:00
|
|
|
AddStep("set room properties", () =>
|
2020-02-14 11:03:37 +00:00
|
|
|
{
|
2020-02-14 14:39:39 +00:00
|
|
|
Room.Name.Value = "my awesome room";
|
|
|
|
Room.Host.Value = new User { Id = 2, Username = "peppy" };
|
|
|
|
Room.Playlist.Add(new PlaylistItem
|
2020-02-14 11:03:37 +00:00
|
|
|
{
|
2020-02-14 14:39:39 +00:00
|
|
|
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
|
|
|
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
2020-02-14 11:03:37 +00:00
|
|
|
});
|
2020-02-14 14:39:39 +00:00
|
|
|
});
|
2020-02-14 11:03:37 +00:00
|
|
|
|
2020-02-14 14:39:39 +00:00
|
|
|
AddStep("move mouse to create button", () =>
|
|
|
|
{
|
|
|
|
var footer = match.ChildrenOfType<Footer>().Single();
|
|
|
|
InputManager.MoveMouseTo(footer.ChildrenOfType<OsuButton>().Single());
|
2020-02-14 11:03:37 +00:00
|
|
|
});
|
2020-02-14 14:39:39 +00:00
|
|
|
|
|
|
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
|
|
|
|
AddAssert("first playlist item selected", () => match.SelectedItem.Value == Room.Playlist[0]);
|
2020-02-14 11:03:37 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 14:39:39 +00:00
|
|
|
private class TestMatchSubScreen : MatchSubScreen
|
2020-02-14 11:03:37 +00:00
|
|
|
{
|
2020-02-14 14:39:39 +00:00
|
|
|
public new Bindable<PlaylistItem> SelectedItem => base.SelectedItem;
|
|
|
|
|
|
|
|
public TestMatchSubScreen(Room room)
|
|
|
|
: base(room)
|
2020-02-14 11:03:37 +00:00
|
|
|
{
|
2020-02-14 14:39:39 +00:00
|
|
|
}
|
2020-02-14 11:03:37 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 14:39:39 +00:00
|
|
|
private class TestRoomManager : IRoomManager
|
2020-02-14 11:03:37 +00:00
|
|
|
{
|
2020-02-14 14:39:39 +00:00
|
|
|
public event Action RoomsUpdated
|
|
|
|
{
|
|
|
|
add => throw new NotImplementedException();
|
|
|
|
remove => throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IBindableList<Room> Rooms { get; } = new BindableList<Room>();
|
|
|
|
|
|
|
|
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
|
|
|
{
|
|
|
|
room.RoomID.Value = 1;
|
|
|
|
onSuccess?.Invoke(room);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) => onSuccess?.Invoke(room);
|
|
|
|
|
|
|
|
public void PartRoom()
|
|
|
|
{
|
|
|
|
}
|
2020-02-14 11:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|