2020-03-17 15:59:34 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-03-17 15:59:34 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
using osu.Game.Screens.Ranking;
|
2021-12-13 15:34:48 +08:00
|
|
|
using osu.Game.Tests.Resources;
|
2020-03-17 15:59:34 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Ranking
|
|
|
|
{
|
|
|
|
public class TestSceneScorePanel : OsuTestScene
|
|
|
|
{
|
2020-05-26 15:26:58 +08:00
|
|
|
private ScorePanel panel;
|
|
|
|
|
2020-03-17 15:59:34 +08:00
|
|
|
[Test]
|
|
|
|
public void TestDRank()
|
|
|
|
{
|
2021-12-13 15:34:48 +08:00
|
|
|
var score = TestResources.CreateTestScoreInfo();
|
|
|
|
score.Accuracy = 0.5;
|
|
|
|
score.Rank = ScoreRank.D;
|
2020-03-17 15:59:34 +08:00
|
|
|
|
|
|
|
addPanelStep(score);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCRank()
|
|
|
|
{
|
2021-12-13 15:34:48 +08:00
|
|
|
var score = TestResources.CreateTestScoreInfo();
|
|
|
|
score.Accuracy = 0.75;
|
|
|
|
score.Rank = ScoreRank.C;
|
2020-03-17 15:59:34 +08:00
|
|
|
|
|
|
|
addPanelStep(score);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBRank()
|
|
|
|
{
|
2021-12-13 15:34:48 +08:00
|
|
|
var score = TestResources.CreateTestScoreInfo();
|
|
|
|
score.Accuracy = 0.85;
|
|
|
|
score.Rank = ScoreRank.B;
|
2020-03-17 15:59:34 +08:00
|
|
|
|
|
|
|
addPanelStep(score);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestARank()
|
|
|
|
{
|
2021-12-13 15:34:48 +08:00
|
|
|
var score = TestResources.CreateTestScoreInfo();
|
|
|
|
score.Accuracy = 0.925;
|
|
|
|
score.Rank = ScoreRank.A;
|
2020-03-17 15:59:34 +08:00
|
|
|
|
|
|
|
addPanelStep(score);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestSRank()
|
|
|
|
{
|
2021-12-13 15:34:48 +08:00
|
|
|
var score = TestResources.CreateTestScoreInfo();
|
|
|
|
score.Accuracy = 0.975;
|
|
|
|
score.Rank = ScoreRank.S;
|
2020-03-17 15:59:34 +08:00
|
|
|
|
|
|
|
addPanelStep(score);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestAlmostSSRank()
|
|
|
|
{
|
2021-12-13 15:34:48 +08:00
|
|
|
var score = TestResources.CreateTestScoreInfo();
|
|
|
|
score.Accuracy = 0.9999;
|
|
|
|
score.Rank = ScoreRank.S;
|
2020-03-17 15:59:34 +08:00
|
|
|
|
|
|
|
addPanelStep(score);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestSSRank()
|
|
|
|
{
|
2021-12-13 15:34:48 +08:00
|
|
|
var score = TestResources.CreateTestScoreInfo();
|
|
|
|
score.Accuracy = 1;
|
|
|
|
score.Rank = ScoreRank.X;
|
2020-03-17 15:59:34 +08:00
|
|
|
|
|
|
|
addPanelStep(score);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestAllHitResults()
|
|
|
|
{
|
2021-12-13 15:34:48 +08:00
|
|
|
var score = TestResources.CreateTestScoreInfo();
|
|
|
|
score.Statistics[HitResult.Perfect] = 350;
|
|
|
|
score.Statistics[HitResult.Ok] = 200;
|
2020-03-17 15:59:34 +08:00
|
|
|
|
|
|
|
addPanelStep(score);
|
|
|
|
}
|
|
|
|
|
2020-05-16 17:22:07 +08:00
|
|
|
[Test]
|
|
|
|
public void TestContractedPanel()
|
|
|
|
{
|
2021-12-13 15:34:48 +08:00
|
|
|
var score = TestResources.CreateTestScoreInfo();
|
|
|
|
score.Accuracy = 0.925;
|
|
|
|
score.Rank = ScoreRank.A;
|
2020-05-16 17:22:07 +08:00
|
|
|
|
|
|
|
addPanelStep(score, PanelState.Contracted);
|
|
|
|
}
|
|
|
|
|
2020-05-26 15:26:58 +08:00
|
|
|
[Test]
|
|
|
|
public void TestExpandAndContract()
|
|
|
|
{
|
2021-12-13 15:34:48 +08:00
|
|
|
var score = TestResources.CreateTestScoreInfo();
|
|
|
|
score.Accuracy = 0.925;
|
|
|
|
score.Rank = ScoreRank.A;
|
2020-05-26 15:26:58 +08:00
|
|
|
|
|
|
|
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 17:22:07 +08:00
|
|
|
private void addPanelStep(ScoreInfo score, PanelState state = PanelState.Expanded) => AddStep("add panel", () =>
|
2020-03-17 15:59:34 +08:00
|
|
|
{
|
2020-10-29 15:11:25 +08:00
|
|
|
Child = panel = new ScorePanel(score, true)
|
2020-03-17 15:59:34 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2020-05-16 17:22:07 +08:00
|
|
|
State = state
|
2020-03-17 15:59:34 +08:00
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|