mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:52:57 +08:00
Add failing test case and fix selection assertion
This commit is contained in:
parent
98fe9f32d8
commit
5303023e57
@ -10,12 +10,14 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Overlays.Mods;
|
using osu.Game.Overlays.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Screens.OnlinePlay;
|
using osu.Game.Screens.OnlinePlay;
|
||||||
|
using osu.Game.Utils;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Multiplayer
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
@ -23,6 +25,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
public partial class TestSceneFreeModSelectOverlay : MultiplayerTestScene
|
public partial class TestSceneFreeModSelectOverlay : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
private FreeModSelectOverlay freeModSelectOverlay;
|
private FreeModSelectOverlay freeModSelectOverlay;
|
||||||
|
private FooterButtonFreeMods footerButtonFreeMods;
|
||||||
private readonly Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods = new Bindable<Dictionary<ModType, IReadOnlyList<Mod>>>();
|
private readonly Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods = new Bindable<Dictionary<ModType, IReadOnlyList<Mod>>>();
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -119,11 +122,46 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddAssert("select all button enabled", () => this.ChildrenOfType<SelectAllModsButton>().Single().Enabled.Value);
|
AddAssert("select all button enabled", () => this.ChildrenOfType<SelectAllModsButton>().Single().Enabled.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSelectAllViaFooterButtonThenDeselectFromOverlay()
|
||||||
|
{
|
||||||
|
createFreeModSelect();
|
||||||
|
|
||||||
|
AddAssert("overlay select all button enabled", () => freeModSelectOverlay.ChildrenOfType<SelectAllModsButton>().Single().Enabled.Value);
|
||||||
|
AddAssert("footer button displays off", () => footerButtonFreeMods.ChildrenOfType<IHasText>().Any(t => t.Text == "off"));
|
||||||
|
|
||||||
|
AddStep("click footer select all button", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(footerButtonFreeMods);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("all mods selected", assertAllAvailableModsSelected);
|
||||||
|
AddAssert("footer button displays all", () => footerButtonFreeMods.ChildrenOfType<IHasText>().Any(t => t.Text == "all"));
|
||||||
|
|
||||||
|
AddStep("click deselect all button", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(this.ChildrenOfType<DeselectAllModsButton>().Single());
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
AddUntilStep("all mods deselected", () => !freeModSelectOverlay.SelectedMods.Value.Any());
|
||||||
|
AddAssert("footer button displays off", () => footerButtonFreeMods.ChildrenOfType<IHasText>().Any(t => t.Text == "off"));
|
||||||
|
}
|
||||||
|
|
||||||
private void createFreeModSelect()
|
private void createFreeModSelect()
|
||||||
{
|
{
|
||||||
AddStep("create free mod select screen", () => Child = freeModSelectOverlay = new FreeModSelectOverlay
|
AddStep("create free mod select screen", () => Children = new Drawable[]
|
||||||
{
|
{
|
||||||
State = { Value = Visibility.Visible }
|
freeModSelectOverlay = new FreeModSelectOverlay
|
||||||
|
{
|
||||||
|
State = { Value = Visibility.Visible }
|
||||||
|
},
|
||||||
|
footerButtonFreeMods = new FooterButtonFreeMods(freeModSelectOverlay)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomRight,
|
||||||
|
Origin = Anchor.BottomRight,
|
||||||
|
Current = { BindTarget = freeModSelectOverlay.SelectedMods },
|
||||||
|
},
|
||||||
});
|
});
|
||||||
AddUntilStep("all column content loaded",
|
AddUntilStep("all column content loaded",
|
||||||
() => freeModSelectOverlay.ChildrenOfType<ModColumn>().Any()
|
() => freeModSelectOverlay.ChildrenOfType<ModColumn>().Any()
|
||||||
@ -134,10 +172,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
var allAvailableMods = availableMods.Value
|
var allAvailableMods = availableMods.Value
|
||||||
.Where(pair => pair.Key != ModType.System)
|
.Where(pair => pair.Key != ModType.System)
|
||||||
.SelectMany(pair => pair.Value)
|
.SelectMany(pair => ModUtils.FlattenMods(pair.Value))
|
||||||
.Where(mod => mod.UserPlayable && mod.HasImplementation)
|
.Where(mod => mod.UserPlayable && mod.HasImplementation)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
if (freeModSelectOverlay.SelectedMods.Value.Count != allAvailableMods.Count)
|
||||||
|
return false;
|
||||||
|
|
||||||
foreach (var availableMod in allAvailableMods)
|
foreach (var availableMod in allAvailableMods)
|
||||||
{
|
{
|
||||||
if (freeModSelectOverlay.SelectedMods.Value.All(selectedMod => selectedMod.GetType() != availableMod.GetType()))
|
if (freeModSelectOverlay.SelectedMods.Value.All(selectedMod => selectedMod.GetType() != availableMod.GetType()))
|
||||||
|
Loading…
Reference in New Issue
Block a user