mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Merge branch 'master' into red-tint
This commit is contained in:
@ -19,10 +19,10 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
[Cached]
|
||||
private OsuLogo logo;
|
||||
|
||||
protected OsuScreenStack IntroStack;
|
||||
|
||||
protected IntroTestScene()
|
||||
{
|
||||
OsuScreenStack introStack = null;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
@ -45,17 +45,17 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
logo.FinishTransforms();
|
||||
logo.IsTracking = false;
|
||||
|
||||
introStack?.Expire();
|
||||
IntroStack?.Expire();
|
||||
|
||||
Add(introStack = new OsuScreenStack
|
||||
Add(IntroStack = new OsuScreenStack
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
});
|
||||
|
||||
introStack.Push(CreateScreen());
|
||||
IntroStack.Push(CreateScreen());
|
||||
});
|
||||
|
||||
AddUntilStep("wait for menu", () => introStack.CurrentScreen is MainMenu);
|
||||
AddUntilStep("wait for menu", () => IntroStack.CurrentScreen is MainMenu);
|
||||
}
|
||||
|
||||
protected abstract IScreen CreateScreen();
|
||||
|
@ -11,5 +11,18 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
public class TestSceneIntroWelcome : IntroTestScene
|
||||
{
|
||||
protected override IScreen CreateScreen() => new IntroWelcome();
|
||||
|
||||
public TestSceneIntroWelcome()
|
||||
{
|
||||
AddAssert("check if menu music loops", () =>
|
||||
{
|
||||
var menu = IntroStack?.CurrentScreen as MainMenu;
|
||||
|
||||
if (menu == null)
|
||||
return false;
|
||||
|
||||
return menu.Track.Looping;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,71 @@
|
||||
// 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.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Ranking.Statistics;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
public class TestSceneHitEventTimingDistributionGraph : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestManyDistributedEvents()
|
||||
{
|
||||
createTest(CreateDistributedHitEvents());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestZeroTimeOffset()
|
||||
{
|
||||
createTest(Enumerable.Range(0, 100).Select(_ => new HitEvent(0, HitResult.Perfect, new HitCircle(), new HitCircle(), null)).ToList());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoEvents()
|
||||
{
|
||||
createTest(new List<HitEvent>());
|
||||
}
|
||||
|
||||
private void createTest(List<HitEvent> events) => AddStep("create test", () =>
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4Extensions.FromHex("#333")
|
||||
},
|
||||
new HitEventTimingDistributionGraph(events)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(600, 130)
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
public static List<HitEvent> CreateDistributedHitEvents()
|
||||
{
|
||||
var hitEvents = new List<HitEvent>();
|
||||
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
int count = (int)(Math.Pow(25 - Math.Abs(i - 25), 2));
|
||||
|
||||
for (int j = 0; j < count; j++)
|
||||
hitEvents.Add(new HitEvent(i - 25, HitResult.Perfect, new HitCircle(), new HitCircle(), null));
|
||||
}
|
||||
|
||||
return hitEvents;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +1,32 @@
|
||||
// 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 System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Ranking.Statistics;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneResultsScreen : ScreenTestScene
|
||||
public class TestSceneResultsScreen : OsuManualInputManagerTestScene
|
||||
{
|
||||
private BeatmapManager beatmaps;
|
||||
|
||||
@ -41,7 +50,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
private UnrankedSoloResultsScreen createUnrankedSoloResultsScreen() => new UnrankedSoloResultsScreen(new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
||||
|
||||
[Test]
|
||||
public void ResultsWithoutPlayer()
|
||||
public void TestResultsWithoutPlayer()
|
||||
{
|
||||
TestResultsScreen screen = null;
|
||||
OsuScreenStack stack;
|
||||
@ -60,7 +69,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResultsWithPlayer()
|
||||
public void TestResultsWithPlayer()
|
||||
{
|
||||
TestResultsScreen screen = null;
|
||||
|
||||
@ -70,7 +79,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResultsForUnranked()
|
||||
public void TestResultsForUnranked()
|
||||
{
|
||||
UnrankedSoloResultsScreen screen = null;
|
||||
|
||||
@ -79,6 +88,130 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowHideStatisticsViaOutsideClick()
|
||||
{
|
||||
TestResultsScreen screen = null;
|
||||
|
||||
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
|
||||
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||
|
||||
AddStep("click expanded panel", () =>
|
||||
{
|
||||
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
InputManager.MoveMouseTo(expandedPanel);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("statistics shown", () => this.ChildrenOfType<StatisticsPanel>().Single().State.Value == Visibility.Visible);
|
||||
|
||||
AddUntilStep("expanded panel at the left of the screen", () =>
|
||||
{
|
||||
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
return expandedPanel.ScreenSpaceDrawQuad.TopLeft.X - screen.ScreenSpaceDrawQuad.TopLeft.X < 150;
|
||||
});
|
||||
|
||||
AddStep("click to right of panel", () =>
|
||||
{
|
||||
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
InputManager.MoveMouseTo(expandedPanel.ScreenSpaceDrawQuad.TopRight + new Vector2(100, 0));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("statistics hidden", () => this.ChildrenOfType<StatisticsPanel>().Single().State.Value == Visibility.Hidden);
|
||||
|
||||
AddUntilStep("expanded panel in centre of screen", () =>
|
||||
{
|
||||
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
return Precision.AlmostEquals(expandedPanel.ScreenSpaceDrawQuad.Centre.X, screen.ScreenSpaceDrawQuad.Centre.X, 1);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowHideStatistics()
|
||||
{
|
||||
TestResultsScreen screen = null;
|
||||
|
||||
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
|
||||
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||
|
||||
AddStep("click expanded panel", () =>
|
||||
{
|
||||
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
InputManager.MoveMouseTo(expandedPanel);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("statistics shown", () => this.ChildrenOfType<StatisticsPanel>().Single().State.Value == Visibility.Visible);
|
||||
|
||||
AddUntilStep("expanded panel at the left of the screen", () =>
|
||||
{
|
||||
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
return expandedPanel.ScreenSpaceDrawQuad.TopLeft.X - screen.ScreenSpaceDrawQuad.TopLeft.X < 150;
|
||||
});
|
||||
|
||||
AddStep("click expanded panel", () =>
|
||||
{
|
||||
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
InputManager.MoveMouseTo(expandedPanel);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("statistics hidden", () => this.ChildrenOfType<StatisticsPanel>().Single().State.Value == Visibility.Hidden);
|
||||
|
||||
AddUntilStep("expanded panel in centre of screen", () =>
|
||||
{
|
||||
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
return Precision.AlmostEquals(expandedPanel.ScreenSpaceDrawQuad.Centre.X, screen.ScreenSpaceDrawQuad.Centre.X, 1);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowStatisticsAndClickOtherPanel()
|
||||
{
|
||||
TestResultsScreen screen = null;
|
||||
|
||||
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
|
||||
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||
|
||||
ScorePanel expandedPanel = null;
|
||||
ScorePanel contractedPanel = null;
|
||||
|
||||
AddStep("click expanded panel then contracted panel", () =>
|
||||
{
|
||||
expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
InputManager.MoveMouseTo(expandedPanel);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
|
||||
contractedPanel = this.ChildrenOfType<ScorePanel>().First(p => p.State == PanelState.Contracted && p.ScreenSpaceDrawQuad.TopLeft.X > screen.ScreenSpaceDrawQuad.TopLeft.X);
|
||||
InputManager.MoveMouseTo(contractedPanel);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("statistics shown", () => this.ChildrenOfType<StatisticsPanel>().Single().State.Value == Visibility.Visible);
|
||||
|
||||
AddAssert("contracted panel still contracted", () => contractedPanel.State == PanelState.Contracted);
|
||||
AddAssert("expanded panel still expanded", () => expandedPanel.State == PanelState.Expanded);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFetchScoresAfterShowingStatistics()
|
||||
{
|
||||
DelayedFetchResultsScreen screen = null;
|
||||
|
||||
AddStep("load results", () => Child = new TestResultsContainer(screen = new DelayedFetchResultsScreen(new TestScoreInfo(new OsuRuleset().RulesetInfo), 3000)));
|
||||
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||
AddStep("click expanded panel", () =>
|
||||
{
|
||||
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||
InputManager.MoveMouseTo(expandedPanel);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for fetch", () => screen.FetchCompleted);
|
||||
AddAssert("expanded panel still on screen", () => this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded).ScreenSpaceDrawQuad.TopLeft.X > 0);
|
||||
}
|
||||
|
||||
private class TestResultsContainer : Container
|
||||
{
|
||||
[Cached(typeof(Player))]
|
||||
@ -113,6 +246,58 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
|
||||
RetryOverlay = InternalChildren.OfType<HotkeyRetryOverlay>().SingleOrDefault();
|
||||
}
|
||||
|
||||
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
|
||||
{
|
||||
var scores = new List<ScoreInfo>();
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
score.TotalScore += 10 - i;
|
||||
scores.Add(score);
|
||||
}
|
||||
|
||||
scoresCallback?.Invoke(scores);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class DelayedFetchResultsScreen : TestResultsScreen
|
||||
{
|
||||
public bool FetchCompleted { get; private set; }
|
||||
|
||||
private readonly double delay;
|
||||
|
||||
public DelayedFetchResultsScreen(ScoreInfo score, double delay)
|
||||
: base(score)
|
||||
{
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(delay));
|
||||
|
||||
var scores = new List<ScoreInfo>();
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo);
|
||||
score.TotalScore += 10 - i;
|
||||
scores.Add(score);
|
||||
}
|
||||
|
||||
scoresCallback?.Invoke(scores);
|
||||
|
||||
Schedule(() => FetchCompleted = true);
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class UnrankedSoloResultsScreen : SoloResultsScreen
|
||||
|
48
osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs
Normal file
48
osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs
Normal file
@ -0,0 +1,48 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking.Statistics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
{
|
||||
public class TestSceneStatisticsPanel : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestScoreWithStatistics()
|
||||
{
|
||||
var score = new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
||||
{
|
||||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents()
|
||||
};
|
||||
|
||||
loadPanel(score);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestScoreWithoutStatistics()
|
||||
{
|
||||
loadPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNullScore()
|
||||
{
|
||||
loadPanel(null);
|
||||
}
|
||||
|
||||
private void loadPanel(ScoreInfo score) => AddStep("load panel", () =>
|
||||
{
|
||||
Child = new StatisticsPanel
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
State = { Value = Visibility.Visible },
|
||||
Score = { Value = score }
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
@ -17,11 +17,12 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Select.Carousel;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.SongSelect
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneBeatmapCarousel : OsuTestScene
|
||||
public class TestSceneBeatmapCarousel : OsuManualInputManagerTestScene
|
||||
{
|
||||
private TestBeatmapCarousel carousel;
|
||||
private RulesetStore rulesets;
|
||||
@ -39,6 +40,43 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
this.rulesets = rulesets;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestKeyRepeat()
|
||||
{
|
||||
loadBeatmaps();
|
||||
advanceSelection(false);
|
||||
|
||||
AddStep("press down arrow", () => InputManager.PressKey(Key.Down));
|
||||
|
||||
BeatmapInfo selection = null;
|
||||
|
||||
checkSelectionIterating(true);
|
||||
|
||||
AddStep("press up arrow", () => InputManager.PressKey(Key.Up));
|
||||
|
||||
checkSelectionIterating(true);
|
||||
|
||||
AddStep("release down arrow", () => InputManager.ReleaseKey(Key.Down));
|
||||
|
||||
checkSelectionIterating(true);
|
||||
|
||||
AddStep("release up arrow", () => InputManager.ReleaseKey(Key.Up));
|
||||
|
||||
checkSelectionIterating(false);
|
||||
|
||||
void checkSelectionIterating(bool isIterating)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
AddStep("store selection", () => selection = carousel.SelectedBeatmap);
|
||||
if (isIterating)
|
||||
AddUntilStep("selection changed", () => carousel.SelectedBeatmap != selection);
|
||||
else
|
||||
AddUntilStep("selection not changed", () => carousel.SelectedBeatmap == selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRecommendedSelection()
|
||||
{
|
||||
|
Reference in New Issue
Block a user