mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 18:42:56 +08:00
Add tests to indicate the issue
This commit is contained in:
parent
0e91e6a155
commit
342c5a5938
@ -2,7 +2,10 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
@ -14,21 +17,34 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
||||||
|
|
||||||
private NewsOverlay news;
|
private NewsOverlay overlay;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp() => Schedule(() => Child = news = new NewsOverlay());
|
public void SetUp() => Schedule(() => Child = overlay = new NewsOverlay());
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestRequest()
|
public void TestRequest()
|
||||||
{
|
{
|
||||||
setUpNewsResponse(responseExample);
|
setUpNewsResponse(responseExample);
|
||||||
AddStep("Show", () => news.Show());
|
AddStep("Show", () => overlay.Show());
|
||||||
AddStep("Show article", () => news.ShowArticle("article"));
|
AddStep("Show article", () => overlay.ShowArticle("article"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpNewsResponse(GetNewsResponse r)
|
[Test]
|
||||||
=> AddStep("set up response", () =>
|
public void TestCursorRequest()
|
||||||
|
{
|
||||||
|
setUpNewsResponse(responseWithCursor, "Set up cursor response");
|
||||||
|
AddStep("Show", () => overlay.Show());
|
||||||
|
AddAssert("Show More button is visible", () => showMoreButton.Alpha == 1);
|
||||||
|
setUpNewsResponse(responseWithNoCursor, "Set up no cursor response");
|
||||||
|
AddStep("Click Show More", () => showMoreButton.Click());
|
||||||
|
AddAssert("Show More button is hidden", () => showMoreButton.Alpha == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ShowMoreButton showMoreButton => overlay.ChildrenOfType<ShowMoreButton>().First();
|
||||||
|
|
||||||
|
private void setUpNewsResponse(GetNewsResponse r, string testName = "Set up response")
|
||||||
|
=> AddStep(testName, () =>
|
||||||
{
|
{
|
||||||
dummyAPI.HandleRequest = request =>
|
dummyAPI.HandleRequest = request =>
|
||||||
{
|
{
|
||||||
@ -40,7 +56,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
private GetNewsResponse responseExample => new GetNewsResponse
|
private static GetNewsResponse responseExample => new GetNewsResponse
|
||||||
{
|
{
|
||||||
NewsPosts = new[]
|
NewsPosts = new[]
|
||||||
{
|
{
|
||||||
@ -62,5 +78,37 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static GetNewsResponse responseWithCursor => new GetNewsResponse
|
||||||
|
{
|
||||||
|
NewsPosts = new[]
|
||||||
|
{
|
||||||
|
new APINewsPost
|
||||||
|
{
|
||||||
|
Title = "This post has an image which starts with \"/\" and has many authors!",
|
||||||
|
Preview = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
|
||||||
|
Author = "someone, someone1, someone2, someone3, someone4",
|
||||||
|
FirstImage = "/help/wiki/shared/news/banners/monthly-beatmapping-contest.png",
|
||||||
|
PublishedAt = DateTimeOffset.Now
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Cursor = new Cursor()
|
||||||
|
};
|
||||||
|
|
||||||
|
private static GetNewsResponse responseWithNoCursor => new GetNewsResponse
|
||||||
|
{
|
||||||
|
NewsPosts = new[]
|
||||||
|
{
|
||||||
|
new APINewsPost
|
||||||
|
{
|
||||||
|
Title = "This post has a full-url image! (HTML entity: &)",
|
||||||
|
Preview = "boom (HTML entity: &)",
|
||||||
|
Author = "user (HTML entity: &)",
|
||||||
|
FirstImage = "https://assets.ppy.sh/artists/88/header.jpg",
|
||||||
|
PublishedAt = DateTimeOffset.Now
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Cursor = null
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user