mirror of
https://github.com/ppy/osu
synced 2025-02-03 03:42:15 +00:00
Remove RoomTestScene inheritance from simple test scenes
This commit is contained in:
parent
b6555c10f8
commit
c9ec4b9da4
@ -10,28 +10,28 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneLoungeRoomInfo : RoomTestScene
|
||||
public class TestSceneLoungeRoomInfo : OsuTestScene
|
||||
{
|
||||
private TestRoomContainer roomContainer;
|
||||
|
||||
[SetUp]
|
||||
public new void Setup() => Schedule(() =>
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
Child = new RoomInfo
|
||||
Child = roomContainer = new TestRoomContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 500
|
||||
Child = new RoomInfo
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 500
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
// Todo: Temp
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNonSelectedRoom()
|
||||
{
|
||||
AddStep("set null room", () => Room.RoomID.Value = null);
|
||||
AddStep("set null room", () => roomContainer.Room.RoomID.Value = null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -39,11 +39,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
AddStep("set open room", () =>
|
||||
{
|
||||
Room.RoomID.Value = 0;
|
||||
Room.Name.Value = "Room 0";
|
||||
Room.Host.Value = new User { Username = "peppy", Id = 2 };
|
||||
Room.EndDate.Value = DateTimeOffset.Now.AddMonths(1);
|
||||
Room.Status.Value = new RoomStatusOpen();
|
||||
roomContainer.Room.RoomID.Value = 0;
|
||||
roomContainer.Room.Name.Value = "Room 0";
|
||||
roomContainer.Room.Host.Value = new User { Username = "peppy", Id = 2 };
|
||||
roomContainer.Room.EndDate.Value = DateTimeOffset.Now.AddMonths(1);
|
||||
roomContainer.Room.Status.Value = new RoomStatusOpen();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneMatchBeatmapDetailArea : RoomTestScene
|
||||
public class TestSceneMatchBeatmapDetailArea : OsuTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private BeatmapManager beatmapManager { get; set; }
|
||||
@ -23,23 +23,28 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Resolved]
|
||||
private RulesetStore rulesetStore { get; set; }
|
||||
|
||||
private TestRoomContainer roomContainer;
|
||||
|
||||
[SetUp]
|
||||
public new void Setup() => Schedule(() =>
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
Child = new MatchBeatmapDetailArea
|
||||
Child = roomContainer = new TestRoomContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(500),
|
||||
CreateNewItem = createNewItem
|
||||
Child = new MatchBeatmapDetailArea
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(500),
|
||||
CreateNewItem = createNewItem
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
private void createNewItem()
|
||||
{
|
||||
Room.Playlist.Add(new PlaylistItem
|
||||
roomContainer.Room.Playlist.Add(new PlaylistItem
|
||||
{
|
||||
ID = Room.Playlist.Count,
|
||||
ID = roomContainer.Room.Playlist.Count,
|
||||
Beatmap = { Value = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
RequiredMods =
|
||||
|
@ -11,42 +11,51 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneMatchHeader : RoomTestScene
|
||||
public class TestSceneMatchHeader : OsuTestScene
|
||||
{
|
||||
public TestSceneMatchHeader()
|
||||
{
|
||||
Child = new Header();
|
||||
}
|
||||
private TestRoomContainer roomContainer;
|
||||
|
||||
[SetUp]
|
||||
public new void Setup() => Schedule(() =>
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
Room.Playlist.Add(new PlaylistItem
|
||||
Child = roomContainer = new TestRoomContainer
|
||||
{
|
||||
Beatmap =
|
||||
{
|
||||
Value = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = "Title",
|
||||
Artist = "Artist",
|
||||
AuthorString = "Author",
|
||||
},
|
||||
Version = "Version",
|
||||
Ruleset = new OsuRuleset().RulesetInfo
|
||||
}
|
||||
},
|
||||
RequiredMods =
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModNoFail(),
|
||||
new OsuModRelax(),
|
||||
}
|
||||
});
|
||||
|
||||
Room.Name.Value = "A very awesome room";
|
||||
Room.Host.Value = new User { Id = 2, Username = "peppy" };
|
||||
Child = new Header()
|
||||
};
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestBasicRoom()
|
||||
{
|
||||
AddStep("set basic room", () =>
|
||||
{
|
||||
roomContainer.Room.Playlist.Add(new PlaylistItem
|
||||
{
|
||||
Beatmap =
|
||||
{
|
||||
Value = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = "Title",
|
||||
Artist = "Artist",
|
||||
AuthorString = "Author",
|
||||
},
|
||||
Version = "Version",
|
||||
Ruleset = new OsuRuleset().RulesetInfo
|
||||
}
|
||||
},
|
||||
RequiredMods =
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModNoFail(),
|
||||
new OsuModRelax(),
|
||||
}
|
||||
});
|
||||
|
||||
roomContainer.Room.Name.Value = "A very awesome room";
|
||||
roomContainer.Room.Host.Value = new User { Id = 2, Username = "peppy" };
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,72 +2,75 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Match.Components;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneMatchLeaderboard : RoomTestScene
|
||||
public class TestSceneMatchLeaderboard : OsuTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public TestSceneMatchLeaderboard()
|
||||
{
|
||||
Add(new MatchLeaderboard
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Size = new Vector2(550f, 450f),
|
||||
Scope = MatchLeaderboardScope.Overall,
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAPIProvider api)
|
||||
private void load()
|
||||
{
|
||||
var req = new GetRoomScoresRequest();
|
||||
req.Success += v => { };
|
||||
req.Failure += _ => { };
|
||||
((DummyAPIAccess)API).HandleRequest = r =>
|
||||
{
|
||||
switch (r)
|
||||
{
|
||||
case GetRoomLeaderboardRequest leaderboardRequest:
|
||||
leaderboardRequest.TriggerSuccess(new APILeaderboard
|
||||
{
|
||||
Leaderboard = new List<APIUserScoreAggregate>
|
||||
{
|
||||
new APIUserScoreAggregate
|
||||
{
|
||||
UserID = 2,
|
||||
User = new User { Id = 2, Username = "peppy" },
|
||||
TotalScore = 995533,
|
||||
RoomID = 3,
|
||||
CompletedBeatmaps = 1,
|
||||
TotalAttempts = 6,
|
||||
Accuracy = 0.9851
|
||||
},
|
||||
new APIUserScoreAggregate
|
||||
{
|
||||
UserID = 1040328,
|
||||
User = new User { Id = 1040328, Username = "smoogipoo" },
|
||||
TotalScore = 981100,
|
||||
RoomID = 3,
|
||||
CompletedBeatmaps = 1,
|
||||
TotalAttempts = 9,
|
||||
Accuracy = 0.937
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
api.Queue(req);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public new void Setup() => Schedule(() =>
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
Room.RoomID.Value = 3;
|
||||
Child = new TestRoomContainer
|
||||
{
|
||||
Room = { RoomID = { Value = 3 } },
|
||||
Child = new MatchLeaderboard
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Size = new Vector2(550f, 450f),
|
||||
Scope = MatchLeaderboardScope.Overall,
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
private class GetRoomScoresRequest : APIRequest<List<RoomScore>>
|
||||
{
|
||||
protected override string Target => "rooms/3/leaderboard";
|
||||
}
|
||||
|
||||
private class RoomScore
|
||||
{
|
||||
[JsonProperty("user")]
|
||||
public User User { get; set; }
|
||||
|
||||
[JsonProperty("accuracy")]
|
||||
public double Accuracy { get; set; }
|
||||
|
||||
[JsonProperty("total_score")]
|
||||
public int TotalScore { get; set; }
|
||||
|
||||
[JsonProperty("pp")]
|
||||
public double PP { get; set; }
|
||||
|
||||
[JsonProperty("attempts")]
|
||||
public int TotalAttempts { get; set; }
|
||||
|
||||
[JsonProperty("completed")]
|
||||
public int CompletedAttempts { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ using osu.Game.Screens.Select;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneMultiplayerMatchSongSelect : RoomTestScene
|
||||
public class TestSceneMultiplayerMatchSongSelect : ScreenTestScene
|
||||
{
|
||||
private BeatmapManager manager;
|
||||
private RulesetStore rulesets;
|
||||
|
@ -12,7 +12,7 @@ using osu.Game.Tests.Beatmaps;
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
[HeadlessTest]
|
||||
public class TestSceneMultiplayerRoomManager : RoomTestScene
|
||||
public class TestSceneMultiplayerRoomManager : OsuTestScene
|
||||
{
|
||||
private TestMultiplayerRoomContainer roomContainer;
|
||||
private TestMultiplayerRoomManager roomManager => roomContainer.RoomManager;
|
||||
|
@ -15,23 +15,25 @@ using osu.Game.Screens.OnlinePlay.Playlists;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
public class TestScenePlaylistsMatchSettingsOverlay : RoomTestScene
|
||||
public class TestScenePlaylistsMatchSettingsOverlay : OsuTestScene
|
||||
{
|
||||
[Cached(Type = typeof(IRoomManager))]
|
||||
private TestRoomManager roomManager = new TestRoomManager();
|
||||
|
||||
private TestRoomContainer roomContainer;
|
||||
private TestRoomSettings settings;
|
||||
|
||||
[SetUp]
|
||||
public new void Setup() => Schedule(() =>
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
settings = new TestRoomSettings
|
||||
Child = roomContainer = new TestRoomContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
State = { Value = Visibility.Visible }
|
||||
Child = settings = new TestRoomSettings
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
State = { Value = Visibility.Visible }
|
||||
}
|
||||
};
|
||||
|
||||
Child = settings;
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -39,19 +41,19 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
AddStep("clear name and beatmap", () =>
|
||||
{
|
||||
Room.Name.Value = "";
|
||||
Room.Playlist.Clear();
|
||||
roomContainer.Room.Name.Value = "";
|
||||
roomContainer.Room.Playlist.Clear();
|
||||
});
|
||||
|
||||
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
|
||||
|
||||
AddStep("set name", () => Room.Name.Value = "Room name");
|
||||
AddStep("set name", () => roomContainer.Room.Name.Value = "Room name");
|
||||
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
|
||||
|
||||
AddStep("set beatmap", () => Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } }));
|
||||
AddStep("set beatmap", () => roomContainer.Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } }));
|
||||
AddAssert("button enabled", () => settings.ApplyButton.Enabled.Value);
|
||||
|
||||
AddStep("clear name", () => Room.Name.Value = "");
|
||||
AddStep("clear name", () => roomContainer.Room.Name.Value = "");
|
||||
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
|
||||
}
|
||||
|
||||
@ -67,7 +69,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
settings.NameField.Current.Value = expected_name;
|
||||
settings.DurationField.Current.Value = expectedDuration;
|
||||
Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } });
|
||||
roomContainer.Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } });
|
||||
|
||||
roomManager.CreateRequested = r =>
|
||||
{
|
||||
@ -88,8 +90,8 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
|
||||
AddStep("setup", () =>
|
||||
{
|
||||
Room.Name.Value = "Test Room";
|
||||
Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } });
|
||||
roomContainer.Room.Name.Value = "Test Room";
|
||||
roomContainer.Room.Playlist.Add(new PlaylistItem { Beatmap = { Value = CreateBeatmap(Ruleset.Value).BeatmapInfo } });
|
||||
|
||||
fail = true;
|
||||
roomManager.CreateRequested = _ => !fail;
|
||||
|
@ -8,16 +8,21 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
public class TestScenePlaylistsParticipantsList : RoomTestScene
|
||||
public class TestScenePlaylistsParticipantsList : OsuTestScene
|
||||
{
|
||||
private TestRoomContainer roomContainer;
|
||||
|
||||
[SetUp]
|
||||
public new void Setup() => Schedule(() =>
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
Room.RoomID.Value = 7;
|
||||
Child = roomContainer = new TestRoomContainer
|
||||
{
|
||||
Room = { RoomID = { Value = 7 } }
|
||||
};
|
||||
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
Room.RecentParticipants.Add(new User
|
||||
roomContainer.Room.RecentParticipants.Add(new User
|
||||
{
|
||||
Username = "peppy",
|
||||
Statistics = new UserStatistics { GlobalRank = 1234 },
|
||||
@ -31,7 +36,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
AddStep("create component", () =>
|
||||
{
|
||||
Child = new ParticipantsDisplay(Direction.Horizontal)
|
||||
roomContainer.Child = new ParticipantsDisplay(Direction.Horizontal)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -45,7 +50,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
AddStep("create component", () =>
|
||||
{
|
||||
Child = new ParticipantsDisplay(Direction.Vertical)
|
||||
roomContainer.Child = new ParticipantsDisplay(Direction.Vertical)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
38
osu.Game/Tests/Visual/TestRoomContainer.cs
Normal file
38
osu.Game/Tests/Visual/TestRoomContainer.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.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains a <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();
|
||||
|
||||
[Cached]
|
||||
private readonly Bindable<Room> roomBindable;
|
||||
|
||||
public TestRoomContainer()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
roomBindable = new Bindable<Room>(Room);
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var dependencies = new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent));
|
||||
dependencies.Model.Value = Room;
|
||||
return dependencies;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user