From 525026e7f09d788f5abdce40b546b0c7617569d5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 8 Sep 2020 13:23:50 +0900 Subject: [PATCH] Fix tests failing due to timings --- .../TestSceneManageCollectionsDialog.cs | 26 ++++++++++++------- .../SongSelect/TestSceneFilterControl.cs | 1 - 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs b/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs index 2d6f8abd8b..fdaded6a5c 100644 --- a/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs +++ b/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs @@ -19,30 +19,30 @@ namespace osu.Game.Tests.Visual.Collections { public class TestSceneManageCollectionsDialog : OsuManualInputManagerTestScene { - [Cached] - private readonly DialogOverlay dialogOverlay; - protected override Container Content => content; private readonly Container content; + private readonly DialogOverlay dialogOverlay; + private readonly BeatmapCollectionManager manager; - private BeatmapCollectionManager manager; private ManageCollectionsDialog dialog; public TestSceneManageCollectionsDialog() { base.Content.AddRange(new Drawable[] { + manager = new BeatmapCollectionManager(LocalStorage), content = new Container { RelativeSizeAxes = Axes.Both }, dialogOverlay = new DialogOverlay() }); } - [BackgroundDependencyLoader] - private void load() + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { - Dependencies.Cache(manager = new BeatmapCollectionManager(LocalStorage)); - Add(manager); + var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); + dependencies.Cache(manager); + dependencies.Cache(dialogOverlay); + return dependencies; } [SetUp] @@ -120,6 +120,8 @@ public void TestRemoveCollectionViaButton() new BeatmapCollection { Name = { Value = "2" } }, })); + assertCollectionCount(2); + AddStep("click first delete button", () => { InputManager.MoveMouseTo(dialog.ChildrenOfType().First(), new Vector2(5, 0)); @@ -146,6 +148,8 @@ public void TestCollectionNotRemovedWhenDialogCancelled() new BeatmapCollection { Name = { Value = "2" } }, })); + assertCollectionCount(2); + AddStep("click first delete button", () => { InputManager.MoveMouseTo(dialog.ChildrenOfType().First(), new Vector2(5, 0)); @@ -185,14 +189,16 @@ public void TestCollectionRenamedOnTextChange() new BeatmapCollection { Name = { Value = "2" } }, })); + assertCollectionCount(2); + AddStep("change first collection name", () => dialog.ChildrenOfType().First().Text = "First"); AddAssert("collection has new name", () => manager.Collections[0].Name.Value == "First"); } private void assertCollectionCount(int count) - => AddAssert($"{count} collections shown", () => dialog.ChildrenOfType().Count() == count); + => AddUntilStep($"{count} collections shown", () => dialog.ChildrenOfType().Count() == count); private void assertCollectionName(int index, string name) - => AddAssert($"item {index + 1} has correct name", () => dialog.ChildrenOfType().ElementAt(index).ChildrenOfType().First().Text == name); + => AddUntilStep($"item {index + 1} has correct name", () => dialog.ChildrenOfType().ElementAt(index).ChildrenOfType().First().Text == name); } } diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs index c2dd652b3a..dea1c4b9b4 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneFilterControl.cs @@ -26,7 +26,6 @@ public class TestSceneFilterControl : OsuManualInputManagerTestScene protected override Container Content => content; private readonly Container content; - [Cached] private readonly BeatmapCollectionManager collectionManager; private RulesetStore rulesets;