1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 00:02:54 +08:00

Update framework

This commit is contained in:
Dean Herbert 2019-03-19 17:24:26 +09:00
parent 6f372e7c07
commit def15645f7
23 changed files with 81 additions and 81 deletions

View File

@ -354,9 +354,9 @@ namespace osu.Game.Rulesets.Osu.Tests
judgementResults = new List<JudgementResult>();
});
AddUntilStep(() => Beatmap.Value.Track.CurrentTime == 0, "Beatmap at 0");
AddUntilStep(() => currentPlayer.IsCurrentScreen(), "Wait until player is loaded");
AddUntilStep(() => allJudgedFired, "Wait for all judged");
AddUntilStep("Beatmap at 0", () => Beatmap.Value.Track.CurrentTime == 0);
AddUntilStep("Wait until player is loaded", () => currentPlayer.IsCurrentScreen());
AddUntilStep("Wait for all judged", () => allJudgedFired);
}
private class ScoreAccessibleReplayPlayer : ReplayPlayer

View File

@ -27,8 +27,8 @@ namespace osu.Game.Tests.Visual
protected override void AddCheckSteps(Func<Player> player)
{
base.AddCheckSteps(player);
AddUntilStep(() => ((ScoreAccessiblePlayer)player()).ScoreProcessor.TotalScore.Value > 0, "score above zero");
AddUntilStep(() => ((ScoreAccessiblePlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0), "key counter counted keys");
AddUntilStep("score above zero", () => ((ScoreAccessiblePlayer)player()).ScoreProcessor.TotalScore.Value > 0);
AddUntilStep("key counter counted keys", () => ((ScoreAccessiblePlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
}
private class ScoreAccessiblePlayer : Player

View File

@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual
{
setupUserSettings();
AddStep("Start player loader", () => songSelect.Push(playerLoader = new DimAccessiblePlayerLoader(player = new DimAccessiblePlayer())));
AddUntilStep(() => playerLoader?.IsLoaded ?? false, "Wait for Player Loader to load");
AddUntilStep("Wait for Player Loader to load", () => playerLoader?.IsLoaded ?? false);
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
AddStep("Trigger background preview", () =>
{
@ -220,7 +220,7 @@ namespace osu.Game.Tests.Visual
AddAssert("Screen is undimmed", () => songSelect.IsBackgroundUndimmed());
}
private void waitForDim() => AddWaitStep(5, "Wait for dim");
private void waitForDim() => AddWaitStep("Wait for dim", 5);
private void createFakeStoryboard() => AddStep("Create storyboard", () =>
{
@ -249,14 +249,14 @@ namespace osu.Game.Tests.Visual
Ready = true,
}));
});
AddUntilStep(() => playerLoader.IsLoaded, "Wait for Player Loader to load");
AddUntilStep("Wait for Player Loader to load", () => playerLoader.IsLoaded);
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
AddUntilStep(() => player.IsLoaded, "Wait for player to load");
AddUntilStep("Wait for player to load", () => player.IsLoaded);
}
private void setupUserSettings()
{
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap != null, "Song select has selection");
AddUntilStep("Song select has selection", () => songSelect.Carousel.SelectedBeatmap != null);
AddStep("Set default user settings", () =>
{
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { new OsuModNoFail() });

View File

@ -87,7 +87,7 @@ namespace osu.Game.Tests.Visual
carousel.BeatmapSetsChanged = () => changed = true;
carousel.BeatmapSets = beatmapSets;
});
AddUntilStep(() => changed, "Wait for load");
AddUntilStep("Wait for load", () => changed);
}
private void ensureRandomFetchSuccess() =>
@ -214,7 +214,7 @@ namespace osu.Game.Tests.Visual
checkSelected(3, 2);
AddStep("Un-filter (debounce)", () => carousel.Filter(new FilterCriteria()));
AddUntilStep(() => !carousel.PendingFilterTask, "Wait for debounce");
AddUntilStep("Wait for debounce", () => !carousel.PendingFilterTask);
checkVisibleItemCount(diff: false, count: set_count);
checkVisibleItemCount(diff: true, count: 3);
@ -327,13 +327,13 @@ namespace osu.Game.Tests.Visual
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
checkSelected(1);
AddUntilStep(() =>
AddUntilStep("Remove all", () =>
{
if (!carousel.BeatmapSets.Any()) return true;
carousel.RemoveBeatmapSet(carousel.BeatmapSets.Last());
return false;
}, "Remove all");
});
checkNoSelection();
}

