1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-11 01:07:23 +08:00

Add failing test

This commit is contained in:
Dan Balasescu 2025-02-28 15:51:54 +09:00
parent a659936c57
commit 306b30cb12
No known key found for this signature in database
2 changed files with 28 additions and 4 deletions

View File

@ -317,6 +317,29 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("score multiplier = 1.20", () => this.ChildrenOfType<RankingInformationDisplay>().Single().ModMultiplier.Value, () => Is.EqualTo(1.2).Within(0.01)); AddAssert("score multiplier = 1.20", () => this.ChildrenOfType<RankingInformationDisplay>().Single().ModMultiplier.Value, () => Is.EqualTo(1.2).Within(0.01));
} }
[Test]
public void TestChangeSettingsButtonVisibleForHost()
{
AddStep("add playlist item", () =>
{
SelectedRoom.Value!.Playlist =
[
new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
{
RulesetID = new OsuRuleset().RulesetInfo.OnlineID
}
];
});
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
AddUntilStep("wait for join", () => RoomJoined);
AddUntilStep("button visible", () => this.ChildrenOfType<DrawableMatchRoom>().Single().ChangeSettingsButton?.Alpha, () => Is.GreaterThan(0));
AddStep("join other user", void () => MultiplayerClient.AddUser(new APIUser { Id = PLAYER_1_ID }));
AddStep("make other user host", () => MultiplayerClient.TransferHost(PLAYER_1_ID));
AddAssert("button hidden", () => this.ChildrenOfType<DrawableMatchRoom>().Single().ChangeSettingsButton?.Alpha, () => Is.EqualTo(0));
}
private partial class TestMultiplayerMatchSubScreen : MultiplayerMatchSubScreen private partial class TestMultiplayerMatchSubScreen : MultiplayerMatchSubScreen
{ {
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]

View File

@ -25,12 +25,13 @@ namespace osu.Game.Screens.OnlinePlay.Match
set => selectedItem.Current = value; set => selectedItem.Current = value;
} }
public Drawable? ChangeSettingsButton { get; private set; }
[Resolved] [Resolved]
private IAPIProvider api { get; set; } = null!; private IAPIProvider api { get; set; } = null!;
private readonly BindableWithCurrent<PlaylistItem?> selectedItem = new BindableWithCurrent<PlaylistItem?>(); private readonly BindableWithCurrent<PlaylistItem?> selectedItem = new BindableWithCurrent<PlaylistItem?>();
private readonly bool allowEdit; private readonly bool allowEdit;
private Drawable? editButton;
public DrawableMatchRoom(Room room, bool allowEdit = true) public DrawableMatchRoom(Room room, bool allowEdit = true)
: base(room) : base(room)
@ -45,7 +46,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
{ {
if (allowEdit) if (allowEdit)
{ {
ButtonsContainer.Add(editButton = new PurpleRoundedButton ButtonsContainer.Add(ChangeSettingsButton = new PurpleRoundedButton
{ {
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -73,8 +74,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
private void updateRoomHost() private void updateRoomHost()
{ {
if (editButton != null) if (ChangeSettingsButton != null)
editButton.Alpha = Room.Host?.Equals(api.LocalUser.Value) == true ? 1 : 0; ChangeSettingsButton.Alpha = Room.Host?.Equals(api.LocalUser.Value) == true ? 1 : 0;
} }
protected override UpdateableBeatmapBackgroundSprite CreateBackground() => base.CreateBackground().With(d => protected override UpdateableBeatmapBackgroundSprite CreateBackground() => base.CreateBackground().With(d =>