mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Merge pull request #22926 from Joehuu/fix-sort-direction-not-resetting
Fix beatmap listing sort direction not resetting when changing criteria
This commit is contained in:
commit
43d7386623
@ -14,10 +14,11 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.BeatmapListing;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public partial class TestSceneBeatmapListingSortTabControl : OsuTestScene
|
||||
public partial class TestSceneBeatmapListingSortTabControl : OsuManualInputManagerTestScene
|
||||
{
|
||||
private readonly BeatmapListingSortTabControl control;
|
||||
|
||||
@ -111,6 +112,29 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
resetUsesCriteriaOnCategory(SortCriteria.Updated, SearchCategory.Mine);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSortDirectionOnCriteriaChange()
|
||||
{
|
||||
AddStep("set category to leaderboard", () => control.Reset(SearchCategory.Leaderboard, false));
|
||||
AddAssert("sort direction is descending", () => control.SortDirection.Value == SortDirection.Descending);
|
||||
|
||||
AddStep("click ranked sort button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(control.TabControl.ChildrenOfType<BeatmapListingSortTabControl.BeatmapTabButton>().Single(s => s.Active.Value));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("sort direction is ascending", () => control.SortDirection.Value == SortDirection.Ascending);
|
||||
|
||||
AddStep("click first inactive sort button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(control.TabControl.ChildrenOfType<BeatmapListingSortTabControl.BeatmapTabButton>().First(s => !s.Active.Value));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("sort direction is descending", () => control.SortDirection.Value == SortDirection.Descending);
|
||||
}
|
||||
|
||||
private void criteriaShowsOnCategory(bool expected, SortCriteria criteria, SearchCategory category)
|
||||
{
|
||||
AddAssert($"{criteria.ToString().ToLowerInvariant()} {(expected ? "shown" : "not shown")} on {category.ToString().ToLowerInvariant()}", () =>
|
||||
|
@ -25,6 +25,8 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
|
||||
if (currentParameters == null)
|
||||
Reset(SearchCategory.Leaderboard, false);
|
||||
|
||||
Current.BindValueChanged(_ => SortDirection.Value = Overlays.SortDirection.Descending);
|
||||
}
|
||||
|
||||
public void Reset(SearchCategory category, bool hasQuery)
|
||||
@ -102,7 +104,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
};
|
||||
}
|
||||
|
||||
private partial class BeatmapTabButton : TabButton
|
||||
public partial class BeatmapTabButton : TabButton
|
||||
{
|
||||
public readonly Bindable<SortDirection> SortDirection = new Bindable<SortDirection>();
|
||||
|
||||
@ -136,7 +138,7 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
|
||||
SortDirection.BindValueChanged(direction =>
|
||||
{
|
||||
icon.Icon = direction.NewValue == Overlays.SortDirection.Ascending ? FontAwesome.Solid.CaretUp : FontAwesome.Solid.CaretDown;
|
||||
icon.Icon = direction.NewValue == Overlays.SortDirection.Ascending && Active.Value ? FontAwesome.Solid.CaretUp : FontAwesome.Solid.CaretDown;
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
}
|
||||
|
||||
protected partial class TabButton : HeaderButton
|
||||
public partial class TabButton : HeaderButton
|
||||
{
|
||||
public readonly BindableBool Active = new BindableBool();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user