2024-05-31 19:20:21 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2024-07-25 13:28:09 +08:00
|
|
|
using osu.Framework.Testing;
|
2024-05-31 19:20:21 +08:00
|
|
|
using osu.Framework.Utils;
|
2024-06-04 21:36:30 +08:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2024-05-31 19:20:21 +08:00
|
|
|
using osu.Game.Overlays;
|
|
|
|
using osu.Game.Screens.OnlinePlay.DailyChallenge;
|
2024-06-04 21:36:30 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.DailyChallenge.Events;
|
2024-05-31 19:20:21 +08:00
|
|
|
using osu.Game.Tests.Resources;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.DailyChallenge
|
|
|
|
{
|
|
|
|
public partial class TestSceneDailyChallengeEventFeed : OsuTestScene
|
|
|
|
{
|
2024-07-25 13:28:09 +08:00
|
|
|
private DailyChallengeEventFeed feed = null!;
|
|
|
|
|
2024-05-31 19:20:21 +08:00
|
|
|
[Cached]
|
|
|
|
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Plum);
|
|
|
|
|
2024-07-25 13:28:09 +08:00
|
|
|
[SetUpSteps]
|
|
|
|
public void SetUpSteps()
|
2024-05-31 19:20:21 +08:00
|
|
|
{
|
|
|
|
AddStep("create content", () => Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = colourProvider.Background4,
|
|
|
|
},
|
|
|
|
feed = new DailyChallengeEventFeed
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2024-07-25 13:24:04 +08:00
|
|
|
Height = 0.3f,
|
2024-05-31 19:20:21 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
}
|
|
|
|
});
|
2024-07-25 13:28:09 +08:00
|
|
|
|
2024-05-31 19:20:21 +08:00
|
|
|
AddSliderStep("adjust width", 0.1f, 1, 1, width =>
|
|
|
|
{
|
|
|
|
if (feed.IsNotNull())
|
|
|
|
feed.Width = width;
|
|
|
|
});
|
2024-07-25 13:24:04 +08:00
|
|
|
AddSliderStep("adjust height", 0.1f, 1, 0.3f, height =>
|
2024-05-31 19:20:21 +08:00
|
|
|
{
|
|
|
|
if (feed.IsNotNull())
|
|
|
|
feed.Height = height;
|
|
|
|
});
|
2024-07-25 13:28:09 +08:00
|
|
|
}
|
2024-05-31 19:20:21 +08:00
|
|
|
|
2024-07-25 13:28:09 +08:00
|
|
|
[Test]
|
|
|
|
public void TestBasicAppearance()
|
|
|
|
{
|
2024-07-25 13:24:04 +08:00
|
|
|
AddRepeatStep("add normal score", () =>
|
2024-05-31 19:20:21 +08:00
|
|
|
{
|
2024-06-04 21:36:30 +08:00
|
|
|
var ev = new NewScoreEvent(1, new APIUser
|
|
|
|
{
|
|
|
|
Id = 2,
|
|
|
|
Username = "peppy",
|
|
|
|
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
|
|
|
}, RNG.Next(1_000_000), null);
|
2024-05-31 19:20:21 +08:00
|
|
|
|
2024-06-04 21:36:30 +08:00
|
|
|
feed.AddNewScore(ev);
|
2024-07-25 13:24:04 +08:00
|
|
|
}, 50);
|
2024-05-31 19:20:21 +08:00
|
|
|
|
2024-07-25 13:24:04 +08:00
|
|
|
AddRepeatStep("add new user best", () =>
|
2024-05-31 19:20:21 +08:00
|
|
|
{
|
2024-06-04 21:36:30 +08:00
|
|
|
var ev = new NewScoreEvent(1, new APIUser
|
|
|
|
{
|
|
|
|
Id = 2,
|
|
|
|
Username = "peppy",
|
|
|
|
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
|
|
|
}, RNG.Next(1_000_000), RNG.Next(11, 1000));
|
|
|
|
|
2024-05-31 19:20:21 +08:00
|
|
|
var testScore = TestResources.CreateTestScoreInfo();
|
|
|
|
testScore.TotalScore = RNG.Next(1_000_000);
|
|
|
|
|
2024-06-04 21:36:30 +08:00
|
|
|
feed.AddNewScore(ev);
|
2024-07-25 13:24:04 +08:00
|
|
|
}, 50);
|
2024-05-31 19:20:21 +08:00
|
|
|
|
2024-07-25 13:24:04 +08:00
|
|
|
AddRepeatStep("add top 10 score", () =>
|
2024-05-31 19:20:21 +08:00
|
|
|
{
|
2024-06-04 21:36:30 +08:00
|
|
|
var ev = new NewScoreEvent(1, new APIUser
|
|
|
|
{
|
|
|
|
Id = 2,
|
|
|
|
Username = "peppy",
|
|
|
|
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
|
|
|
}, RNG.Next(1_000_000), RNG.Next(1, 10));
|
2024-05-31 19:20:21 +08:00
|
|
|
|
2024-06-04 21:36:30 +08:00
|
|
|
feed.AddNewScore(ev);
|
2024-07-25 13:24:04 +08:00
|
|
|
}, 50);
|
2024-05-31 19:20:21 +08:00
|
|
|
}
|
2024-07-25 13:28:09 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestMassAdd()
|
|
|
|
{
|
|
|
|
AddStep("add 1000 scores at once", () =>
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 1000; i++)
|
|
|
|
{
|
|
|
|
var ev = new NewScoreEvent(1, new APIUser
|
|
|
|
{
|
|
|
|
Id = 2,
|
|
|
|
Username = "peppy",
|
|
|
|
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
|
|
|
}, RNG.Next(1_000_000), null);
|
|
|
|
|
|
|
|
feed.AddNewScore(ev);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2024-05-31 19:20:21 +08:00
|
|
|
}
|
|
|
|
}
|