mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Merge branch 'master' into un-nest-overlined-display
This commit is contained in:
@ -19,24 +19,18 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class CustomDataDirectoryTest
|
public class CustomDataDirectoryTest
|
||||||
{
|
{
|
||||||
[SetUp]
|
|
||||||
public void SetUp()
|
|
||||||
{
|
|
||||||
if (Directory.Exists(customPath))
|
|
||||||
Directory.Delete(customPath, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDefaultDirectory()
|
public void TestDefaultDirectory()
|
||||||
{
|
{
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestDefaultDirectory)))
|
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestDefaultDirectory)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
string defaultStorageLocation = getDefaultLocationFor(nameof(TestDefaultDirectory));
|
||||||
|
|
||||||
var osu = loadOsu(host);
|
var osu = loadOsu(host);
|
||||||
var storage = osu.Dependencies.Get<Storage>();
|
var storage = osu.Dependencies.Get<Storage>();
|
||||||
|
|
||||||
string defaultStorageLocation = Path.Combine(RuntimeInfo.StartupDirectory, "headless", nameof(TestDefaultDirectory));
|
|
||||||
Assert.That(storage.GetFullPath("."), Is.EqualTo(defaultStorageLocation));
|
Assert.That(storage.GetFullPath("."), Is.EqualTo(defaultStorageLocation));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@ -46,21 +40,14 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string customPath => Path.Combine(RuntimeInfo.StartupDirectory, "custom-path");
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestCustomDirectory()
|
public void TestCustomDirectory()
|
||||||
{
|
{
|
||||||
using (var host = new HeadlessGameHost(nameof(TestCustomDirectory)))
|
string customPath = prepareCustomPath();
|
||||||
|
|
||||||
|
using (var host = new CustomTestHeadlessGameHost(nameof(TestCustomDirectory)))
|
||||||
{
|
{
|
||||||
string defaultStorageLocation = Path.Combine(RuntimeInfo.StartupDirectory, "headless", nameof(TestCustomDirectory));
|
using (var storageConfig = new StorageConfigManager(host.InitialStorage))
|
||||||
|
|
||||||
// need access before the game has constructed its own storage yet.
|
|
||||||
Storage storage = new DesktopStorage(defaultStorageLocation, host);
|
|
||||||
// manual cleaning so we can prepare a config file.
|
|
||||||
storage.DeleteDirectory(string.Empty);
|
|
||||||
|
|
||||||
using (var storageConfig = new StorageConfigManager(storage))
|
|
||||||
storageConfig.Set(StorageConfig.FullPath, customPath);
|
storageConfig.Set(StorageConfig.FullPath, customPath);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -68,7 +55,7 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
var osu = loadOsu(host);
|
var osu = loadOsu(host);
|
||||||
|
|
||||||
// switch to DI'd storage
|
// switch to DI'd storage
|
||||||
storage = osu.Dependencies.Get<Storage>();
|
var storage = osu.Dependencies.Get<Storage>();
|
||||||
|
|
||||||
Assert.That(storage.GetFullPath("."), Is.EqualTo(customPath));
|
Assert.That(storage.GetFullPath("."), Is.EqualTo(customPath));
|
||||||
}
|
}
|
||||||
@ -82,16 +69,11 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestSubDirectoryLookup()
|
public void TestSubDirectoryLookup()
|
||||||
{
|
{
|
||||||
using (var host = new HeadlessGameHost(nameof(TestSubDirectoryLookup)))
|
string customPath = prepareCustomPath();
|
||||||
|
|
||||||
|
using (var host = new CustomTestHeadlessGameHost(nameof(TestSubDirectoryLookup)))
|
||||||
{
|
{
|
||||||
string defaultStorageLocation = Path.Combine(RuntimeInfo.StartupDirectory, "headless", nameof(TestSubDirectoryLookup));
|
using (var storageConfig = new StorageConfigManager(host.InitialStorage))
|
||||||
|
|
||||||
// need access before the game has constructed its own storage yet.
|
|
||||||
Storage storage = new DesktopStorage(defaultStorageLocation, host);
|
|
||||||
// manual cleaning so we can prepare a config file.
|
|
||||||
storage.DeleteDirectory(string.Empty);
|
|
||||||
|
|
||||||
using (var storageConfig = new StorageConfigManager(storage))
|
|
||||||
storageConfig.Set(StorageConfig.FullPath, customPath);
|
storageConfig.Set(StorageConfig.FullPath, customPath);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -99,7 +81,7 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
var osu = loadOsu(host);
|
var osu = loadOsu(host);
|
||||||
|
|
||||||
// switch to DI'd storage
|
// switch to DI'd storage
|
||||||
storage = osu.Dependencies.Get<Storage>();
|
var storage = osu.Dependencies.Get<Storage>();
|
||||||
|
|
||||||
string actualTestFile = Path.Combine(customPath, "rulesets", "test");
|
string actualTestFile = Path.Combine(customPath, "rulesets", "test");
|
||||||
|
|
||||||
@ -120,10 +102,14 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestMigration()
|
public void TestMigration()
|
||||||
{
|
{
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestMigration)))
|
string customPath = prepareCustomPath();
|
||||||
|
|
||||||
|
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestMigration)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
string defaultStorageLocation = getDefaultLocationFor(nameof(TestMigration));
|
||||||
|
|
||||||
var osu = loadOsu(host);
|
var osu = loadOsu(host);
|
||||||
var storage = osu.Dependencies.Get<Storage>();
|
var storage = osu.Dependencies.Get<Storage>();
|
||||||
|
|
||||||
@ -139,8 +125,6 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
// for testing nested files are not ignored (only top level)
|
// for testing nested files are not ignored (only top level)
|
||||||
host.Storage.GetStorageForDirectory("test-nested").GetStorageForDirectory("cache");
|
host.Storage.GetStorageForDirectory("test-nested").GetStorageForDirectory("cache");
|
||||||
|
|
||||||
string defaultStorageLocation = Path.Combine(RuntimeInfo.StartupDirectory, "headless", nameof(TestMigration));
|
|
||||||
|
|
||||||
Assert.That(storage.GetFullPath("."), Is.EqualTo(defaultStorageLocation));
|
Assert.That(storage.GetFullPath("."), Is.EqualTo(defaultStorageLocation));
|
||||||
|
|
||||||
osu.Migrate(customPath);
|
osu.Migrate(customPath);
|
||||||
@ -178,14 +162,15 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestMigrationBetweenTwoTargets()
|
public void TestMigrationBetweenTwoTargets()
|
||||||
{
|
{
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestMigrationBetweenTwoTargets)))
|
string customPath = prepareCustomPath();
|
||||||
|
string customPath2 = prepareCustomPath("-2");
|
||||||
|
|
||||||
|
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestMigrationBetweenTwoTargets)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var osu = loadOsu(host);
|
var osu = loadOsu(host);
|
||||||
|
|
||||||
string customPath2 = $"{customPath}-2";
|
|
||||||
|
|
||||||
const string database_filename = "client.db";
|
const string database_filename = "client.db";
|
||||||
|
|
||||||
Assert.DoesNotThrow(() => osu.Migrate(customPath));
|
Assert.DoesNotThrow(() => osu.Migrate(customPath));
|
||||||
@ -207,7 +192,9 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestMigrationToSameTargetFails()
|
public void TestMigrationToSameTargetFails()
|
||||||
{
|
{
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestMigrationToSameTargetFails)))
|
string customPath = prepareCustomPath();
|
||||||
|
|
||||||
|
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestMigrationToSameTargetFails)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -226,7 +213,9 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestMigrationToNestedTargetFails()
|
public void TestMigrationToNestedTargetFails()
|
||||||
{
|
{
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestMigrationToNestedTargetFails)))
|
string customPath = prepareCustomPath();
|
||||||
|
|
||||||
|
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestMigrationToNestedTargetFails)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -253,7 +242,9 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestMigrationToSeeminglyNestedTarget()
|
public void TestMigrationToSeeminglyNestedTarget()
|
||||||
{
|
{
|
||||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestMigrationToSeeminglyNestedTarget)))
|
string customPath = prepareCustomPath();
|
||||||
|
|
||||||
|
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestMigrationToSeeminglyNestedTarget)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -282,6 +273,7 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
var osu = new OsuGameBase();
|
var osu = new OsuGameBase();
|
||||||
Task.Run(() => host.Run(osu));
|
Task.Run(() => host.Run(osu));
|
||||||
waitForOrAssert(() => osu.IsLoaded, @"osu! failed to start in a reasonable amount of time");
|
waitForOrAssert(() => osu.IsLoaded, @"osu! failed to start in a reasonable amount of time");
|
||||||
|
|
||||||
return osu;
|
return osu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,5 +286,39 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
|
|
||||||
Assert.IsTrue(task.Wait(timeout), failureMessage);
|
Assert.IsTrue(task.Wait(timeout), failureMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string getDefaultLocationFor(string testTypeName)
|
||||||
|
{
|
||||||
|
string path = Path.Combine(RuntimeInfo.StartupDirectory, "headless", testTypeName);
|
||||||
|
|
||||||
|
if (Directory.Exists(path))
|
||||||
|
Directory.Delete(path, true);
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string prepareCustomPath(string suffix = "")
|
||||||
|
{
|
||||||
|
string path = Path.Combine(RuntimeInfo.StartupDirectory, $"custom-path{suffix}");
|
||||||
|
|
||||||
|
if (Directory.Exists(path))
|
||||||
|
Directory.Delete(path, true);
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CustomTestHeadlessGameHost : HeadlessGameHost
|
||||||
|
{
|
||||||
|
public Storage InitialStorage { get; }
|
||||||
|
|
||||||
|
public CustomTestHeadlessGameHost(string name)
|
||||||
|
: base(name)
|
||||||
|
{
|
||||||
|
string defaultStorageLocation = getDefaultLocationFor(name);
|
||||||
|
|
||||||
|
InitialStorage = new DesktopStorage(defaultStorageLocation, this);
|
||||||
|
InitialStorage.DeleteDirectory(string.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
60
osu.Game.Tests/Visual/Multiplayer/RoomManagerTestScene.cs
Normal file
60
osu.Game.Tests/Visual/Multiplayer/RoomManagerTestScene.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Screens.Multi;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
|
{
|
||||||
|
public abstract class RoomManagerTestScene : MultiplayerTestScene
|
||||||
|
{
|
||||||
|
[Cached(Type = typeof(IRoomManager))]
|
||||||
|
protected TestRoomManager RoomManager { get; } = new TestRoomManager();
|
||||||
|
|
||||||
|
public override void SetUpSteps()
|
||||||
|
{
|
||||||
|
base.SetUpSteps();
|
||||||
|
|
||||||
|
AddStep("clear rooms", () => RoomManager.Rooms.Clear());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void AddRooms(int count, RulesetInfo ruleset = null)
|
||||||
|
{
|
||||||
|
AddStep("add rooms", () =>
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
var room = new Room
|
||||||
|
{
|
||||||
|
RoomID = { Value = i },
|
||||||
|
Name = { Value = $"Room {i}" },
|
||||||
|
Host = { Value = new User { Username = "Host" } },
|
||||||
|
EndDate = { Value = DateTimeOffset.Now + TimeSpan.FromSeconds(10) }
|
||||||
|
};
|
||||||
|
|
||||||
|
if (ruleset != null)
|
||||||
|
{
|
||||||
|
room.Playlist.Add(new PlaylistItem
|
||||||
|
{
|
||||||
|
Ruleset = { Value = ruleset },
|
||||||
|
Beatmap =
|
||||||
|
{
|
||||||
|
Value = new BeatmapInfo
|
||||||
|
{
|
||||||
|
Metadata = new BeatmapMetadata()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
RoomManager.Rooms.Add(room);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
osu.Game.Tests/Visual/Multiplayer/TestRoomManager.cs
Normal file
35
osu.Game.Tests/Visual/Multiplayer/TestRoomManager.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Screens.Multi;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
|
{
|
||||||
|
public class TestRoomManager : IRoomManager
|
||||||
|
{
|
||||||
|
public event Action RoomsUpdated
|
||||||
|
{
|
||||||
|
add { }
|
||||||
|
remove { }
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly BindableList<Room> Rooms = new BindableList<Room>();
|
||||||
|
|
||||||
|
public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);
|
||||||
|
|
||||||
|
IBindableList<Room> IRoomManager.Rooms => Rooms;
|
||||||
|
|
||||||
|
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) => Rooms.Add(room);
|
||||||
|
|
||||||
|
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PartRoom()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Room.CopyFrom(new Room());
|
Room = new Room();
|
||||||
|
|
||||||
Child = new RoomInfo
|
Child = new RoomInfo
|
||||||
{
|
{
|
||||||
|
@ -1,30 +1,21 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Rulesets.Catch;
|
using osu.Game.Rulesets.Catch;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.Multi;
|
|
||||||
using osu.Game.Screens.Multi.Lounge.Components;
|
using osu.Game.Screens.Multi.Lounge.Components;
|
||||||
using osu.Game.Users;
|
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneLoungeRoomsContainer : MultiplayerTestScene
|
public class TestSceneLoungeRoomsContainer : RoomManagerTestScene
|
||||||
{
|
{
|
||||||
[Cached(Type = typeof(IRoomManager))]
|
|
||||||
private TestRoomManager roomManager = new TestRoomManager();
|
|
||||||
|
|
||||||
private RoomsContainer container;
|
private RoomsContainer container;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -39,34 +30,27 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetUpSteps()
|
|
||||||
{
|
|
||||||
base.SetUpSteps();
|
|
||||||
|
|
||||||
AddStep("clear rooms", () => roomManager.Rooms.Clear());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBasicListChanges()
|
public void TestBasicListChanges()
|
||||||
{
|
{
|
||||||
addRooms(3);
|
AddRooms(3);
|
||||||
|
|
||||||
AddAssert("has 3 rooms", () => container.Rooms.Count == 3);
|
AddAssert("has 3 rooms", () => container.Rooms.Count == 3);
|
||||||
AddStep("remove first room", () => roomManager.Rooms.Remove(roomManager.Rooms.FirstOrDefault()));
|
AddStep("remove first room", () => RoomManager.Rooms.Remove(RoomManager.Rooms.FirstOrDefault()));
|
||||||
AddAssert("has 2 rooms", () => container.Rooms.Count == 2);
|
AddAssert("has 2 rooms", () => container.Rooms.Count == 2);
|
||||||
AddAssert("first room removed", () => container.Rooms.All(r => r.Room.RoomID.Value != 0));
|
AddAssert("first room removed", () => container.Rooms.All(r => r.Room.RoomID.Value != 0));
|
||||||
|
|
||||||
AddStep("select first room", () => container.Rooms.First().Action?.Invoke());
|
AddStep("select first room", () => container.Rooms.First().Action?.Invoke());
|
||||||
AddAssert("first room selected", () => Room == roomManager.Rooms.First());
|
AddAssert("first room selected", () => Room == RoomManager.Rooms.First());
|
||||||
|
|
||||||
AddStep("join first room", () => container.Rooms.First().Action?.Invoke());
|
AddStep("join first room", () => container.Rooms.First().Action?.Invoke());
|
||||||
AddAssert("first room joined", () => roomManager.Rooms.First().Status.Value is JoinedRoomStatus);
|
AddAssert("first room joined", () => RoomManager.Rooms.First().Status.Value is JoinedRoomStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestStringFiltering()
|
public void TestStringFiltering()
|
||||||
{
|
{
|
||||||
addRooms(4);
|
AddRooms(4);
|
||||||
|
|
||||||
AddUntilStep("4 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 4);
|
AddUntilStep("4 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 4);
|
||||||
|
|
||||||
@ -82,8 +66,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestRulesetFiltering()
|
public void TestRulesetFiltering()
|
||||||
{
|
{
|
||||||
addRooms(2, new OsuRuleset().RulesetInfo);
|
AddRooms(2, new OsuRuleset().RulesetInfo);
|
||||||
addRooms(3, new CatchRuleset().RulesetInfo);
|
AddRooms(3, new CatchRuleset().RulesetInfo);
|
||||||
|
|
||||||
AddUntilStep("5 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 5);
|
AddUntilStep("5 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 5);
|
||||||
|
|
||||||
@ -96,67 +80,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddUntilStep("3 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 3);
|
AddUntilStep("3 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRooms(int count, RulesetInfo ruleset = null)
|
|
||||||
{
|
|
||||||
AddStep("add rooms", () =>
|
|
||||||
{
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
var room = new Room
|
|
||||||
{
|
|
||||||
RoomID = { Value = i },
|
|
||||||
Name = { Value = $"Room {i}" },
|
|
||||||
Host = { Value = new User { Username = "Host" } },
|
|
||||||
EndDate = { Value = DateTimeOffset.Now + TimeSpan.FromSeconds(10) }
|
|
||||||
};
|
|
||||||
|
|
||||||
if (ruleset != null)
|
|
||||||
{
|
|
||||||
room.Playlist.Add(new PlaylistItem
|
|
||||||
{
|
|
||||||
Ruleset = { Value = ruleset },
|
|
||||||
Beatmap =
|
|
||||||
{
|
|
||||||
Value = new BeatmapInfo
|
|
||||||
{
|
|
||||||
Metadata = new BeatmapMetadata()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
roomManager.Rooms.Add(room);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void joinRequested(Room room) => room.Status.Value = new JoinedRoomStatus();
|
private void joinRequested(Room room) => room.Status.Value = new JoinedRoomStatus();
|
||||||
|
|
||||||
private class TestRoomManager : IRoomManager
|
|
||||||
{
|
|
||||||
public event Action RoomsUpdated
|
|
||||||
{
|
|
||||||
add { }
|
|
||||||
remove { }
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly BindableList<Room> Rooms = new BindableList<Room>();
|
|
||||||
|
|
||||||
public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);
|
|
||||||
|
|
||||||
IBindableList<Room> IRoomManager.Rooms => Rooms;
|
|
||||||
|
|
||||||
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) => Rooms.Add(room);
|
|
||||||
|
|
||||||
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PartRoom()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class JoinedRoomStatus : RoomStatus
|
private class JoinedRoomStatus : RoomStatus
|
||||||
{
|
{
|
||||||
public override string Message => "Joined";
|
public override string Message => "Joined";
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
// 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.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Screens;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Screens.Multi.Lounge;
|
||||||
|
using osu.Game.Screens.Multi.Lounge.Components;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
|
{
|
||||||
|
public class TestSceneLoungeSubScreen : RoomManagerTestScene
|
||||||
|
{
|
||||||
|
private LoungeSubScreen loungeScreen;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetUpSteps()
|
||||||
|
{
|
||||||
|
base.SetUpSteps();
|
||||||
|
|
||||||
|
AddStep("push screen", () => LoadScreen(loungeScreen = new LoungeSubScreen
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Width = 0.5f,
|
||||||
|
}));
|
||||||
|
|
||||||
|
AddUntilStep("wait for present", () => loungeScreen.IsCurrentScreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
private RoomsContainer roomsContainer => loungeScreen.ChildrenOfType<RoomsContainer>().First();
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestScrollSelectedIntoView()
|
||||||
|
{
|
||||||
|
AddRooms(30);
|
||||||
|
|
||||||
|
AddUntilStep("first room is not masked", () => checkRoomVisible(roomsContainer.Rooms.First()));
|
||||||
|
|
||||||
|
AddStep("select last room", () => roomsContainer.Rooms.Last().Action?.Invoke());
|
||||||
|
|
||||||
|
AddUntilStep("first room is masked", () => !checkRoomVisible(roomsContainer.Rooms.First()));
|
||||||
|
AddUntilStep("last room is not masked", () => checkRoomVisible(roomsContainer.Rooms.Last()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool checkRoomVisible(DrawableRoom room) =>
|
||||||
|
loungeScreen.ChildrenOfType<OsuScrollContainer>().First().ScreenSpaceDrawQuad
|
||||||
|
.Contains(room.ScreenSpaceDrawQuad.Centre);
|
||||||
|
}
|
||||||
|
}
|
@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Room.Playlist.Clear();
|
Room = new Room();
|
||||||
|
|
||||||
Child = new MatchBeatmapDetailArea
|
Child = new MatchBeatmapDetailArea
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
public TestSceneMatchHeader()
|
public TestSceneMatchHeader()
|
||||||
{
|
{
|
||||||
|
Room = new Room();
|
||||||
Room.Playlist.Add(new PlaylistItem
|
Room.Playlist.Add(new PlaylistItem
|
||||||
{
|
{
|
||||||
Beatmap =
|
Beatmap =
|
||||||
|
@ -6,6 +6,7 @@ using Newtonsoft.Json;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Screens.Multi.Match.Components;
|
using osu.Game.Screens.Multi.Match.Components;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -18,7 +19,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
public TestSceneMatchLeaderboard()
|
public TestSceneMatchLeaderboard()
|
||||||
{
|
{
|
||||||
Room.RoomID.Value = 3;
|
Room = new Room { RoomID = { Value = 3 } };
|
||||||
|
|
||||||
Add(new MatchLeaderboard
|
Add(new MatchLeaderboard
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Platform;
|
|||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.Multi.Components;
|
using osu.Game.Screens.Multi.Components;
|
||||||
@ -95,7 +96,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Room.Playlist.Clear();
|
Room = new Room();
|
||||||
});
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Room.CopyFrom(new Room());
|
Room = new Room();
|
||||||
});
|
});
|
||||||
|
|
||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Screens.Multi.Components;
|
using osu.Game.Screens.Multi.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -12,10 +13,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
protected override bool UseOnlineAPI => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
public TestSceneOverlinedParticipants()
|
[SetUp]
|
||||||
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Room.RoomID.Value = 7;
|
Room = new Room { RoomID = { Value = 7 } };
|
||||||
}
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestHorizontalLayout()
|
public void TestHorizontalLayout()
|
||||||
|
@ -16,6 +16,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
public TestSceneOverlinedPlaylist()
|
public TestSceneOverlinedPlaylist()
|
||||||
{
|
{
|
||||||
|
Room = new Room { RoomID = { Value = 7 } };
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
Room.Playlist.Add(new PlaylistItem
|
Room.Playlist.Add(new PlaylistItem
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Screens.Multi.Components;
|
using osu.Game.Screens.Multi.Components;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
@ -10,10 +12,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
protected override bool UseOnlineAPI => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup() => Schedule(() =>
|
||||||
|
{
|
||||||
|
Room = new Room { RoomID = { Value = 7 } };
|
||||||
|
});
|
||||||
|
|
||||||
public TestSceneParticipantsList()
|
public TestSceneParticipantsList()
|
||||||
{
|
{
|
||||||
Room.RoomID.Value = 7;
|
|
||||||
|
|
||||||
Add(new ParticipantsList { RelativeSizeAxes = Axes.Both });
|
Add(new ParticipantsList { RelativeSizeAxes = Axes.Both });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -20,21 +21,23 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
{
|
{
|
||||||
public override string Title => "Lounge";
|
public override string Title => "Lounge";
|
||||||
|
|
||||||
protected readonly FilterControl Filter;
|
protected FilterControl Filter;
|
||||||
|
|
||||||
private readonly Bindable<bool> initialRoomsReceived = new Bindable<bool>();
|
private readonly Bindable<bool> initialRoomsReceived = new Bindable<bool>();
|
||||||
|
|
||||||
private readonly Container content;
|
private Container content;
|
||||||
private readonly LoadingLayer loadingLayer;
|
private LoadingLayer loadingLayer;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<Room> selectedRoom { get; set; }
|
private Bindable<Room> selectedRoom { get; set; }
|
||||||
|
|
||||||
private bool joiningRoom;
|
private bool joiningRoom;
|
||||||
|
|
||||||
public LoungeSubScreen()
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
{
|
{
|
||||||
RoomsContainer roomsContainer;
|
RoomsContainer roomsContainer;
|
||||||
|
OsuScrollContainer scrollContainer;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -50,7 +53,7 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
Width = 0.55f,
|
Width = 0.55f,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuScrollContainer
|
scrollContainer = new OsuScrollContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
ScrollbarOverlapsContent = false,
|
ScrollbarOverlapsContent = false,
|
||||||
@ -70,6 +73,14 @@ namespace osu.Game.Screens.Multi.Lounge
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// scroll selected room into view on selection.
|
||||||
|
selectedRoom.BindValueChanged(val =>
|
||||||
|
{
|
||||||
|
var drawable = roomsContainer.Rooms.FirstOrDefault(r => r.Room == val.NewValue);
|
||||||
|
if (drawable != null)
|
||||||
|
scrollContainer.ScrollIntoView(drawable);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -10,7 +10,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
public abstract class MultiplayerTestScene : ScreenTestScene
|
public abstract class MultiplayerTestScene : ScreenTestScene
|
||||||
{
|
{
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly Bindable<Room> currentRoom = new Bindable<Room>(new Room());
|
private readonly Bindable<Room> currentRoom = new Bindable<Room>();
|
||||||
|
|
||||||
protected Room Room
|
protected Room Room
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user