mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Merge pull request #24203 from peppy/results-screen-testability
Make results / statistics visual testing easier with better data population
This commit is contained in:
commit
601e3fe24f
@ -69,6 +69,35 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
}));
|
||||
}
|
||||
|
||||
private int onlineScoreID = 1;
|
||||
|
||||
[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;
|
||||
|
||||
loadResultsScreen(() =>
|
||||
{
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
|
||||
score.OnlineID = onlineScoreID++;
|
||||
score.HitEvents = TestSceneStatisticsPanel.CreatePositionDistributedHitEvents();
|
||||
score.Accuracy = accuracy;
|
||||
score.Rank = rank;
|
||||
|
||||
return screen = createResultsScreen(score);
|
||||
});
|
||||
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestResultsWithoutPlayer()
|
||||
{
|
||||
@ -82,34 +111,14 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
RelativeSizeAxes = Axes.Both
|
||||
};
|
||||
|
||||
stack.Push(screen = createResultsScreen());
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
|
||||
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()
|
||||
{
|
||||
@ -328,13 +337,14 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Solo;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Difficulty;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -23,6 +24,7 @@ using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
@ -30,19 +32,20 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
public partial class TestSceneStatisticsPanel : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestScoreWithTimeStatistics()
|
||||
public void TestScoreWithPositionStatistics()
|
||||
{
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents();
|
||||
score.OnlineID = 1234;
|
||||
score.HitEvents = CreatePositionDistributedHitEvents();
|
||||
|
||||
loadPanel(score);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestScoreWithPositionStatistics()
|
||||
public void TestScoreWithTimeStatistics()
|
||||
{
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.HitEvents = createPositionDistributedHitEvents();
|
||||
score.HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents();
|
||||
|
||||
loadPanel(score);
|
||||
}
|
||||
@ -79,28 +82,67 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
|
||||
private void loadPanel(ScoreInfo score) => AddStep("load panel", () =>
|
||||
{
|
||||
Child = new StatisticsPanel
|
||||
Child = new SoloStatisticsPanel(score)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
State = { Value = Visibility.Visible },
|
||||
Score = { Value = score }
|
||||
Score = { Value = score },
|
||||
StatisticsUpdate =
|
||||
{
|
||||
Value = new SoloStatisticsUpdate(score, new UserStatistics
|
||||
{
|
||||
Level = new UserStatistics.LevelInfo
|
||||
{
|
||||
Current = 5,
|
||||
Progress = 20,
|
||||
},
|
||||
GlobalRank = 38000,
|
||||
CountryRank = 12006,
|
||||
PP = 2134,
|
||||
RankedScore = 21123849,
|
||||
Accuracy = 0.985,
|
||||
PlayCount = 13375,
|
||||
PlayTime = 354490,
|
||||
TotalScore = 128749597,
|
||||
TotalHits = 0,
|
||||
MaxCombo = 1233,
|
||||
}, new UserStatistics
|
||||
{
|
||||
Level = new UserStatistics.LevelInfo
|
||||
{
|
||||
Current = 5,
|
||||
Progress = 30,
|
||||
},
|
||||
GlobalRank = 36000,
|
||||
CountryRank = 12000,
|
||||
PP = (decimal)2134.5,
|
||||
RankedScore = 23897015,
|
||||
Accuracy = 0.984,
|
||||
PlayCount = 13376,
|
||||
PlayTime = 35789,
|
||||
TotalScore = 132218497,
|
||||
TotalHits = 0,
|
||||
MaxCombo = 1233,
|
||||
})
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
private static List<HitEvent> createPositionDistributedHitEvents()
|
||||
public static List<HitEvent> CreatePositionDistributedHitEvents()
|
||||
{
|
||||
var hitEvents = new List<HitEvent>();
|
||||
var hitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents();
|
||||
|
||||
// Use constant seed for reproducibility
|
||||
var random = new Random(0);
|
||||
|
||||
for (int i = 0; i < 500; i++)
|
||||
for (int i = 0; i < hitEvents.Count; i++)
|
||||
{
|
||||
double angle = random.NextDouble() * 2 * Math.PI;
|
||||
double radius = random.NextDouble() * 0.5f * OsuHitObject.OBJECT_RADIUS;
|
||||
|
||||
var position = new Vector2((float)(radius * Math.Cos(angle)), (float)(radius * Math.Sin(angle)));
|
||||
|
||||
hitEvents.Add(new HitEvent(0, HitResult.Perfect, new HitCircle(), new HitCircle(), position));
|
||||
hitEvents[i] = hitEvents[i].With(position);
|
||||
}
|
||||
|
||||
return hitEvents;
|
||||
|
Loading…
Reference in New Issue
Block a user