-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from andy840119/update-nuget
Update nuget
- Loading branch information
Showing
7 changed files
with
292 additions
and
11 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
osu.Game.Rulesets.Karaoke.Tests/Ranking/TestKaraokeScoreInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using osu.Game.Rulesets.Karaoke.Mods; | ||
using osu.Game.Rulesets.Karaoke.Tests.Beatmaps; | ||
using osu.Game.Rulesets.Mods; | ||
using osu.Game.Rulesets.Scoring; | ||
using osu.Game.Scoring; | ||
using osu.Game.Users; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.Ranking | ||
{ | ||
public class TestKaraokeScoreInfo : ScoreInfo | ||
{ | ||
public TestKaraokeScoreInfo() | ||
{ | ||
var ruleset = new KaraokeRuleset().RulesetInfo; | ||
|
||
User = new User | ||
{ | ||
Id = 1030492, | ||
Username = "andy840119", | ||
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", | ||
}; | ||
|
||
Beatmap = new TestKaraokeBeatmap(ruleset).BeatmapInfo; | ||
Ruleset = ruleset; | ||
RulesetID = ruleset.ID ?? 0; | ||
Mods = new Mod[] { new KaraokeModFlashlight(), new KaraokeModSnow() }; | ||
|
||
TotalScore = 2845370; | ||
Accuracy = 0.95; | ||
MaxCombo = 999; | ||
Rank = ScoreRank.S; | ||
Date = DateTimeOffset.Now; | ||
|
||
Statistics[HitResult.Miss] = 1; | ||
Statistics[HitResult.Meh] = 50; | ||
Statistics[HitResult.Good] = 100; | ||
Statistics[HitResult.Great] = 300; | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
osu.Game.Rulesets.Karaoke.Tests/Ranking/TestSceneHitEventTimingDistributionGraph.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL 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.Karaoke.Objects; | ||
using osu.Game.Rulesets.Scoring; | ||
using osu.Game.Screens.Ranking.Statistics; | ||
using osu.Game.Tests.Visual; | ||
using osuTK; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.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 Note(), new Note(), 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 Note(), new Note(), null)); | ||
} | ||
|
||
return hitEvents; | ||
} | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
osu.Game.Rulesets.Karaoke.Tests/Ranking/TestSceneResultsScreen.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL 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.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Screens; | ||
using osu.Framework.Testing; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Online.API; | ||
using osu.Game.Rulesets.Karaoke.Tests.Beatmaps; | ||
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 osu.Game.Tests.Visual; | ||
using osuTK.Input; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.Ranking | ||
{ | ||
[TestFixture] | ||
public class TestSceneResultsScreen : OsuManualInputManagerTestScene | ||
{ | ||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestKaraokeBeatmap(ruleset); | ||
|
||
private TestResultsScreen createResultsScreen() => new TestResultsScreen(new TestKaraokeScoreInfo | ||
{ | ||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents() | ||
}); | ||
|
||
[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); | ||
} | ||
|
||
private class TestResultsContainer : Container | ||
{ | ||
[Cached(typeof(Player))] | ||
private readonly Player player = new TestPlayer(); | ||
|
||
public TestResultsContainer(IScreen screen) | ||
{ | ||
RelativeSizeAxes = Axes.Both; | ||
OsuScreenStack stack; | ||
|
||
InternalChild = stack = new OsuScreenStack | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
}; | ||
|
||
stack.Push(screen); | ||
} | ||
} | ||
|
||
private class TestResultsScreen : ResultsScreen | ||
{ | ||
public TestResultsScreen(ScoreInfo score) | ||
: base(score) | ||
{ | ||
} | ||
|
||
protected override APIRequest FetchScores(Action<IEnumerable<ScoreInfo>> scoresCallback) | ||
{ | ||
var scores = new List<ScoreInfo>(); | ||
|
||
for (int i = 0; i < 20; i++) | ||
{ | ||
var score = new TestKaraokeScoreInfo(); | ||
score.TotalScore += 10 - i; | ||
scores.Add(score); | ||
} | ||
|
||
scoresCallback?.Invoke(scores); | ||
|
||
return null; | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
osu.Game.Rulesets.Karaoke.Tests/Ranking/TestSceneStatisticsPanel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL 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.Scoring; | ||
using osu.Game.Screens.Ranking.Statistics; | ||
using osu.Game.Tests.Visual; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.Ranking | ||
{ | ||
public class TestSceneStatisticsPanel : OsuTestScene | ||
{ | ||
[Test] | ||
public void TestScoreWithStatistics() | ||
{ | ||
var score = new TestKaraokeScoreInfo | ||
{ | ||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents() | ||
}; | ||
|
||
loadPanel(score); | ||
} | ||
|
||
[Test] | ||
public void TestScoreWithoutStatistics() | ||
{ | ||
loadPanel(new TestKaraokeScoreInfo()); | ||
} | ||
|
||
[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 } | ||
}; | ||
}); | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeSkinnableTestScene.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,14 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.Skinning; | ||
using osu.Game.Tests.Visual; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Tests.Skinning | ||
{ | ||
public abstract class KaraokeSkinnableTestScene : SkinnableTestScene | ||
{ | ||
public override IReadOnlyList<Type> RequiredTypes => new[] | ||
{ | ||
typeof(KaraokeRuleset), | ||
typeof(KaraokeLegacySkinTransformer), | ||
}; | ||
|
||
protected override Ruleset CreateRulesetForSkinProvider() => new KaraokeRuleset(); | ||
|
||
protected override IBeatmap CreateBeatmapForSkinProvider() => new KaraokeBeatmap(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters