mirror of
https://github.com/ppy/osu
synced 2025-03-22 19:06:58 +00:00
Update test scene to allow seeing loading spinner
This commit is contained in:
parent
e43c8e84b0
commit
00d8398056
@ -4,6 +4,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -78,11 +80,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ManualResetEventSlim deletionPerformed = new ManualResetEventSlim();
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDeletion()
|
public void TestDeletion()
|
||||||
{
|
{
|
||||||
DrawableComment? ourComment = null;
|
DrawableComment? ourComment = null;
|
||||||
bool delete = false;
|
|
||||||
|
|
||||||
addTestComments();
|
addTestComments();
|
||||||
AddUntilStep("Comment exists", () =>
|
AddUntilStep("Comment exists", () =>
|
||||||
@ -102,6 +105,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
});
|
});
|
||||||
AddStep("Setup request handling", () =>
|
AddStep("Setup request handling", () =>
|
||||||
{
|
{
|
||||||
|
deletionPerformed.Reset();
|
||||||
|
|
||||||
dummyAPI.HandleRequest = request =>
|
dummyAPI.HandleRequest = request =>
|
||||||
{
|
{
|
||||||
if (!(request is CommentDeleteRequest req))
|
if (!(request is CommentDeleteRequest req))
|
||||||
@ -130,18 +135,23 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
IncludedComments = new List<Comment>(),
|
IncludedComments = new List<Comment>(),
|
||||||
PinnedComments = new List<Comment>(),
|
PinnedComments = new List<Comment>(),
|
||||||
};
|
};
|
||||||
delete = true;
|
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
deletionPerformed.Wait(10000);
|
||||||
req.TriggerSuccess(cb);
|
req.TriggerSuccess(cb);
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
AddStep("Confirm dialog", () => InputManager.Key(Key.Number1));
|
AddStep("Confirm dialog", () => InputManager.Key(Key.Number1));
|
||||||
AddUntilStep("Deletion requested", () => delete);
|
|
||||||
AddAssert("Loading spinner shown", () => commentsContainer.ChildrenOfType<LoadingSpinner>().Any(d => d.IsPresent));
|
AddAssert("Loading spinner shown", () => commentsContainer.ChildrenOfType<LoadingSpinner>().Any(d => d.IsPresent));
|
||||||
AddUntilStep("Comment is deleted locally", () =>
|
|
||||||
{
|
AddStep("Complete request", () => deletionPerformed.Set());
|
||||||
return this.ChildrenOfType<DrawableComment>().Single(x => x.Comment.Id == 1).WasDeleted;
|
|
||||||
});
|
AddUntilStep("Comment is deleted locally", () => this.ChildrenOfType<DrawableComment>().Single(x => x.Comment.Id == 1).WasDeleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
Loading…
Reference in New Issue
Block a user