osu/osu.Game.Tests/Visual/Ranking/TestSceneScorePanel.cs

115 lines
3.3 KiB
C#
Raw Normal View History

2020-03-17 07:59:34 +00: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.Graphics;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
namespace osu.Game.Tests.Visual.Ranking
{
public class TestSceneScorePanel : OsuTestScene
{
2020-05-26 07:26:58 +00:00
private ScorePanel panel;
2020-03-17 07:59:34 +00:00
[Test]
public void TestDRank()
{
2020-05-21 09:39:22 +00:00
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.5, Rank = ScoreRank.D };
2020-03-17 07:59:34 +00:00
addPanelStep(score);
}
[Test]
public void TestCRank()
{
2020-05-21 09:39:22 +00:00
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.75, Rank = ScoreRank.C };
2020-03-17 07:59:34 +00:00
addPanelStep(score);
}
[Test]
public void TestBRank()
{
2020-05-21 09:39:22 +00:00
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.85, Rank = ScoreRank.B };
2020-03-17 07:59:34 +00:00
addPanelStep(score);
}
[Test]
public void TestARank()
{
2020-05-21 09:39:22 +00:00
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.925, Rank = ScoreRank.A };
2020-03-17 07:59:34 +00:00
addPanelStep(score);
}
[Test]
public void TestSRank()
{
2020-05-21 09:39:22 +00:00
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.975, Rank = ScoreRank.S };
2020-03-17 07:59:34 +00:00
addPanelStep(score);
}
[Test]
public void TestAlmostSSRank()
{
2020-05-21 09:39:22 +00:00
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.9999, Rank = ScoreRank.S };
2020-03-17 07:59:34 +00:00
addPanelStep(score);
}
[Test]
public void TestSSRank()
{
2020-05-21 09:39:22 +00:00
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 1, Rank = ScoreRank.X };
2020-03-17 07:59:34 +00:00
addPanelStep(score);
}
[Test]
public void TestAllHitResults()
{
2020-05-21 09:39:22 +00:00
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Statistics = { [HitResult.Perfect] = 350, [HitResult.Ok] = 200 } };
2020-03-17 07:59:34 +00:00
addPanelStep(score);
}
2020-05-16 09:22:07 +00:00
[Test]
public void TestContractedPanel()
{
2020-05-21 09:39:22 +00:00
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.925, Rank = ScoreRank.A };
2020-05-16 09:22:07 +00:00
addPanelStep(score, PanelState.Contracted);
}
2020-05-26 07:26:58 +00:00
[Test]
public void TestExpandAndContract()
{
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo) { Accuracy = 0.925, Rank = ScoreRank.A };
addPanelStep(score, PanelState.Contracted);
AddWaitStep("wait for transition", 10);
AddStep("expand panel", () => panel.State = PanelState.Expanded);
AddWaitStep("wait for transition", 10);
AddStep("contract panel", () => panel.State = PanelState.Contracted);
AddWaitStep("wait for transition", 10);
}
2020-05-16 09:22:07 +00:00
private void addPanelStep(ScoreInfo score, PanelState state = PanelState.Expanded) => AddStep("add panel", () =>
2020-03-17 07:59:34 +00:00
{
2020-05-26 07:26:58 +00:00
Child = panel = new ScorePanel(score)
2020-03-17 07:59:34 +00:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2020-05-16 09:22:07 +00:00
State = state
2020-03-17 07:59:34 +00:00
};
});
}
}