1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 19:43:22 +08:00

Allow null score

This commit is contained in:
smoogipoo 2020-05-28 20:46:17 +09:00
parent 9928bff664
commit a55ce26130
2 changed files with 42 additions and 3 deletions

View File

@ -9,10 +9,11 @@ using osu.Framework.Utils;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Ranking namespace osu.Game.Tests.Visual.Ranking
{ {
public class TestSceneScorePanelList : OsuTestScene public class TestSceneScorePanelList : OsuManualInputManagerTestScene
{ {
private ScoreInfo initialScore; private ScoreInfo initialScore;
private ScorePanelList list; private ScorePanelList list;
@ -72,6 +73,41 @@ namespace osu.Game.Tests.Visual.Ranking
assertPanelCentred(); assertPanelCentred();
} }
[Test]
public void TestNullScore()
{
AddStep("create panel with null score", () =>
{
Child = list = new ScorePanelList(null)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
});
AddStep("add many panels", () =>
{
for (int i = 0; i < 20; i++)
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo) { TotalScore = initialScore.TotalScore - i - 1 });
for (int i = 0; i < 20; i++)
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo) { TotalScore = initialScore.TotalScore + i + 1 });
});
AddWaitStep("wait for panel animation", 5);
AddAssert("no panel selected", () => list.ChildrenOfType<ScorePanel>().All(p => p.State != PanelState.Expanded));
AddStep("expand second panel", () =>
{
var expandedPanel = list.ChildrenOfType<ScorePanel>().OrderBy(p => p.DrawPosition.X).ElementAt(1);
InputManager.MoveMouseTo(expandedPanel);
InputManager.Click(MouseButton.Left);
});
assertPanelCentred();
}
private void assertPanelCentred() => AddUntilStep("expanded panel centred", () => private void assertPanelCentred() => AddUntilStep("expanded panel centred", () =>
{ {
var expandedPanel = list.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded); var expandedPanel = list.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);

View File

@ -45,8 +45,11 @@ namespace osu.Game.Screens.Ranking
} }
}; };
AddScore(initialScore); if (initialScore != null)
presentScore(initialScore); {
AddScore(initialScore);
presentScore(initialScore);
}
} }
/// <summary> /// <summary>