mirror of
https://github.com/ppy/osu
synced 2024-12-23 23:33:36 +00:00
Fix testing
This commit is contained in:
parent
7422b5285c
commit
a226caff56
@ -203,7 +203,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddUntilStep("mod select contains only double time mod",
|
||||
() => this.ChildrenOfType<RoomSubScreen>().Single().UserModsSelectOverlay
|
||||
.ChildrenOfType<ModPanel>()
|
||||
.SingleOrDefault(panel => panel.MatchingFilter)?.Mod is OsuModDoubleTime);
|
||||
.SingleOrDefault(panel => panel.IsValid)?.Mod is OsuModDoubleTime);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -106,26 +106,26 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
});
|
||||
|
||||
AddStep("set filter", () => setFilter(mod => mod.Name.Contains("Wind", StringComparison.CurrentCultureIgnoreCase)));
|
||||
AddUntilStep("two panels visible", () => column.ChildrenOfType<ModPanel>().Count(panel => panel.MatchingFilter) == 2);
|
||||
AddUntilStep("two panels visible", () => column.ChildrenOfType<ModPanel>().Count(panel => panel.IsValid) == 2);
|
||||
|
||||
clickToggle();
|
||||
AddUntilStep("wait for animation", () => !column.SelectionAnimationRunning);
|
||||
AddAssert("only visible items selected", () => column.ChildrenOfType<ModPanel>().Where(panel => panel.Active.Value).All(panel => panel.MatchingFilter));
|
||||
AddAssert("only visible items selected", () => column.ChildrenOfType<ModPanel>().Where(panel => panel.Active.Value).All(panel => panel.IsValid));
|
||||
|
||||
AddStep("unset filter", () => setFilter(null));
|
||||
AddUntilStep("all panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => panel.MatchingFilter));
|
||||
AddUntilStep("all panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => panel.IsValid));
|
||||
AddAssert("checkbox not selected", () => !column.ChildrenOfType<OsuCheckbox>().Single().Current.Value);
|
||||
|
||||
AddStep("set filter", () => setFilter(mod => mod.Name.Contains("Wind", StringComparison.CurrentCultureIgnoreCase)));
|
||||
AddUntilStep("two panels visible", () => column.ChildrenOfType<ModPanel>().Count(panel => panel.MatchingFilter) == 2);
|
||||
AddUntilStep("two panels visible", () => column.ChildrenOfType<ModPanel>().Count(panel => panel.IsValid) == 2);
|
||||
AddAssert("checkbox selected", () => column.ChildrenOfType<OsuCheckbox>().Single().Current.Value);
|
||||
|
||||
AddStep("filter out everything", () => setFilter(_ => false));
|
||||
AddUntilStep("no panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => !panel.MatchingFilter));
|
||||
AddUntilStep("no panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => !panel.IsValid));
|
||||
AddUntilStep("checkbox hidden", () => !column.ChildrenOfType<OsuCheckbox>().Single().IsPresent);
|
||||
|
||||
AddStep("inset filter", () => setFilter(null));
|
||||
AddUntilStep("all panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => panel.MatchingFilter));
|
||||
AddUntilStep("all panels visible", () => column.ChildrenOfType<ModPanel>().All(panel => panel.IsValid));
|
||||
AddUntilStep("checkbox visible", () => column.ChildrenOfType<OsuCheckbox>().Single().IsPresent);
|
||||
|
||||
void clickToggle() => AddStep("click toggle", () =>
|
||||
@ -291,7 +291,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
private void setFilter(Func<Mod, bool>? filter)
|
||||
{
|
||||
foreach (var modState in this.ChildrenOfType<ModColumn>().Single().AvailableMods)
|
||||
modState.MatchingFilter.Value = filter?.Invoke(modState.Mod) ?? true;
|
||||
modState.ValidForSelection.Value = filter?.Invoke(modState.Mod) ?? true;
|
||||
}
|
||||
|
||||
private partial class TestModColumn : ModColumn
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Mods.Input
|
||||
if (!mod_type_lookup.TryGetValue(e.Key, out var typesToMatch))
|
||||
return false;
|
||||
|
||||
var matchingMods = availableMods.Where(modState => matches(modState, typesToMatch) && modState.MatchingFilter.Value).ToArray();
|
||||
var matchingMods = availableMods.Where(modState => matches(modState, typesToMatch) && modState.IsValid).ToArray();
|
||||
|
||||
if (matchingMods.Length == 0)
|
||||
return false;
|
||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Mods.Input
|
||||
if (index < 0)
|
||||
return false;
|
||||
|
||||
var modState = availableMods.Where(modState => modState.MatchingFilter.Value).ElementAtOrDefault(index);
|
||||
var modState = availableMods.Where(modState => modState.IsValid).ElementAtOrDefault(index);
|
||||
if (modState == null)
|
||||
return false;
|
||||
|
||||
|
@ -146,12 +146,12 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
Alpha = availableMods.All(mod => !mod.MatchingFilter.Value || !mod.ValidForSelection.Value) ? 0 : 1;
|
||||
Alpha = availableMods.All(mod => !mod.IsValid) ? 0 : 1;
|
||||
|
||||
if (toggleAllCheckbox != null && !SelectionAnimationRunning)
|
||||
{
|
||||
toggleAllCheckbox.Alpha = availableMods.Any(panel => panel.MatchingFilter.Value) ? 1 : 0;
|
||||
toggleAllCheckbox.Current.Value = availableMods.Where(panel => panel.MatchingFilter.Value).All(panel => panel.Active.Value);
|
||||
toggleAllCheckbox.Alpha = availableMods.Any(panel => panel.IsValid) ? 1 : 0;
|
||||
toggleAllCheckbox.Current.Value = availableMods.Where(panel => panel.IsValid).All(panel => panel.Active.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
pendingSelectionOperations.Clear();
|
||||
|
||||
foreach (var button in availableMods.Where(b => !b.Active.Value && b.MatchingFilter.Value))
|
||||
foreach (var button in availableMods.Where(b => !b.Active.Value && b.IsValid))
|
||||
pendingSelectionOperations.Enqueue(() => button.Active.Value = true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user