View File

@ -56,11 +56,11 @@ namespace osu.Game.Tests.Visual
// select part is redundant, but wait for load isn't
selectBeatmap(Beatmap.Value.Beatmap);
AddWaitStep(3);
AddWaitStep("wait for select", 3);
AddStep("hide", () => { infoWedge.State = Visibility.Hidden; });
AddWaitStep(3);
AddWaitStep("wait for hide", 3);
AddStep("show", () => { infoWedge.State = Visibility.Visible; });
@ -135,7 +135,7 @@ namespace osu.Game.Tests.Visual
infoWedge.Beatmap = Beatmap.Value = b == null ? Beatmap.Default : new TestWorkingBeatmap(b);
});
AddUntilStep(() => infoWedge.Info != infoBefore, "wait for async load");
AddUntilStep("wait for async load", () => infoWedge.Info != infoBefore);
}
private IBeatmap createTestBeatmap(RulesetInfo ruleset)

View File

@ -90,7 +90,7 @@ namespace osu.Game.Tests.Visual
AddStep("set second channel", () => channelTabControl.Current.Value = channelTabControl.Items.Skip(1).First());
AddAssert("selector tab is inactive", () => !channelTabControl.ChannelSelectorActive.Value);
AddUntilStep(() =>
AddUntilStep("remove all channels", () =>
{
var first = channelTabControl.Items.First();
if (first.Name == "+")
@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual
channelTabControl.RemoveChannel(first);
return false;
}, "remove all channels");
});
AddAssert("selector tab is active", () => channelTabControl.ChannelSelectorActive.Value);
}

View File

@ -159,7 +159,7 @@ namespace osu.Game.Tests.Visual
Scheduler.AddDelayed(() => newLine.Message = new DummyMessage(completeText ?? text), delay);
});
AddUntilStep(() => textContainer.All(line => line.Message is DummyMessage), $"wait for msg #{echoCounter}");
AddUntilStep($"wait for msg #{echoCounter}", () => textContainer.All(line => line.Message is DummyMessage));
}
}

View File

@ -32,9 +32,9 @@ namespace osu.Game.Tests.Visual
var text = holdForMenuButton.Children.OfType<SpriteText>().First();
AddStep("Trigger text fade in", () => InputManager.MoveMouseTo(holdForMenuButton));
AddUntilStep(() => text.IsPresent && !exitAction, "Text visible");
AddUntilStep("Text visible", () => text.IsPresent && !exitAction);
AddStep("Trigger text fade out", () => InputManager.MoveMouseTo(Vector2.One));
AddUntilStep(() => !text.IsPresent && !exitAction, "Text is not visible");
AddUntilStep("Text is not visible", () => !text.IsPresent && !exitAction);
AddStep("Trigger exit action", () =>
{
@ -47,7 +47,7 @@ namespace osu.Game.Tests.Visual
AddAssert("action not triggered", () => !exitAction);
AddStep("Trigger exit action", () => InputManager.PressButton(MouseButton.Left));
AddUntilStep(() => exitAction, $"{nameof(holdForMenuButton.Action)} was triggered");
AddUntilStep($"{nameof(holdForMenuButton.Action)} was triggered", () => exitAction);
}
}
}

View File

@ -49,7 +49,7 @@ namespace osu.Game.Tests.Visual
AddStep("start confirming", () => overlay.Begin());
AddUntilStep(() => fired, "wait until confirmed");
AddUntilStep("wait until confirmed", () => fired);
}
private class TestHoldToConfirmOverlay : ExitConfirmOverlay

View File

