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

Merge pull request #18966 from smoogipoo/fix-flaky-multiplayer-test

Fix test sometimes referencing old ModSelect object
This commit is contained in:
Dean Herbert 2022-07-01 17:55:06 +09:00 committed by GitHub
commit b460a52faf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 14 deletions

View File

@ -176,8 +176,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("mod select contents loaded", AddUntilStep("mod select contents loaded",
() => this.ChildrenOfType<ModColumn>().Any() && this.ChildrenOfType<ModColumn>().All(col => col.IsLoaded && col.ItemsLoaded)); () => this.ChildrenOfType<ModColumn>().Any() && this.ChildrenOfType<ModColumn>().All(col => col.IsLoaded && col.ItemsLoaded));
AddUntilStep("mod select contains only double time mod", AddUntilStep("mod select contains only double time mod",
() => this.ChildrenOfType<UserModSelectOverlay>() () => this.ChildrenOfType<RoomSubScreen>().Single().UserModsSelectOverlay
.SingleOrDefault()?
.ChildrenOfType<ModPanel>() .ChildrenOfType<ModPanel>()
.SingleOrDefault(panel => !panel.Filtered.Value)?.Mod is OsuModDoubleTime); .SingleOrDefault(panel => !panel.Filtered.Value)?.Mod is OsuModDoubleTime);
} }
@ -200,7 +199,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("press toggle mod select key", () => InputManager.Key(Key.F1)); AddStep("press toggle mod select key", () => InputManager.Key(Key.F1));
AddUntilStep("mod select shown", () => this.ChildrenOfType<ModSelectOverlay>().Single().State.Value == Visibility.Visible); AddUntilStep("mod select shown", () => this.ChildrenOfType<RoomSubScreen>().Single().UserModsSelectOverlay.State.Value == Visibility.Visible);
} }
[Test] [Test]
@ -220,7 +219,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("press toggle mod select key", () => InputManager.Key(Key.F1)); AddStep("press toggle mod select key", () => InputManager.Key(Key.F1));
AddWaitStep("wait some", 3); AddWaitStep("wait some", 3);
AddAssert("mod select not shown", () => this.ChildrenOfType<ModSelectOverlay>().Single().State.Value == Visibility.Hidden); AddAssert("mod select not shown", () => this.ChildrenOfType<RoomSubScreen>().Single().UserModsSelectOverlay.State.Value == Visibility.Hidden);
} }
[Test] [Test]

View File

@ -86,7 +86,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
public readonly Room Room; public readonly Room Room;
private readonly bool allowEdit; private readonly bool allowEdit;
private ModSelectOverlay userModsSelectOverlay; internal ModSelectOverlay UserModsSelectOverlay { get; private set; }
[CanBeNull] [CanBeNull]
private IDisposable userModsSelectOverlayRegistration; private IDisposable userModsSelectOverlayRegistration;
@ -236,7 +236,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
} }
}; };
LoadComponent(userModsSelectOverlay = new UserModSelectOverlay(OverlayColourScheme.Plum) LoadComponent(UserModsSelectOverlay = new UserModSelectOverlay(OverlayColourScheme.Plum)
{ {
SelectedMods = { BindTarget = UserMods }, SelectedMods = { BindTarget = UserMods },
IsValidMod = _ => false IsValidMod = _ => false
@ -269,7 +269,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
beatmapAvailabilityTracker.SelectedItem.BindTo(SelectedItem); beatmapAvailabilityTracker.SelectedItem.BindTo(SelectedItem);
beatmapAvailabilityTracker.Availability.BindValueChanged(_ => updateWorkingBeatmap()); beatmapAvailabilityTracker.Availability.BindValueChanged(_ => updateWorkingBeatmap());
userModsSelectOverlayRegistration = overlayManager?.RegisterBlockingOverlay(userModsSelectOverlay); userModsSelectOverlayRegistration = overlayManager?.RegisterBlockingOverlay(UserModsSelectOverlay);
} }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
@ -289,9 +289,9 @@ namespace osu.Game.Screens.OnlinePlay.Match
return base.OnBackButton(); return base.OnBackButton();
} }
if (userModsSelectOverlay.State.Value == Visibility.Visible) if (UserModsSelectOverlay.State.Value == Visibility.Visible)
{ {
userModsSelectOverlay.Hide(); UserModsSelectOverlay.Hide();
return true; return true;
} }
@ -304,7 +304,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
return base.OnBackButton(); return base.OnBackButton();
} }
protected void ShowUserModSelect() => userModsSelectOverlay.Show(); protected void ShowUserModSelect() => UserModsSelectOverlay.Show();
public override void OnEntering(ScreenTransitionEvent e) public override void OnEntering(ScreenTransitionEvent e)
{ {
@ -385,13 +385,13 @@ namespace osu.Game.Screens.OnlinePlay.Match
if (!selected.AllowedMods.Any()) if (!selected.AllowedMods.Any())
{ {
UserModsSection?.Hide(); UserModsSection?.Hide();
userModsSelectOverlay.Hide(); UserModsSelectOverlay.Hide();
userModsSelectOverlay.IsValidMod = _ => false; UserModsSelectOverlay.IsValidMod = _ => false;
} }
else else
{ {
UserModsSection?.Show(); UserModsSection?.Show();
userModsSelectOverlay.IsValidMod = m => allowedMods.Any(a => a.GetType() == m.GetType()); UserModsSelectOverlay.IsValidMod = m => allowedMods.Any(a => a.GetType() == m.GetType());
} }
} }
@ -430,7 +430,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
private void onLeaving() private void onLeaving()
{ {
userModsSelectOverlay.Hide(); UserModsSelectOverlay.Hide();
endHandlingTrack(); endHandlingTrack();
} }