1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:43:22 +08:00

Fix failing tests

This commit is contained in:
Salman Ahmed 2022-07-30 11:49:33 +03:00
parent 369ab10212
commit 8ca8484f0e
3 changed files with 52 additions and 4 deletions

View File

@ -4,6 +4,7 @@
#nullable disable
using System.Linq;
using JetBrains.Annotations;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -17,6 +18,8 @@ using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
using osu.Game.Overlays.Dialog;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
@ -24,6 +27,7 @@ using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Taiko;
using osu.Game.Rulesets.Taiko.Mods;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Menu;
using osu.Game.Screens.OnlinePlay;
using osu.Game.Screens.OnlinePlay.Match;
using osu.Game.Screens.OnlinePlay.Multiplayer;
@ -65,7 +69,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("load match", () =>
{
SelectedRoom.Value = new Room { Name = { Value = "Test Room" } };
LoadScreen(screen = new MultiplayerMatchSubScreen(SelectedRoom.Value));
LoadScreen(screen = new TestMultiplayerMatchSubScreen(SelectedRoom.Value));
});
AddUntilStep("wait for load", () => screen.IsCurrentScreen());
@ -281,5 +285,29 @@ namespace osu.Game.Tests.Visual.Multiplayer
return lastItem.IsSelectedItem;
});
}
private class TestMultiplayerMatchSubScreen : MultiplayerMatchSubScreen
{
[Resolved(canBeNull: true)]
[CanBeNull]
private IDialogOverlay dialogOverlay { get; set; }
public TestMultiplayerMatchSubScreen(Room room)
: base(room)
{
}
public override bool OnExiting(ScreenExitEvent e)
{
// For testing purposes allow the screen to exit without confirming on second attempt.
if (!ExitConfirmed && dialogOverlay?.CurrentDialog is ConfirmDiscardChangesDialog confirmDialog)
{
confirmDialog.PerformAction<PopupDialogDangerousButton>();
return true;
}
return base.OnExiting(e);
}
}
}
}

View File

@ -6,6 +6,7 @@
using System;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -16,9 +17,12 @@ using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
using osu.Game.Overlays.Dialog;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Menu;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.OnlinePlay.Playlists;
@ -221,10 +225,26 @@ namespace osu.Game.Tests.Visual.Playlists
public new Bindable<WorkingBeatmap> Beatmap => base.Beatmap;
[Resolved(canBeNull: true)]
[CanBeNull]
private IDialogOverlay dialogOverlay { get; set; }
public TestPlaylistsRoomSubScreen(Room room)
: base(room)
{
}
public override bool OnExiting(ScreenExitEvent e)
{
// For testing purposes allow the screen to exit without confirming on second attempt.
if (!ExitConfirmed && dialogOverlay?.CurrentDialog is ConfirmDiscardChangesDialog confirmDialog)
{
confirmDialog.PerformAction<PopupDialogDangerousButton>();
return true;
}
return base.OnExiting(e);
}
}
}
}

View File

@ -336,7 +336,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
Scheduler.AddOnce(updateRuleset);
}
private bool exitConfirmed;
protected bool ExitConfirmed { get; private set; }
public override bool OnExiting(ScreenExitEvent e)
{
@ -353,7 +353,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
private bool ensureExitConfirmed()
{
if (exitConfirmed)
if (ExitConfirmed)
return true;
if (dialogOverlay == null || Room.RoomID.Value != null || Room.Playlist.Count == 0)
@ -365,7 +365,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
dialogOverlay.Push(new ConfirmDiscardChangesDialog(() =>
{
exitConfirmed = true;
ExitConfirmed = true;
settingsOverlay.Hide();
this.Exit();
}));