@ -59,7 +59,7 @@ namespace osu.Game.Tests.Visual
{
AddStep("move mouse to top left", () => InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.Centre));
AddUntilStep(() => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle, "Wait for all idle");
AddUntilStep("Wait for all idle", () => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle);
AddStep("nudge mouse", () => InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.Centre + new Vector2(1)));
@ -87,7 +87,7 @@ namespace osu.Game.Tests.Visual
AddAssert("check idle", () => !box3.IsIdle);
AddAssert("check idle", () => !box4.IsIdle);
AddUntilStep(() => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle, "Wait for all idle");
AddUntilStep("Wait for all idle", () => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle);
}
[Test]
@ -96,13 +96,13 @@ namespace osu.Game.Tests.Visual
AddStep("move mouse", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre));
AddAssert("check not idle", () => !box1.IsIdle && !box2.IsIdle && !box3.IsIdle && !box4.IsIdle);
AddUntilStep(() => box1.IsIdle, "Wait for idle");
AddUntilStep("Wait for idle", () => box1.IsIdle);
AddAssert("check not idle", () => !box2.IsIdle && !box3.IsIdle && !box4.IsIdle);
AddUntilStep(() => box2.IsIdle, "Wait for idle");
AddUntilStep("Wait for idle", () => box2.IsIdle);
AddAssert("check not idle", () => !box3.IsIdle && !box4.IsIdle);
AddUntilStep(() => box3.IsIdle, "Wait for idle");
AddUntilStep("Wait for idle", () => box3.IsIdle);
AddUntilStep(() => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle, "Wait for all idle");
AddUntilStep("Wait for all idle", () => box1.IsIdle && box2.IsIdle && box3.IsIdle && box4.IsIdle);
}
private class IdleTrackingBox : CompositeDrawable

View File

@ -25,30 +25,30 @@ namespace osu.Game.Tests.Visual
bool logoVisible = false;
AddStep("almost instant display", () => Child = loader = new TestLoader(250));
AddUntilStep(() =>
AddUntilStep("loaded", () =>
{
logoVisible = loader.Logo?.Alpha > 0;
return loader.Logo != null && loader.ScreenLoaded;
}, "loaded");
});
AddAssert("logo not visible", () => !logoVisible);
AddStep("short load", () => Child = loader = new TestLoader(800));
AddUntilStep(() =>
AddUntilStep("loaded", () =>
{
logoVisible = loader.Logo?.Alpha > 0;
return loader.Logo != null && loader.ScreenLoaded;
}, "loaded");
});
AddAssert("logo visible", () => logoVisible);
AddUntilStep(() => loader.Logo?.Alpha == 0, "logo gone");
AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0);
AddStep("longer load", () => Child = loader = new TestLoader(1400));
AddUntilStep(() =>
AddUntilStep("loaded", () =>
{
logoVisible = loader.Logo?.Alpha > 0;
return loader.Logo != null && loader.ScreenLoaded;
}, "loaded");
});
AddAssert("logo visible", () => logoVisible);
AddUntilStep(() => loader.Logo?.Alpha == 0, "logo gone");
AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0);
}
private class TestLoader : Loader

View File

@ -111,7 +111,7 @@ namespace osu.Game.Tests.Visual
settings.ApplyButton.Action.Invoke();
});
AddUntilStep(() => !settings.ErrorText.IsPresent, "error not displayed");
AddUntilStep("error not displayed", () => !settings.ErrorText.IsPresent);
}
private class TestRoomSettings : MatchSettingsOverlay

View File

