Skip to content

Commit

Permalink
Reorder tests for testability
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jul 13, 2023
1 parent 654a705 commit 6ef39b8
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,30 @@ public void TestScaling()
}));
}

[TestCase(1, ScoreRank.X)]
[TestCase(0.9999, ScoreRank.S)]
[TestCase(0.975, ScoreRank.S)]
[TestCase(0.925, ScoreRank.A)]
[TestCase(0.85, ScoreRank.B)]
[TestCase(0.75, ScoreRank.C)]
[TestCase(0.5, ScoreRank.D)]
[TestCase(0.2, ScoreRank.D)]
public void TestResultsWithPlayer(double accuracy, ScoreRank rank)
{
TestResultsScreen screen = null;

var score = TestResources.CreateTestScoreInfo();

score.OnlineID = 1234;
score.HitEvents = TestSceneStatisticsPanel.CreatePositionDistributedHitEvents();
score.Accuracy = accuracy;
score.Rank = rank;

loadResultsScreen(() => screen = createResultsScreen(score));
AddUntilStep("wait for loaded", () => screen.IsLoaded);
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
}

[Test]
public void TestResultsWithoutPlayer()
{
Expand All @@ -83,37 +107,13 @@ public void TestResultsWithoutPlayer()
};
var score = TestResources.CreateTestScoreInfo();
score.OnlineID = 1234;
score.HitEvents = TestSceneStatisticsPanel.CreatePositionDistributedHitEvents();
stack.Push(screen = createResultsScreen(score));
});
AddUntilStep("wait for loaded", () => screen.IsLoaded);
AddAssert("retry overlay not present", () => screen.RetryOverlay == null);
}

[TestCase(0.2, ScoreRank.D)]
[TestCase(0.5, ScoreRank.D)]
[TestCase(0.75, ScoreRank.C)]
[TestCase(0.85, ScoreRank.B)]
[TestCase(0.925, ScoreRank.A)]
[TestCase(0.975, ScoreRank.S)]
[TestCase(0.9999, ScoreRank.S)]
[TestCase(1, ScoreRank.X)]
public void TestResultsWithPlayer(double accuracy, ScoreRank rank)
{
TestResultsScreen screen = null;

var score = TestResources.CreateTestScoreInfo();

score.Accuracy = accuracy;
score.Rank = rank;

loadResultsScreen(() => screen = createResultsScreen(score));
AddUntilStep("wait for loaded", () => screen.IsLoaded);
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
}

[Test]
public void TestResultsForUnranked()
{
Expand Down Expand Up @@ -332,13 +332,14 @@ public TestResultsContainer(IScreen screen)
}
}

private partial class TestResultsScreen : ResultsScreen
private partial class TestResultsScreen : SoloResultsScreen
{
public HotkeyRetryOverlay RetryOverlay;

public TestResultsScreen(ScoreInfo score)
: base(score, true)
{
ShowUserStatistics = true;
}

protected override void LoadComplete()
Expand Down

0 comments on commit 6ef39b8

Please sign in to comment.