mirror of
https://github.com/ppy/osu
synced 2025-01-11 16:49:39 +00:00
Add details test scene + fix metrics not getting updated correctly
This commit is contained in:
parent
7af2d650cd
commit
f2b5f274cf
@ -0,0 +1,68 @@
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays.BeatmapSet;
|
||||
using osu.Game.Screens.Select.Details;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneBeatmapSetOverlayDetails : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(Details)
|
||||
};
|
||||
|
||||
private RatingsExposingDetails details;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
Child = details = new RatingsExposingDetails
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
};
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestMetrics()
|
||||
{
|
||||
var firstSet = createSet();
|
||||
var secondSet = createSet();
|
||||
|
||||
AddStep("set first set", () => details.BeatmapSet = firstSet);
|
||||
AddAssert("ratings set", () => details.Ratings.Metrics == firstSet.Metrics);
|
||||
|
||||
AddStep("set second set", () => details.BeatmapSet = secondSet);
|
||||
AddAssert("ratings set", () => details.Ratings.Metrics == secondSet.Metrics);
|
||||
|
||||
BeatmapSetInfo createSet() => new BeatmapSetInfo
|
||||
{
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
{
|
||||
new BeatmapInfo
|
||||
{
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class RatingsExposingDetails : Details
|
||||
{
|
||||
public new UserRatings Ratings => base.Ratings;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,10 +16,11 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class Details : FillFlowContainer
|
||||
{
|
||||
protected readonly UserRatings Ratings;
|
||||
|
||||
private readonly PreviewButton preview;
|
||||
private readonly BasicStats basic;
|
||||
private readonly AdvancedStats advanced;
|
||||
private readonly UserRatings ratings;
|
||||
|
||||
private BeatmapSetInfo beatmapSet;
|
||||
|
||||
@ -33,6 +34,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
beatmapSet = value;
|
||||
|
||||
basic.BeatmapSet = preview.BeatmapSet = BeatmapSet;
|
||||
updateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,13 +48,12 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
if (value == beatmap) return;
|
||||
|
||||
basic.Beatmap = advanced.Beatmap = beatmap = value;
|
||||
updateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
ratings.Metrics = BeatmapSet?.Metrics;
|
||||
Ratings.Metrics = BeatmapSet?.Metrics;
|
||||
}
|
||||
|
||||
public Details()
|
||||
@ -87,7 +88,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
},
|
||||
new DetailBox
|
||||
{
|
||||
Child = ratings = new UserRatings
|
||||
Child = Ratings = new UserRatings
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 95,
|
||||
|
Loading…
Reference in New Issue
Block a user