mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Fix scrolling (1-frame + maintain scroll position)
This commit is contained in:
@ -1,10 +1,14 @@
|
||||
// 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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -12,12 +16,13 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
public class TestSceneScorePanelList : OsuTestScene
|
||||
{
|
||||
private ScoreInfo initialScore;
|
||||
private ScorePanelList list;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
Child = list = new ScorePanelList(new TestScoreInfo(new OsuRuleset().RulesetInfo))
|
||||
Child = list = new ScorePanelList(initialScore = new TestScoreInfo(new OsuRuleset().RulesetInfo))
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -36,16 +41,52 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[Test]
|
||||
public void TestSingleScore()
|
||||
{
|
||||
assertPanelCentred();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestManyScores()
|
||||
public void TestAddManyScoresAfter()
|
||||
{
|
||||
AddStep("add many scores", () =>
|
||||
AddStep("add scores", () =>
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
||||
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo) { TotalScore = initialScore.TotalScore - i - 1 });
|
||||
});
|
||||
|
||||
assertPanelCentred();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddManyScoresBefore()
|
||||
{
|
||||
AddStep("add scores", () =>
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo) { TotalScore = initialScore.TotalScore + i + 1 });
|
||||
});
|
||||
|
||||
assertPanelCentred();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddManyPanelsOnBothSides()
|
||||
{
|
||||
AddStep("add scores after", () =>
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo) { TotalScore = initialScore.TotalScore - i - 1 });
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
list.AddScore(new TestScoreInfo(new OsuRuleset().RulesetInfo) { TotalScore = initialScore.TotalScore + i + 1 });
|
||||
});
|
||||
|
||||
assertPanelCentred();
|
||||
}
|
||||
|
||||
private void assertPanelCentred() => AddUntilStep("expanded panel centred", () =>
|
||||
{
|
||||
var expandedPanel = list.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
return Precision.AlmostEquals(expandedPanel.ScreenSpaceDrawQuad.Centre.X, list.ScreenSpaceDrawQuad.Centre.X, 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user