mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 19:22:56 +08:00
Fix SelectAllModsButton
state doesn’t update when search term changed
This commit is contained in:
parent
71e6f80c40
commit
ba7069df34
@ -8,6 +8,7 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Testing;
|
||||
@ -57,6 +58,29 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("customisation area not expanded", () => this.ChildrenOfType<ModSettingsArea>().Single().Height == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectAllButtonUpdatesStateWhenSearchTermChanged()
|
||||
{
|
||||
createFreeModSelect();
|
||||
|
||||
AddStep("apply search term", () => freeModSelectOverlay.SearchTerm = "ea");
|
||||
|
||||
AddAssert("select all button enabled", () => this.ChildrenOfType<SelectAllModsButton>().Single().Enabled.Value);
|
||||
|
||||
AddStep("click select all button", navigateAndClick<SelectAllModsButton>);
|
||||
AddAssert("select all button disabled", () => !this.ChildrenOfType<SelectAllModsButton>().Single().Enabled.Value);
|
||||
|
||||
AddStep("change search term", () => freeModSelectOverlay.SearchTerm = "e");
|
||||
|
||||
AddAssert("select all button enabled", () => this.ChildrenOfType<SelectAllModsButton>().Single().Enabled.Value);
|
||||
|
||||
void navigateAndClick<T>() where T : Drawable
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<T>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectDeselectAllViaKeyboard()
|
||||
{
|
||||
|
@ -17,6 +17,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
private readonly Bindable<IReadOnlyList<Mod>> selectedMods = new Bindable<IReadOnlyList<Mod>>();
|
||||
private readonly Bindable<Dictionary<ModType, IReadOnlyList<ModState>>> availableMods = new Bindable<Dictionary<ModType, IReadOnlyList<ModState>>>();
|
||||
private readonly Bindable<string> searchTerm = new Bindable<string>();
|
||||
|
||||
public SelectAllModsButton(FreeModSelectOverlay modSelectOverlay)
|
||||
: base(ModSelectOverlay.BUTTON_WIDTH)
|
||||
@ -26,6 +27,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
selectedMods.BindTo(modSelectOverlay.SelectedMods);
|
||||
availableMods.BindTo(modSelectOverlay.AvailableMods);
|
||||
searchTerm.BindTo(modSelectOverlay.SearchTextBox.Current);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -34,6 +36,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
selectedMods.BindValueChanged(_ => Scheduler.AddOnce(updateEnabledState));
|
||||
availableMods.BindValueChanged(_ => Scheduler.AddOnce(updateEnabledState));
|
||||
searchTerm.BindValueChanged(_ => Scheduler.AddOnce(updateEnabledState));
|
||||
updateEnabledState();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user