mirror of
https://github.com/ppy/osu.git
synced 2025-03-04 03:53:21 +08:00
Remove "test container", make everything go through OnlinePlayTestScene
This commit is contained in:
parent
8fba7d2423
commit
aa5d22d04a
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Online.Rooms.RoomStatuses;
|
using osu.Game.Online.Rooms.RoomStatuses;
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
@ -11,28 +12,25 @@ using osu.Game.Users;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneLoungeRoomInfo : OsuTestScene
|
public class TestSceneLoungeRoomInfo : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
private TestRoomContainer roomContainer;
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
|
||||||
Child = roomContainer = new TestRoomContainer
|
|
||||||
{
|
{
|
||||||
|
SelectedRoom.Value = new Room();
|
||||||
|
|
||||||
Child = new RoomInfo
|
Child = new RoomInfo
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Width = 500
|
Width = 500
|
||||||
}
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestNonSelectedRoom()
|
public void TestNonSelectedRoom()
|
||||||
{
|
{
|
||||||
AddStep("set null room", () => roomContainer.Room.RoomID.Value = null);
|
AddStep("set null room", () => SelectedRoom.Value.RoomID.Value = null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -40,11 +38,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
AddStep("set open room", () =>
|
AddStep("set open room", () =>
|
||||||
{
|
{
|
||||||
roomContainer.Room.RoomID.Value = 0;
|
SelectedRoom.Value.RoomID.Value = 0;
|
||||||
roomContainer.Room.Name.Value = "Room 0";
|
SelectedRoom.Value.Name.Value = "Room 0";
|
||||||
roomContainer.Room.Host.Value = new User { Username = "peppy", Id = 2 };
|
SelectedRoom.Value.Host.Value = new User { Username = "peppy", Id = 2 };
|
||||||
roomContainer.Room.EndDate.Value = DateTimeOffset.Now.AddMonths(1);
|
SelectedRoom.Value.EndDate.Value = DateTimeOffset.Now.AddMonths(1);
|
||||||
roomContainer.Room.Status.Value = new RoomStatusOpen();
|
SelectedRoom.Value.Status.Value = new RoomStatusOpen();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Rulesets.Catch;
|
using osu.Game.Rulesets.Catch;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.OnlinePlay;
|
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -17,9 +16,9 @@ using osuTK.Input;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneLoungeRoomsContainer : OnlinePlaySubScreenTestScene
|
public class TestSceneLoungeRoomsContainer : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
protected new TestBasicRoomManager RoomManager => (TestBasicRoomManager)base.RoomManager;
|
protected new BasicTestRoomManager RoomManager => (BasicTestRoomManager)base.RoomManager;
|
||||||
|
|
||||||
private RoomsContainer container;
|
private RoomsContainer container;
|
||||||
|
|
||||||
@ -35,8 +34,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IRoomManager CreateRoomManager() => new TestBasicRoomManager();
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBasicListChanges()
|
public void TestBasicListChanges()
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneMatchBeatmapDetailArea : OsuTestScene
|
public class TestSceneMatchBeatmapDetailArea : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmapManager { get; set; }
|
private BeatmapManager beatmapManager { get; set; }
|
||||||
@ -24,28 +24,25 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private RulesetStore rulesetStore { get; set; }
|
private RulesetStore rulesetStore { get; set; }
|
||||||
|
|
||||||
private TestRoomContainer roomContainer;
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
|
||||||
Child = roomContainer = new TestRoomContainer
|
|
||||||
{
|
{
|
||||||
|
SelectedRoom.Value = new Room();
|
||||||
|
|
||||||
Child = new MatchBeatmapDetailArea
|
Child = new MatchBeatmapDetailArea
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Size = new Vector2(500),
|
Size = new Vector2(500),
|
||||||
CreateNewItem = createNewItem
|
CreateNewItem = createNewItem
|
||||||
}
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
private void createNewItem()
|
private void createNewItem()
|
||||||
{
|
{
|
||||||
roomContainer.Room.Playlist.Add(new PlaylistItem
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
||||||
{
|
{
|
||||||
ID = roomContainer.Room.Playlist.Count,
|
ID = SelectedRoom.Value.Playlist.Count,
|
||||||
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
||||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||||
RequiredMods =
|
RequiredMods =
|
||||||
|
@ -12,17 +12,14 @@ using osu.Game.Users;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneMatchHeader : OsuTestScene
|
public class TestSceneMatchHeader : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
private TestRoomContainer roomContainer;
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Child = roomContainer = new TestRoomContainer
|
SelectedRoom.Value = new Room();
|
||||||
{
|
|
||||||
Child = new Header()
|
Child = new Header();
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -30,7 +27,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
AddStep("set basic room", () =>
|
AddStep("set basic room", () =>
|
||||||
{
|
{
|
||||||
roomContainer.Room.Playlist.Add(new PlaylistItem
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem
|
||||||
{
|
{
|
||||||
Beatmap =
|
Beatmap =
|
||||||
{
|
{
|
||||||
@ -54,8 +51,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
roomContainer.Room.Name.Value = "A very awesome room";
|
SelectedRoom.Value.Name.Value = "A very awesome room";
|
||||||
roomContainer.Room.Host.Value = new User { Id = 2, Username = "peppy" };
|
SelectedRoom.Value.Host.Value = new User { Id = 2, Username = "peppy" };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneMatchLeaderboard : OsuTestScene
|
public class TestSceneMatchLeaderboard : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -59,18 +59,16 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Child = new TestRoomContainer
|
SelectedRoom.Value = new Room { RoomID = { Value = 3 } };
|
||||||
{
|
|
||||||
Room = { RoomID = { Value = 3 } },
|
|
||||||
Child = new MatchLeaderboard
|
Child = new MatchLeaderboard
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Size = new Vector2(550f, 450f),
|
Size = new Vector2(550f, 450f),
|
||||||
Scope = MatchLeaderboardScope.Overall,
|
Scope = MatchLeaderboardScope.Overall,
|
||||||
}
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
// 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 osu.Framework.Allocation;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
||||||
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestSceneMultiplayerMatchFooter : MultiplayerTestScene
|
public class TestSceneMultiplayerMatchFooter : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
[Cached]
|
[SetUp]
|
||||||
private readonly OnlinePlayBeatmapAvailabilityTracker availablilityTracker = new OnlinePlayBeatmapAvailabilityTracker();
|
public new void Setup() => Schedule(() =>
|
||||||
|
{
|
||||||
|
SelectedRoom.Value = new Room();
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
Child = new MultiplayerMatchFooter
|
Child = new MultiplayerMatchFooter
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Height = 50
|
Height = 50
|
||||||
};
|
};
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ using osu.Game.Tests.Visual.OnlinePlay;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestScenePlaylistsSongSelect : OnlinePlaySubScreenTestScene
|
public class TestScenePlaylistsSongSelect : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmapManager { get; set; }
|
private BeatmapManager beatmapManager { get; set; }
|
||||||
|
@ -6,7 +6,6 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Screens.OnlinePlay;
|
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge;
|
using osu.Game.Screens.OnlinePlay.Lounge;
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||||
@ -14,14 +13,12 @@ using osu.Game.Tests.Visual.OnlinePlay;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Playlists
|
namespace osu.Game.Tests.Visual.Playlists
|
||||||
{
|
{
|
||||||
public class TestScenePlaylistsLoungeSubScreen : OnlinePlaySubScreenTestScene
|
public class TestScenePlaylistsLoungeSubScreen : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
protected new TestBasicRoomManager RoomManager => (TestBasicRoomManager)base.RoomManager;
|
protected new BasicTestRoomManager RoomManager => (BasicTestRoomManager)base.RoomManager;
|
||||||
|
|
||||||
private LoungeSubScreen loungeScreen;
|
private LoungeSubScreen loungeScreen;
|
||||||
|
|
||||||
protected override IRoomManager CreateRoomManager() => new TestBasicRoomManager();
|
|
||||||
|
|
||||||
public override void SetUpSteps()
|
public override void SetUpSteps()
|
||||||
{
|
{
|
||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -16,24 +15,23 @@ using osu.Game.Tests.Visual.OnlinePlay;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Playlists
|
namespace osu.Game.Tests.Visual.Playlists
|
||||||
{
|
{
|
||||||
public class TestScenePlaylistsMatchSettingsOverlay : OsuTestScene
|
public class TestScenePlaylistsMatchSettingsOverlay : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
[Cached(Type = typeof(IRoomManager))]
|
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
|
||||||
private TestRoomManager roomManager = new TestRoomManager();
|
|
||||||
|
|
||||||
private TestRoomContainer roomContainer;
|
|
||||||
private TestRoomSettings settings;
|
private TestRoomSettings settings;
|
||||||
|
|
||||||
|
protected override RoomTestDependencies CreateRoomDependencies() => new TestDependencies();
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
|
||||||
Child = roomContainer = new TestRoomContainer
|
|
||||||
{
|
{
|
||||||
|
SelectedRoom.Value = new Room();
|
||||||
|
|
||||||
Child = settings = new TestRoomSettings
|
Child = settings = new TestRoomSettings
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
State = { Value = Visibility.Visible }
|
State = { Value = Visibility.Visible }
|
||||||
}
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -42,19 +40,19 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
{
|
{
|
||||||
AddStep("clear name and beatmap", () =>
|
AddStep("clear name and beatmap", () =>
|
||||||
{
|
{
|
||||||
roomContainer.Room.Name.Value = "";
|
SelectedRoom.Value.Name.Value = "";
|
||||||
roomContainer.Room.Playlist.Clear();
|
SelectedRoom.Value.Playlist.Clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
|
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
|
||||||
|
|
||||||
AddStep("set name", () => roomContainer.Room.Name.Value = "Room name");
|
AddStep("set name", () => SelectedRoom.Value.Name.Value = "Room name");
|
||||||
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
|
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
|
||||||
|
|
||||||
AddStep("set beatmap", () => roomContainer.Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } }));
|
AddStep("set beatmap", () => SelectedRoom.Value.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } }));
|
||||||
AddAssert("button enabled", () => settings.ApplyButton.Enabled.Value);
|
AddAssert("button enabled", () => settings.ApplyButton.Enabled.Value);
|
||||||
|
|
||||||
AddStep("clear name", () => roomContainer.Room.Name.Value = "");
|
AddStep("clear name", () => SelectedRoom.Value.Name.Value = "");
|
||||||
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
|
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +68,9 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
{
|
{
|
||||||
settings.NameField.Current.Value = expected_name;
|
settings.NameField.Current.Value = expected_name;
|
||||||
settings.DurationField.Current.Value = expectedDuration;
|
settings.DurationField.Current.Value = expectedDuration;
|
||||||
roomContainer.Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } });
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } });
|
||||||
|
|
||||||
roomManager.CreateRequested = r =>
|
RoomManager.CreateRequested = r =>
|
||||||
{
|
{
|
||||||
createdRoom = r;
|
createdRoom = r;
|
||||||
return true;
|
return true;
|
||||||
@ -91,11 +89,11 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
|
|
||||||
AddStep("setup", () =>
|
AddStep("setup", () =>
|
||||||
{
|
{
|
||||||
roomContainer.Room.Name.Value = "Test Room";
|
SelectedRoom.Value.Name.Value = "Test Room";
|
||||||
roomContainer.Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } });
|
SelectedRoom.Value.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } });
|
||||||
|
|
||||||
fail = true;
|
fail = true;
|
||||||
roomManager.CreateRequested = _ => !fail;
|
RoomManager.CreateRequested = _ => !fail;
|
||||||
});
|
});
|
||||||
AddAssert("error not displayed", () => !settings.ErrorText.IsPresent);
|
AddAssert("error not displayed", () => !settings.ErrorText.IsPresent);
|
||||||
|
|
||||||
@ -122,7 +120,12 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
public OsuSpriteText ErrorText => ((MatchSettings)Settings).ErrorText;
|
public OsuSpriteText ErrorText => ((MatchSettings)Settings).ErrorText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestRoomManager : IRoomManager
|
private class TestDependencies : RoomTestDependencies
|
||||||
|
{
|
||||||
|
protected override IRoomManager CreateRoomManager() => new TestRoomManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class TestRoomManager : IRoomManager
|
||||||
{
|
{
|
||||||
public const string FAILED_TEXT = "failed";
|
public const string FAILED_TEXT = "failed";
|
||||||
|
|
||||||
|
@ -3,27 +3,23 @@
|
|||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Screens.OnlinePlay.Components;
|
using osu.Game.Screens.OnlinePlay.Components;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Playlists
|
namespace osu.Game.Tests.Visual.Playlists
|
||||||
{
|
{
|
||||||
public class TestScenePlaylistsParticipantsList : OsuTestScene
|
public class TestScenePlaylistsParticipantsList : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
private TestRoomContainer roomContainer;
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public new void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Child = roomContainer = new TestRoomContainer
|
SelectedRoom.Value = new Room { RoomID = { Value = 7 } };
|
||||||
{
|
|
||||||
Room = { RoomID = { Value = 7 } }
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i = 0; i < 50; i++)
|
for (int i = 0; i < 50; i++)
|
||||||
{
|
{
|
||||||
roomContainer.Room.RecentParticipants.Add(new User
|
SelectedRoom.Value.RecentParticipants.Add(new User
|
||||||
{
|
{
|
||||||
Username = "peppy",
|
Username = "peppy",
|
||||||
Statistics = new UserStatistics { GlobalRank = 1234 },
|
Statistics = new UserStatistics { GlobalRank = 1234 },
|
||||||
@ -37,7 +33,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
{
|
{
|
||||||
AddStep("create component", () =>
|
AddStep("create component", () =>
|
||||||
{
|
{
|
||||||
roomContainer.Child = new ParticipantsDisplay(Direction.Horizontal)
|
Child = new ParticipantsDisplay(Direction.Horizontal)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -51,7 +47,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
{
|
{
|
||||||
AddStep("create component", () =>
|
AddStep("create component", () =>
|
||||||
{
|
{
|
||||||
roomContainer.Child = new ParticipantsDisplay(Direction.Vertical)
|
Child = new ParticipantsDisplay(Direction.Vertical)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
|
@ -24,7 +24,7 @@ using osuTK.Input;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Playlists
|
namespace osu.Game.Tests.Visual.Playlists
|
||||||
{
|
{
|
||||||
public class TestScenePlaylistsRoomSubScreen : OnlinePlaySubScreenTestScene
|
public class TestScenePlaylistsRoomSubScreen : OnlinePlayTestScene
|
||||||
{
|
{
|
||||||
private BeatmapManager manager;
|
private BeatmapManager manager;
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
// 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 osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Screens.OnlinePlay;
|
||||||
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
|
{
|
||||||
|
public interface IMultiplayerRoomTestDependencies : IRoomTestDependencies
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The cached <see cref="MultiplayerClient"/>.
|
||||||
|
/// </summary>
|
||||||
|
TestMultiplayerClient Client { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The cached <see cref="IRoomManager"/>.
|
||||||
|
/// </summary>
|
||||||
|
new TestMultiplayerRoomManager RoomManager { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
// 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 osu.Game.Online.Multiplayer;
|
||||||
|
using osu.Game.Screens.OnlinePlay;
|
||||||
|
using osu.Game.Tests.Visual.OnlinePlay;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
|
{
|
||||||
|
public class MultiplayerRoomTestDependencies : RoomTestDependencies, IMultiplayerRoomTestDependencies
|
||||||
|
{
|
||||||
|
public TestMultiplayerClient Client { get; }
|
||||||
|
public new TestMultiplayerRoomManager RoomManager => (TestMultiplayerRoomManager)base.RoomManager;
|
||||||
|
|
||||||
|
public MultiplayerRoomTestDependencies()
|
||||||
|
{
|
||||||
|
Client = new TestMultiplayerClient(RoomManager);
|
||||||
|
CacheAs<MultiplayerClient>(Client);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IRoomManager CreateRoomManager() => new TestMultiplayerRoomManager();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
// 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 osu.Game.Tests.Visual.OnlinePlay;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
|
{
|
||||||
|
public class MultiplayerSubScreenTestScene : OnlinePlayTestScene, IMultiplayerRoomTestDependencies
|
||||||
|
{
|
||||||
|
public TestMultiplayerClient Client => RoomDependencies.Client;
|
||||||
|
public new TestMultiplayerRoomManager RoomManager => RoomDependencies.RoomManager;
|
||||||
|
|
||||||
|
protected new MultiplayerRoomTestDependencies RoomDependencies => (MultiplayerRoomTestDependencies)base.RoomDependencies;
|
||||||
|
|
||||||
|
protected override RoomTestDependencies CreateRoomDependencies() => new MultiplayerRoomTestDependencies();
|
||||||
|
}
|
||||||
|
}
|
@ -8,11 +8,10 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Screens.OnlinePlay;
|
using osu.Game.Screens.OnlinePlay;
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||||
using osu.Game.Tests.Visual.OnlinePlay;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
{
|
{
|
||||||
public class TestMultiplayerRoomContainer : TestRoomContainer
|
public class TestMultiplayerRoomContainer : Container
|
||||||
{
|
{
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
@ -12,7 +12,7 @@ using osu.Game.Users;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.OnlinePlay
|
namespace osu.Game.Tests.Visual.OnlinePlay
|
||||||
{
|
{
|
||||||
public class TestBasicRoomManager : IRoomManager
|
public class BasicTestRoomManager : IRoomManager
|
||||||
{
|
{
|
||||||
public event Action RoomsUpdated
|
public event Action RoomsUpdated
|
||||||
{
|
{
|
38
osu.Game/Tests/Visual/OnlinePlay/IRoomTestDependencies.cs
Normal file
38
osu.Game/Tests/Visual/OnlinePlay/IRoomTestDependencies.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// 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 osu.Framework.Bindables;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
|
using osu.Game.Screens.OnlinePlay;
|
||||||
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.OnlinePlay
|
||||||
|
{
|
||||||
|
public interface IRoomTestDependencies
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The cached <see cref="Room"/>.
|
||||||
|
/// </summary>
|
||||||
|
Bindable<Room> SelectedRoom { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The cached <see cref="IRoomManager"/>
|
||||||
|
/// </summary>
|
||||||
|
IRoomManager RoomManager { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The cached <see cref="FilterCriteria"/>.
|
||||||
|
/// </summary>
|
||||||
|
Bindable<FilterCriteria> Filter { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The cached <see cref="OngoingOperationTracker"/>.
|
||||||
|
/// </summary>
|
||||||
|
OngoingOperationTracker OngoingOperationTracker { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The cached <see cref="OnlinePlayBeatmapAvailabilityTracker"/>.
|
||||||
|
/// </summary>
|
||||||
|
OnlinePlayBeatmapAvailabilityTracker AvailabilityTracker { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,83 +0,0 @@
|
|||||||
// 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.Framework.Bindables;
|
|
||||||
using osu.Game.Online.Rooms;
|
|
||||||
using osu.Game.Screens;
|
|
||||||
using osu.Game.Screens.OnlinePlay;
|
|
||||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.OnlinePlay
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A <see cref="ScreenTestScene"/> providing all the dependencies cached by <see cref="OnlinePlayScreen"/> for testing <see cref="OnlinePlaySubScreen"/>s.
|
|
||||||
/// </summary>
|
|
||||||
public abstract class OnlinePlaySubScreenTestScene : ScreenTestScene
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The cached <see cref="SelectedRoom"/>.
|
|
||||||
/// </summary>
|
|
||||||
protected Bindable<Room> SelectedRoom { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The cached <see cref="IRoomManager"/>
|
|
||||||
/// </summary>
|
|
||||||
protected IRoomManager RoomManager { get; private set; }
|
|
||||||
|
|
||||||
protected Bindable<FilterCriteria> Filter { get; private set; }
|
|
||||||
|
|
||||||
protected OngoingOperationTracker OngoingOperationTracker { get; private set; }
|
|
||||||
|
|
||||||
public override void SetUpSteps()
|
|
||||||
{
|
|
||||||
base.SetUpSteps();
|
|
||||||
|
|
||||||
AddStep("create dependencies", () => LoadScreen(new DependenciesScreen(CreateScreenDependencies)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates dependencies for any <see cref="OsuScreen"/> pushed via <see cref="ScreenTestScene.LoadScreen"/>.
|
|
||||||
/// Invoked at the start of every test via <see cref="SetUpSteps"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// This should be overridden to add any custom dependencies required by subclasses of <see cref="OnlinePlaySubScreen"/>.
|
|
||||||
/// </remarks>
|
|
||||||
/// <param name="parent">The parent dependency container.</param>
|
|
||||||
/// <returns>The resultant dependency container.</returns>
|
|
||||||
protected virtual IReadOnlyDependencyContainer CreateScreenDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
SelectedRoom = new Bindable<Room>();
|
|
||||||
RoomManager = CreateRoomManager();
|
|
||||||
Filter = new Bindable<FilterCriteria>(new FilterCriteria());
|
|
||||||
OngoingOperationTracker = new OngoingOperationTracker();
|
|
||||||
|
|
||||||
var dependencies = new DependencyContainer(new CachedModelDependencyContainer<Room>(parent) { Model = { BindTarget = SelectedRoom } });
|
|
||||||
dependencies.CacheAs(SelectedRoom);
|
|
||||||
dependencies.CacheAs(RoomManager);
|
|
||||||
dependencies.CacheAs(Filter);
|
|
||||||
dependencies.CacheAs(OngoingOperationTracker);
|
|
||||||
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual IRoomManager CreateRoomManager() => new TestBasicRoomManager();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A dummy screen used for injecting new dependencies into the hierarchy before any screen is pushed via <see cref="ScreenTestScene.LoadScreen"/>.
|
|
||||||
/// </summary>
|
|
||||||
private class DependenciesScreen : OsuScreen
|
|
||||||
{
|
|
||||||
private readonly Func<IReadOnlyDependencyContainer, IReadOnlyDependencyContainer> createDependenciesFunc;
|
|
||||||
|
|
||||||
public DependenciesScreen(Func<IReadOnlyDependencyContainer, IReadOnlyDependencyContainer> createDependenciesFunc)
|
|
||||||
{
|
|
||||||
this.createDependenciesFunc = createDependenciesFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
=> createDependenciesFunc(base.CreateChildDependencies(parent));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
100
osu.Game/Tests/Visual/OnlinePlay/OnlinePlayTestScene.cs
Normal file
100
osu.Game/Tests/Visual/OnlinePlay/OnlinePlayTestScene.cs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
|
using osu.Game.Screens.OnlinePlay;
|
||||||
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.OnlinePlay
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A <see cref="ScreenTestScene"/> providing all the dependencies cached by <see cref="OnlinePlayScreen"/> for testing <see cref="OnlinePlaySubScreen"/>s.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class OnlinePlayTestScene : ScreenTestScene, IRoomTestDependencies
|
||||||
|
{
|
||||||
|
public Bindable<Room> SelectedRoom => RoomDependencies?.SelectedRoom;
|
||||||
|
public IRoomManager RoomManager => RoomDependencies?.RoomManager;
|
||||||
|
public Bindable<FilterCriteria> Filter => RoomDependencies?.Filter;
|
||||||
|
public OngoingOperationTracker OngoingOperationTracker => RoomDependencies?.OngoingOperationTracker;
|
||||||
|
public OnlinePlayBeatmapAvailabilityTracker AvailabilityTracker => RoomDependencies?.AvailabilityTracker;
|
||||||
|
|
||||||
|
protected RoomTestDependencies RoomDependencies => delegatedDependencies?.RoomDependencies;
|
||||||
|
private DelegatedRoomDependencyContainer delegatedDependencies;
|
||||||
|
|
||||||
|
protected override Container<Drawable> Content => content;
|
||||||
|
private readonly Container content;
|
||||||
|
private readonly Container drawableDependenciesContainer;
|
||||||
|
|
||||||
|
protected OnlinePlayTestScene()
|
||||||
|
{
|
||||||
|
base.Content.AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
drawableDependenciesContainer = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
|
content = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
{
|
||||||
|
delegatedDependencies = new DelegatedRoomDependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
return delegatedDependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup() => Schedule(() =>
|
||||||
|
{
|
||||||
|
// Reset the room dependencies to a fresh state.
|
||||||
|
drawableDependenciesContainer.Clear();
|
||||||
|
delegatedDependencies.RoomDependencies = CreateRoomDependencies();
|
||||||
|
drawableDependenciesContainer.AddRange(RoomDependencies.DrawableComponents);
|
||||||
|
});
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the room dependencies. Called every <see cref="Setup"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Any custom dependencies required for online-play sub-classes should be added here.
|
||||||
|
/// </remarks>
|
||||||
|
protected virtual RoomTestDependencies CreateRoomDependencies() => new RoomTestDependencies();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A <see cref="IReadOnlyDependencyContainer"/> providing a mutable lookup source for room dependencies.
|
||||||
|
/// </summary>
|
||||||
|
private class DelegatedRoomDependencyContainer : IReadOnlyDependencyContainer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The room's dependencies.
|
||||||
|
/// </summary>
|
||||||
|
public RoomTestDependencies RoomDependencies { get; set; }
|
||||||
|
|
||||||
|
private readonly IReadOnlyDependencyContainer parent;
|
||||||
|
private readonly DependencyContainer injectableDependencies;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="DelegatedRoomDependencyContainer"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The fallback <see cref="IReadOnlyDependencyContainer"/> to use when <see cref="RoomDependencies"/> cannot satisfy a dependency.</param>
|
||||||
|
public DelegatedRoomDependencyContainer(IReadOnlyDependencyContainer parent)
|
||||||
|
{
|
||||||
|
this.parent = parent;
|
||||||
|
injectableDependencies = new DependencyContainer(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Get(Type type)
|
||||||
|
=> RoomDependencies?.Get(type) ?? parent.Get(type);
|
||||||
|
|
||||||
|
public object Get(Type type, CacheInfo info)
|
||||||
|
=> RoomDependencies?.Get(type, info) ?? parent.Get(type, info);
|
||||||
|
|
||||||
|
public void Inject<T>(T instance)
|
||||||
|
where T : class
|
||||||
|
=> injectableDependencies.Inject(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
78
osu.Game/Tests/Visual/OnlinePlay/RoomTestDependencies.cs
Normal file
78
osu.Game/Tests/Visual/OnlinePlay/RoomTestDependencies.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
// 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 System.Collections.Generic;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
|
using osu.Game.Screens.OnlinePlay;
|
||||||
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.OnlinePlay
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains dependencies for testing online-play rooms.
|
||||||
|
/// </summary>
|
||||||
|
public class RoomTestDependencies : IReadOnlyDependencyContainer, IRoomTestDependencies
|
||||||
|
{
|
||||||
|
public Bindable<Room> SelectedRoom { get; }
|
||||||
|
public IRoomManager RoomManager { get; }
|
||||||
|
public Bindable<FilterCriteria> Filter { get; }
|
||||||
|
public OngoingOperationTracker OngoingOperationTracker { get; }
|
||||||
|
public OnlinePlayBeatmapAvailabilityTracker AvailabilityTracker { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All cached dependencies which are also <see cref="Drawable"/> components.
|
||||||
|
/// </summary>
|
||||||
|
public IReadOnlyList<Drawable> DrawableComponents => drawableComponents;
|
||||||
|
|
||||||
|
private readonly List<Drawable> drawableComponents = new List<Drawable>();
|
||||||
|
private readonly DependencyContainer dependencies;
|
||||||
|
|
||||||
|
public RoomTestDependencies()
|
||||||
|
{
|
||||||
|
SelectedRoom = new Bindable<Room>();
|
||||||
|
RoomManager = CreateRoomManager();
|
||||||
|
Filter = new Bindable<FilterCriteria>(new FilterCriteria());
|
||||||
|
OngoingOperationTracker = new OngoingOperationTracker();
|
||||||
|
AvailabilityTracker = new OnlinePlayBeatmapAvailabilityTracker();
|
||||||
|
|
||||||
|
dependencies = new DependencyContainer(new CachedModelDependencyContainer<Room>(null) { Model = { BindTarget = SelectedRoom } });
|
||||||
|
|
||||||
|
CacheAs(SelectedRoom);
|
||||||
|
CacheAs(RoomManager);
|
||||||
|
CacheAs(Filter);
|
||||||
|
CacheAs(OngoingOperationTracker);
|
||||||
|
CacheAs(AvailabilityTracker);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Get(Type type)
|
||||||
|
=> dependencies.Get(type);
|
||||||
|
|
||||||
|
public object Get(Type type, CacheInfo info)
|
||||||
|
=> dependencies.Get(type, info);
|
||||||
|
|
||||||
|
public void Inject<T>(T instance)
|
||||||
|
where T : class
|
||||||
|
=> dependencies.Inject(instance);
|
||||||
|
|
||||||
|
protected void Cache(object instance)
|
||||||
|
{
|
||||||
|
dependencies.Cache(instance);
|
||||||
|
if (instance is Drawable drawable)
|
||||||
|
drawableComponents.Add(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void CacheAs<T>(T instance)
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
dependencies.CacheAs(instance);
|
||||||
|
if (instance is Drawable drawable)
|
||||||
|
drawableComponents.Add(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual IRoomManager CreateRoomManager() => new BasicTestRoomManager();
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +0,0 @@
|
|||||||
// 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 osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Online.Rooms;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.OnlinePlay
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Contains a single <see cref="Room"/> that is resolvable by components in test scenes.
|
|
||||||
/// </summary>
|
|
||||||
public class TestRoomContainer : Container
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The cached <see cref="Room"/>.
|
|
||||||
/// </summary>
|
|
||||||
public readonly Room Room = new Room();
|
|
||||||
|
|
||||||
public TestRoomContainer()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
var dependencies = new DependencyContainer(
|
|
||||||
new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent)) { Model = { Value = Room } });
|
|
||||||
|
|
||||||
dependencies.Cache(new Bindable<Room>(Room));
|
|
||||||
|
|
||||||
return dependencies;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user