mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 06:52:55 +08:00
Merge pull request #24880 from bdach/flaky-scoreboard-test
Fix `TestFriendScore` intermittently failing due to randomness
This commit is contained in:
commit
d18bd2d2ac
@ -3,10 +3,10 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Extensions.PolygonExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -161,10 +161,16 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
int playerNumber = 1;
|
||||
|
||||
AddRepeatStep("add 3 other players", () => createRandomScore(new APIUser { Username = $"Player {playerNumber++}" }), 3);
|
||||
AddUntilStep("there are no pink color score", () => leaderboard.ChildrenOfType<Box>().All(b => b.Colour != Color4Extensions.FromHex("ff549a")));
|
||||
AddUntilStep("no pink color scores",
|
||||
() => leaderboard.ChildrenOfType<Box>().Select(b => ((Colour4)b.Colour).ToHex()),
|
||||
() => Does.Not.Contain("#FF549A"));
|
||||
|
||||
AddRepeatStep("add 3 friend score", () => createRandomScore(friend), 3);
|
||||
AddUntilStep("there are pink color for friend score", () => leaderboard.GetScoreByUsername("my friend").ChildrenOfType<Box>().Any(b => b.Colour == Color4Extensions.FromHex("ff549a")));
|
||||
AddUntilStep("at least one friend score is pink",
|
||||
() => leaderboard.GetAllScoresForUsername("my friend")
|
||||
.SelectMany(score => score.ChildrenOfType<Box>())
|
||||
.Select(b => ((Colour4)b.Colour).ToHex()),
|
||||
() => Does.Contain("#FF549A"));
|
||||
}
|
||||
|
||||
private void addLocalPlayer()
|
||||
@ -208,10 +214,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
return scoreItem != null && scoreItem.ScorePosition == expectedPosition;
|
||||
}
|
||||
|
||||
public GameplayLeaderboardScore GetScoreByUsername(string username)
|
||||
{
|
||||
return Flow.FirstOrDefault(i => i.User?.Username == username);
|
||||
}
|
||||
public IEnumerable<GameplayLeaderboardScore> GetAllScoresForUsername(string username)
|
||||
=> Flow.Where(i => i.User?.Username == username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user