@ -208,22 +208,22 @@ namespace osu.Game.Tests.Visual
{
checkLabelColor(Color4.White);
selectNext(mod);
AddWaitStep(1, "wait for changing colour");
AddWaitStep("wait for changing colour", 1);
checkLabelColor(colour);
selectPrevious(mod);
AddWaitStep(1, "wait for changing colour");
AddWaitStep("wait for changing colour", 1);
checkLabelColor(Color4.White);
}
private void testRankedText(Mod mod)
{
AddWaitStep(1, "wait for fade");
AddWaitStep("wait for fade", 1);
AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0);
selectNext(mod);
AddWaitStep(1, "wait for fade");
AddWaitStep("wait for fade", 1);
AddAssert("check for unranked", () => modSelect.UnrankedLabel.Alpha != 0);
selectPrevious(mod);
AddWaitStep(1, "wait for fade");
AddWaitStep("wait for fade", 1);
AddAssert("check for ranked", () => modSelect.UnrankedLabel.Alpha == 0);
}

View File

@ -112,10 +112,10 @@ namespace osu.Game.Tests.Visual
createSongSelect();
AddAssert("dummy selected", () => songSelect.CurrentBeatmap == defaultBeatmap);
AddUntilStep(() => songSelect.CurrentBeatmapDetailsBeatmap == defaultBeatmap, "dummy shown on wedge");
AddUntilStep("dummy shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap == defaultBeatmap);
addManyTestMaps();
AddWaitStep(3);
AddWaitStep("wait for select", 3);
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
}
@ -125,7 +125,7 @@ namespace osu.Game.Tests.Visual
{
createSongSelect();
addManyTestMaps();
AddWaitStep(3);
AddWaitStep("wait for add", 3);
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
@ -142,7 +142,7 @@ namespace osu.Game.Tests.Visual
createSongSelect();
changeRuleset(2);
importForRuleset(0);
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap == null, "no selection");
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmap == null);
}
[Test]
@ -152,13 +152,13 @@ namespace osu.Game.Tests.Visual
changeRuleset(2);
importForRuleset(2);
importForRuleset(1);
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap.RulesetID == 2, "has selection");
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.RulesetID == 2);
changeRuleset(1);
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap.RulesetID == 1, "has selection");
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.RulesetID == 1);
changeRuleset(0);
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap == null, "no selection");
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmap == null);
}
[Test]
@ -196,7 +196,7 @@ namespace osu.Game.Tests.Visual
{
createSongSelect();
addManyTestMaps();
AddUntilStep(() => songSelect.Carousel.SelectedBeatmap != null, "has selection");
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
bool startRequested = false;
@ -225,7 +225,7 @@ namespace osu.Game.Tests.Visual
private void createSongSelect()
{
AddStep("create song select", () => LoadScreen(songSelect = new TestSongSelect()));
AddUntilStep(() => songSelect.IsCurrentScreen(), "wait for present");
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen());
}
private void addManyTestMaps()

View File

@ -37,15 +37,15 @@ namespace osu.Game.Tests.Visual
AllowResults = false,
})));
AddUntilStep(() => loader.IsCurrentScreen(), "wait for current");
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
AddUntilStep(() => !loader.IsCurrentScreen(), "wait for no longer current");
AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen());
AddStep("exit loader", () => loader.Exit());
AddUntilStep(() => !loader.IsAlive, "wait for no longer alive");
AddUntilStep("wait for no longer alive", () => !loader.IsAlive);
AddStep("load slow dummy beatmap", () =>
{
@ -61,7 +61,7 @@ namespace osu.Game.Tests.Visual
Scheduler.AddDelayed(() => slow.Ready = true, 5000);
});
AddUntilStep(() => !loader.IsCurrentScreen(), "wait for no longer current");
AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen());
}
protected class SlowLoadPlayer : Player

View File

