mirror of
https://github.com/osukey/osukey.git
synced 2025-05-31 10:27:26 +09:00
Fix test failures by waiting for panel load
This commit is contained in:
parent
42b27e3050
commit
6cc972aa6a
@ -54,17 +54,20 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestMultiSelection()
|
public void TestMultiSelection()
|
||||||
{
|
{
|
||||||
|
ModColumn column = null;
|
||||||
AddStep("create content", () => Child = new Container
|
AddStep("create content", () => Child = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding(30),
|
Padding = new MarginPadding(30),
|
||||||
Child = new ModColumn(ModType.DifficultyIncrease, true)
|
Child = column = new ModColumn(ModType.DifficultyIncrease, true)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre
|
Origin = Anchor.Centre
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for panel load", () => column.IsLoaded && column.ItemsLoaded);
|
||||||
|
|
||||||
clickToggle();
|
clickToggle();
|
||||||
AddUntilStep("all panels selected", () => this.ChildrenOfType<ModPanel>().All(panel => panel.Active.Value));
|
AddUntilStep("all panels selected", () => this.ChildrenOfType<ModPanel>().All(panel => panel.Active.Value));
|
||||||
|
|
||||||
@ -140,13 +143,15 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding(30),
|
Padding = new MarginPadding(30),
|
||||||
Child = column = new ModColumn(ModType.DifficultyReduction, true, new Key[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P })
|
Child = column = new ModColumn(ModType.DifficultyReduction, true, new[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P })
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre
|
Origin = Anchor.Centre
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for panel load", () => column.IsLoaded && column.ItemsLoaded);
|
||||||
|
|
||||||
AddStep("press W", () => InputManager.Key(Key.W));
|
AddStep("press W", () => InputManager.Key(Key.W));
|
||||||
AddAssert("NF panel selected", () => this.ChildrenOfType<ModPanel>().Single(panel => panel.Mod.Acronym == "NF").Active.Value);
|
AddAssert("NF panel selected", () => this.ChildrenOfType<ModPanel>().Single(panel => panel.Mod.Acronym == "NF").Active.Value);
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -56,6 +57,9 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private Colour4 accentColour;
|
private Colour4 accentColour;
|
||||||
|
|
||||||
|
private Task? latestLoadTask;
|
||||||
|
internal bool ItemsLoaded => latestLoadTask == null;
|
||||||
|
|
||||||
private const float header_height = 42;
|
private const float header_height = 42;
|
||||||
|
|
||||||
public ModColumn(ModType modType, bool allowBulkSelection, Key[]? toggleKeys = null)
|
public ModColumn(ModType modType, bool allowBulkSelection, Key[]? toggleKeys = null)
|
||||||
@ -234,7 +238,9 @@ namespace osu.Game.Overlays.Mods
|
|||||||
Shear = new Vector2(-ModPanel.SHEAR_X, 0)
|
Shear = new Vector2(-ModPanel.SHEAR_X, 0)
|
||||||
});
|
});
|
||||||
|
|
||||||
LoadComponentsAsync(panels, loaded =>
|
Task? loadTask;
|
||||||
|
|
||||||
|
latestLoadTask = loadTask = LoadComponentsAsync(panels, loaded =>
|
||||||
{
|
{
|
||||||
panelFlow.ChildrenEnumerable = loaded;
|
panelFlow.ChildrenEnumerable = loaded;
|
||||||
|
|
||||||
@ -244,6 +250,11 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
updateFilter();
|
updateFilter();
|
||||||
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
|
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
|
||||||
|
loadTask.ContinueWith(_ =>
|
||||||
|
{
|
||||||
|
if (loadTask == latestLoadTask)
|
||||||
|
latestLoadTask = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Bulk select / deselect
|
#region Bulk select / deselect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user