Fix test failures

This commit is contained in:
ansel 2022-09-27 22:40:53 +03:00
parent 5282c8b8c6
commit 4013c96ca5
4 changed files with 33 additions and 12 deletions

View File

@ -34,9 +34,9 @@ namespace osu.Game.Tests.Visual.Online
[SetUpSteps] [SetUpSteps]
public void SetUp() public void SetUp()
{ {
API.Login("test", "test");
Schedule(() => Schedule(() =>
{ {
API.Login("test", "test");
if (dialogOverlay.Parent != null) Remove(dialogOverlay, false); if (dialogOverlay.Parent != null) Remove(dialogOverlay, false);
Children = new Container<Drawable>[] Children = new Container<Drawable>[]
{ {
@ -55,11 +55,11 @@ namespace osu.Game.Tests.Visual.Online
{ {
addTestComments(); addTestComments();
AddAssert("First comment has button", () => AddUntilStep("First comment has button", () =>
{ {
var comments = this.ChildrenOfType<DrawableComment>(); var comments = this.ChildrenOfType<DrawableComment>();
var ourComment = comments.Single(x => x.Comment.Id == 1); var ourComment = comments.SingleOrDefault(x => x.Comment.Id == 1);
return ourComment.ChildrenOfType<OsuSpriteText>().Any(x => x.Text == "Delete"); return ourComment != null && ourComment.ChildrenOfType<OsuSpriteText>().Any(x => x.Text == "Delete");
}); });
AddAssert("Second doesn't", () => AddAssert("Second doesn't", () =>
@ -73,14 +73,15 @@ namespace osu.Game.Tests.Visual.Online
[Test] [Test]
public void TestDeletion() public void TestDeletion()
{ {
DrawableComment ourComment = null!; DrawableComment? ourComment = null;
bool delete = false; bool delete = false;
addTestComments(); addTestComments();
AddStep("Comment exists", () => AddUntilStep("Comment exists", () =>
{ {
var comments = this.ChildrenOfType<DrawableComment>(); var comments = this.ChildrenOfType<DrawableComment>();
ourComment = comments.Single(x => x.Comment.Id == 1); ourComment = comments.SingleOrDefault(x => x.Comment.Id == 1);
return ourComment != null;
}); });
AddStep("It has delete button", () => AddStep("It has delete button", () =>
{ {

View File

@ -25,17 +25,27 @@ namespace osu.Game.Tests.Visual.Online
[Cached] [Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
[Cached]
private readonly DialogOverlay dialogOverlay = new DialogOverlay();
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API; private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
private CommentsContainer commentsContainer; private CommentsContainer commentsContainer;
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
Child = new BasicScrollContainer {
if (dialogOverlay.Parent != null) Remove(dialogOverlay, false);
Children = new Drawable[]
{ {
RelativeSizeAxes = Axes.Both, new BasicScrollContainer
Child = commentsContainer = new CommentsContainer() {
}); RelativeSizeAxes = Axes.Both,
Child = commentsContainer = new CommentsContainer()
},
dialogOverlay
};
});
[Test] [Test]
public void TestIdleState() public void TestIdleState()
@ -139,7 +149,7 @@ namespace osu.Game.Tests.Visual.Online
}; };
}); });
private CommentBundle getExampleComments(bool withPinned = false) private static CommentBundle getExampleComments(bool withPinned = false)
{ {
var bundle = new CommentBundle var bundle = new CommentBundle
{ {

View File

@ -20,11 +20,15 @@ namespace osu.Game.Tests.Visual.Online
[Cached] [Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
[Cached]
private readonly DialogOverlay dialogOverlay = new DialogOverlay();
private Container container; private Container container;
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {
if (dialogOverlay.Parent != null) Remove(dialogOverlay, false);
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new Box
@ -37,6 +41,7 @@ namespace osu.Game.Tests.Visual.Online
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
}, },
dialogOverlay
}; };
}); });

View File

@ -24,17 +24,22 @@ namespace osu.Game.Tests.Visual.Online
[Cached] [Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
[Cached]
private readonly DialogOverlay dialogOverlay = new DialogOverlay();
private TestCommentsContainer comments; private TestCommentsContainer comments;
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {
if (dialogOverlay.Parent != null) Remove(dialogOverlay, false);
Clear(); Clear();
Add(new BasicScrollContainer Add(new BasicScrollContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = comments = new TestCommentsContainer() Child = comments = new TestCommentsContainer()
}); });
Add(dialogOverlay);
}); });
[Test] [Test]