@ -24,8 +24,8 @@ namespace osu.Game.Tests.Visual
protected override void AddCheckSteps(Func<Player> player)
{
base.AddCheckSteps(player);
AddUntilStep(() => ((ScoreAccessibleReplayPlayer)player()).ScoreProcessor.TotalScore.Value > 0, "score above zero");
AddUntilStep(() => ((ScoreAccessibleReplayPlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0), "key counter counted keys");
AddUntilStep("score above zero", () => ((ScoreAccessibleReplayPlayer)player()).ScoreProcessor.TotalScore.Value > 0);
AddUntilStep("key counter counted keys", () => ((ScoreAccessibleReplayPlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
}
private class ScoreAccessibleReplayPlayer : ReplayPlayer

View File

@ -74,7 +74,7 @@ namespace osu.Game.Tests.Visual
}
private void pushNext() => AddStep(@"push next screen", () => ((TestScreen)screenStack.CurrentScreen).PushNext());
private void waitForCurrent() => AddUntilStep(() => screenStack.CurrentScreen.IsCurrentScreen(), "current screen");
private void waitForCurrent() => AddUntilStep("current screen", () => screenStack.CurrentScreen.IsCurrentScreen());
private abstract class TestScreen : OsuScreen
{

View File

@ -46,23 +46,23 @@ namespace osu.Game.Tests.Visual
Origin = Anchor.TopLeft,
});
AddWaitStep(5);
AddWaitStep("wait some", 5);
AddAssert("ensure not created", () => graph.CreationCount == 0);
AddStep("display values", displayNewValues);
AddWaitStep(5);
AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
AddWaitStep("wait some", 5);
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
AddWaitStep(5);
AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
AddWaitStep("wait some", 5);
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
AddWaitStep(5);
AddUntilStep(() => graph.CreationCount == 1, "wait for creation count");
AddWaitStep("wait some", 5);
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
AddRepeatStep("New Values", displayNewValues, 5);
AddWaitStep(5);
AddWaitStep("wait some", 5);
AddAssert("ensure debounced", () => graph.CreationCount == 2);
}

View File

@ -36,18 +36,18 @@ namespace osu.Game.Tests.Visual
api.Queue(req);
AddStep("load null beatmap", () => beatmapBindable.Value = null);
AddUntilStep(() => backgroundSprite.ChildCount == 1, "wait for cleanup...");
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
AddStep("load imported beatmap", () => beatmapBindable.Value = imported.Beatmaps.First());
AddUntilStep(() => backgroundSprite.ChildCount == 1, "wait for cleanup...");
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
if (api.IsLoggedIn)
{
AddUntilStep(() => req.Result != null, "wait for api response");
AddUntilStep("wait for api response", () => req.Result != null);
AddStep("load online beatmap", () => beatmapBindable.Value = new BeatmapInfo
{
BeatmapSet = req.Result?.ToBeatmapSet(rulesets)
});
AddUntilStep(() => backgroundSprite.ChildCount == 1, "wait for cleanup...");
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
}
else
{

View File

@ -108,7 +108,7 @@ namespace osu.Game.Tests.Visual
private void checkSupporterTag(bool isSupporter)
{
AddUntilStep(() => profile.Header.User != null, "wait for load");
AddUntilStep("wait for load", () => profile.Header.User != null);
if (isSupporter)
AddAssert("is supporter", () => profile.Header.SupporterTag.Alpha == 1);
else

View File

@ -55,7 +55,7 @@ namespace osu.Game.Tests.Visual
AddStep(r.Name, () => p = loadPlayerFor(r));
AddCheckSteps(() => p);
AddUntilStep(() =>
AddUntilStep("no leaked beatmaps", () =>
{
p = null;
@ -65,9 +65,9 @@ namespace osu.Game.Tests.Visual
workingWeakReferences.ForEachAlive(_ => count++);
return count == 1;
}, "no leaked beatmaps");
});
AddUntilStep(() =>
AddUntilStep("no leaked players", () =>
{
GC.Collect();
GC.WaitForPendingFinalizers();
@ -75,14 +75,14 @@ namespace osu.Game.Tests.Visual
playerWeakReferences.ForEachAlive(_ => count++);
return count == 1;
}, "no leaked players");
});
}
}
}
protected virtual void AddCheckSteps(Func<Player> player)
{
AddUntilStep(() => player().IsLoaded, "player loaded");
AddUntilStep("player loaded", () => player().IsLoaded);
}
protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo);

View File

@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.315.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.319.0" />
<PackageReference Include="SharpCompress" Version="0.22.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />

View File

@ -105,8 +105,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.315.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.315.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.319.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.319.0" />
<PackageReference Include="SharpCompress" Version="0.22.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />