mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 17:37:23 +09:00
Simplify popover hide logic and add test coverage
This commit is contained in:
parent
64cf9b702e
commit
c6bc95767d
@ -52,6 +52,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("room join password correct", () => lastJoinedPassword == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPopoverHidesOnLeavingScreen()
|
||||
{
|
||||
AddStep("add room", () => RoomManager.AddRooms(1, withPassword: true));
|
||||
AddStep("select room", () => InputManager.Key(Key.Down));
|
||||
AddStep("attempt join room", () => InputManager.Key(Key.Enter));
|
||||
|
||||
AddUntilStep("password prompt appeared", () => InputManager.ChildrenOfType<DrawableRoom.PasswordEntryPopover>().Any());
|
||||
AddStep("exit screen", () => Stack.Exit());
|
||||
AddUntilStep("password prompt hidden", () => !InputManager.ChildrenOfType<DrawableRoom.PasswordEntryPopover>().Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestJoinRoomWithPassword()
|
||||
{
|
||||
|
@ -7,7 +7,6 @@ using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -239,11 +238,5 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
if (roomManager != null)
|
||||
roomManager.RoomsUpdated -= updateSorting;
|
||||
}
|
||||
|
||||
public void HideAnyPopovers()
|
||||
{
|
||||
// must be called on a child of the PopoverContainer due to parent traversal not considering self.
|
||||
roomFlow.HidePopover();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
@ -151,24 +152,29 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
onReturning();
|
||||
}
|
||||
|
||||
private void onReturning()
|
||||
{
|
||||
filter.HoldFocus = true;
|
||||
}
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
{
|
||||
filter.HoldFocus = false;
|
||||
onLeaving();
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
{
|
||||
onLeaving();
|
||||
base.OnSuspending(next);
|
||||
}
|
||||
|
||||
private void onReturning()
|
||||
{
|
||||
filter.HoldFocus = true;
|
||||
}
|
||||
|
||||
private void onLeaving()
|
||||
{
|
||||
filter.HoldFocus = false;
|
||||
|
||||
// ensure any password prompt is dismissed.
|
||||
roomsContainer.HideAnyPopovers();
|
||||
this.HidePopover();
|
||||
}
|
||||
|
||||
public void Join(Room room, string password)
|
||||
|
Loading…
x
Reference in New Issue
Block a user