diff --git a/osu-framework b/osu-framework index e6394035d4..34c9f17a6a 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit e6394035d443d4498b71e845e5763dd3faf98c7c +Subproject commit 34c9f17a6ac6fa5e9fd5569f9e119331316c1313 diff --git a/osu.Desktop.Deploy/Program.cs b/osu.Desktop.Deploy/Program.cs index 00ec215e8a..37776b329f 100644 --- a/osu.Desktop.Deploy/Program.cs +++ b/osu.Desktop.Deploy/Program.cs @@ -53,7 +53,7 @@ namespace osu.Desktop.Deploy private static string nupkgFilename(string ver) => $"{PackageName}.{ver}.nupkg"; private static string nupkgDistroFilename(string ver) => $"{PackageName}-{ver}-full.nupkg"; - private static Stopwatch sw = new Stopwatch(); + private static readonly Stopwatch sw = new Stopwatch(); private static string codeSigningPassword; diff --git a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs new file mode 100644 index 0000000000..f135a6affa --- /dev/null +++ b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs @@ -0,0 +1,24 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Audio.Track; +using osu.Framework.Graphics.Textures; +using osu.Game.Beatmaps; + +namespace osu.Desktop.VisualTests.Beatmaps +{ + public class TestWorkingBeatmap : WorkingBeatmap + { + public TestWorkingBeatmap(Beatmap beatmap) + : base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet) + { + this.beatmap = beatmap; + } + + private readonly Beatmap beatmap; + + protected override Beatmap GetBeatmap() => beatmap; + protected override Texture GetBackground() => null; + protected override Track GetTrack() => null; + } +} diff --git a/osu.Desktop.VisualTests/Benchmark.cs b/osu.Desktop.VisualTests/Benchmark.cs index 3847b6f00f..0a15b38fc2 100644 --- a/osu.Desktop.VisualTests/Benchmark.cs +++ b/osu.Desktop.VisualTests/Benchmark.cs @@ -10,7 +10,7 @@ namespace osu.Desktop.VisualTests { public class Benchmark : OsuGameBase { - private double timePerTest = 200; + private const double time_per_test = 200; [BackgroundDependencyLoader] private void load() @@ -27,7 +27,7 @@ namespace osu.Desktop.VisualTests TestBrowser f = new TestBrowser(); Add(f); - Console.WriteLine($@"{Time}: Running {f.TestCount} tests for {timePerTest}ms each..."); + Console.WriteLine($@"{Time}: Running {f.TestCount} tests for {time_per_test}ms each..."); for (int i = 1; i < f.TestCount; i++) { @@ -36,10 +36,10 @@ namespace osu.Desktop.VisualTests { f.LoadTest(loadableCase); Console.WriteLine($@"{Time}: Switching to test #{loadableCase}"); - }, loadableCase * timePerTest); + }, loadableCase * time_per_test); } - Scheduler.AddDelayed(Host.Exit, f.TestCount * timePerTest); + Scheduler.AddDelayed(Host.Exit, f.TestCount * time_per_test); } } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs new file mode 100644 index 0000000000..bb7df19202 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Screens.Testing; +using osu.Game.Screens.Select; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseBeatmapDetailArea : TestCase + { + public override string Description => @"Beatmap details in song select"; + + public override void Reset() + { + base.Reset(); + + Add(new BeatmapDetailArea + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(550f, 450f), + }); + } + } +} \ No newline at end of file diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs index 7aa6e1aee1..00e41de254 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using osu.Framework.Screens.Testing; using osu.Game.Screens.Tournament; using osu.Game.Screens.Tournament.Teams; +using osu.Game.Users; namespace osu.Desktop.VisualTests.Tests { @@ -24,57 +25,57 @@ namespace osu.Desktop.VisualTests.Tests private class TestTeamList : ITeamList { - public IEnumerable Teams { get; } = new[] + public IEnumerable Teams { get; } = new[] { - new Team + new Country { FlagName = "GB", FullName = "United Kingdom", Acronym = "UK" }, - new Team + new Country { FlagName = "FR", FullName = "France", Acronym = "FRA" }, - new Team + new Country { FlagName = "CN", FullName = "China", Acronym = "CHN" }, - new Team + new Country { FlagName = "AU", FullName = "Australia", Acronym = "AUS" }, - new Team + new Country { FlagName = "JP", FullName = "Japan", Acronym = "JPN" }, - new Team + new Country { FlagName = "RO", FullName = "Romania", Acronym = "ROM" }, - new Team + new Country { FlagName = "IT", FullName = "Italy", Acronym = "PIZZA" }, - new Team + new Country { FlagName = "VE", FullName = "Venezuela", Acronym = "VNZ" }, - new Team + new Country { FlagName = "US", FullName = "United States of America", diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index c2e33f7f32..e876c21a12 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -8,7 +8,6 @@ using osu.Framework.MathUtils; using osu.Framework.Screens.Testing; using osu.Framework.Timing; using osu.Game.Beatmaps; -using osu.Game.Beatmaps.IO; using osu.Game.Database; using osu.Game.Modes.Catch.UI; using osu.Game.Modes.Mania.UI; @@ -17,6 +16,7 @@ using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.Taiko.UI; using System.Collections.Generic; +using osu.Desktop.VisualTests.Beatmaps; namespace osu.Desktop.VisualTests.Tests { @@ -95,16 +95,5 @@ namespace osu.Desktop.VisualTests.Tests } }); } - - private class TestWorkingBeatmap : WorkingBeatmap - { - public TestWorkingBeatmap(Beatmap beatmap) - : base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet) - { - Beatmap = beatmap; - } - - protected override ArchiveReader GetReader() => null; - } } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index eeebc7faa8..f302330346 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -21,7 +21,7 @@ namespace osu.Desktop.VisualTests.Tests { internal class TestCaseHitObjects : TestCase { - private FramedClock framedClock; + private readonly FramedClock framedClock; private bool auto; @@ -34,7 +34,7 @@ namespace osu.Desktop.VisualTests.Tests private HitObjectType mode = HitObjectType.Slider; - private BindableNumber playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 }; + private readonly BindableNumber playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 }; private Container playfieldContainer; private Container approachContainer; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs b/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs new file mode 100644 index 0000000000..cc30e3de95 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs @@ -0,0 +1,225 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Screens.Testing; +using osu.Game.Modes; +using osu.Game.Modes.Mods; +using osu.Game.Modes.Osu.Mods; +using osu.Game.Screens.Select.Leaderboards; +using osu.Game.Users; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseLeaderboard : TestCase + { + public override string Description => @"From song select"; + + private Leaderboard leaderboard; + + private void newScores() + { + var scores = new[] + { + new Score + { + Rank = ScoreRank.XH, + Accuracy = 100, + MaxCombo = 244, + TotalScore = 1707827, + Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, + User = new User + { + Id = 6602580, + Username = @"waaiiru", + Country = new Country + { + FullName = @"Spain", + FlagName = @"ES", + }, + }, + }, + new Score + { + Rank = ScoreRank.X, + Accuracy = 100, + MaxCombo = 244, + TotalScore = 1707827, + Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, + User = new User + { + Id = 4608074, + Username = @"Skycries", + Country = new Country + { + FullName = @"Brazil", + FlagName = @"BR", + }, + }, + }, + new Score + { + Rank = ScoreRank.SH, + Accuracy = 100, + MaxCombo = 244, + TotalScore = 1707827, + Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, + User = new User + { + Id = 1014222, + Username = @"eLy", + Country = new Country + { + FullName = @"Japan", + FlagName = @"JP", + }, + }, + }, + new Score + { + Rank = ScoreRank.S, + Accuracy = 100, + MaxCombo = 244, + TotalScore = 1707827, + Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, + User = new User + { + Id = 1541390, + Username = @"Toukai", + Country = new Country + { + FullName = @"Canada", + FlagName = @"CA", + }, + }, + }, + new Score + { + Rank = ScoreRank.A, + Accuracy = 100, + MaxCombo = 244, + TotalScore = 1707827, + Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, + User = new User + { + Id = 2243452, + Username = @"Satoruu", + Country = new Country + { + FullName = @"Venezuela", + FlagName = @"VE", + }, + }, + }, + new Score + { + Rank = ScoreRank.B, + Accuracy = 98.26, + MaxCombo = 244, + TotalScore = 1707827, + Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, + User = new User + { + Id = 2705430, + Username = @"Mooha", + Country = new Country + { + FullName = @"France", + FlagName = @"FR", + }, + }, + }, + new Score + { + Rank = ScoreRank.C, + Accuracy = 96.54, + MaxCombo = 244, + TotalScore = 1707827, + Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, + User = new User + { + Id = 7151382, + Username = @"Mayuri Hana", + Country = new Country + { + FullName = @"Thailand", + FlagName = @"TH", + }, + }, + }, + new Score + { + Rank = ScoreRank.F, + Accuracy = 60.25, + MaxCombo = 244, + TotalScore = 1707827, + Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, + User = new User + { + Id = 2051389, + Username = @"FunOrange", + Country = new Country + { + FullName = @"Canada", + FlagName = @"CA", + }, + }, + }, + new Score + { + Rank = ScoreRank.F, + Accuracy = 51.40, + MaxCombo = 244, + TotalScore = 1707827, + Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, + User = new User + { + Id = 6169483, + Username = @"-Hebel-", + Country = new Country + { + FullName = @"Mexico", + FlagName = @"MX", + }, + }, + }, + new Score + { + Rank = ScoreRank.F, + Accuracy = 42.22, + MaxCombo = 244, + TotalScore = 1707827, + Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), }, + User = new User + { + Id = 6702666, + Username = @"prhtnsm", + Country = new Country + { + FullName = @"Germany", + FlagName = @"DE", + }, + }, + }, + }; + + leaderboard.Scores = scores; + } + + public override void Reset() + { + base.Reset(); + + Add(leaderboard = new Leaderboard + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Size = new Vector2(550f, 450f), + }); + + AddButton(@"New Scores", newScores); + newScores(); + } + } +} diff --git a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs index c3a9064e69..13f89153e9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs @@ -95,7 +95,7 @@ namespace osu.Desktop.VisualTests.Tests progressingNotifications.Add(n); } - private List progressingNotifications = new List(); + private readonly List progressingNotifications = new List(); private void sendProgress1() { diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index 41bd24b900..a08cb3e97e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -8,13 +8,13 @@ using osu.Framework.Screens.Testing; using osu.Game.Beatmaps; using OpenTK; using osu.Framework.Graphics.Sprites; -using osu.Game.Beatmaps.IO; using osu.Game.Database; using osu.Game.Modes; using osu.Game.Modes.Objects; using osu.Game.Modes.Osu.Objects; using osu.Game.Screens.Play; using OpenTK.Graphics; +using osu.Desktop.VisualTests.Beatmaps; namespace osu.Desktop.VisualTests.Tests { @@ -23,7 +23,6 @@ namespace osu.Desktop.VisualTests.Tests protected Player Player; private BeatmapDatabase db; - public override string Description => @"Showing everything to play the game."; [BackgroundDependencyLoader] @@ -97,16 +96,5 @@ namespace osu.Desktop.VisualTests.Tests Beatmap = beatmap }; } - - private class TestWorkingBeatmap : WorkingBeatmap - { - public TestWorkingBeatmap(Beatmap beatmap) - : base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet) - { - Beatmap = beatmap; - } - - protected override ArchiveReader GetReader() => null; - } } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs new file mode 100644 index 0000000000..3087b90e36 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs @@ -0,0 +1,77 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.MathUtils; +using osu.Framework.Screens.Testing; +using osu.Game.Modes.Objects.Drawables; +using osu.Game.Modes.Taiko.Judgements; +using osu.Game.Modes.Taiko.Objects; +using osu.Game.Modes.Taiko.UI; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseTaikoPlayfield : TestCase + { + public override string Description => "Taiko playfield"; + + private TaikoPlayfield playfield; + + public override void Reset() + { + base.Reset(); + + AddButton("Hit!", addHitJudgement); + AddButton("Miss :(", addMissJudgement); + + Add(playfield = new TaikoPlayfield + { + Y = 200 + }); + } + + private void addHitJudgement() + { + TaikoHitResult hitResult = RNG.Next(2) == 0 ? TaikoHitResult.Good : TaikoHitResult.Great; + + playfield.OnJudgement(new DrawableTestHit(new Hit()) + { + X = RNG.NextSingle(hitResult == TaikoHitResult.Good ? -0.1f : -0.05f, hitResult == TaikoHitResult.Good ? 0.1f : 0.05f), + Judgement = new TaikoJudgementInfo + { + Result = HitResult.Hit, + TaikoResult = hitResult, + TimeOffset = 0, + ComboAtHit = 1, + SecondHit = RNG.Next(10) == 0 + } + }); + } + + private void addMissJudgement() + { + playfield.OnJudgement(new DrawableTestHit(new Hit()) + { + Judgement = new TaikoJudgementInfo + { + Result = HitResult.Miss, + TimeOffset = 0, + ComboAtHit = 0 + } + }); + } + + private class DrawableTestHit : DrawableHitObject + { + public DrawableTestHit(TaikoHitObject hitObject) + : base(hitObject) + { + } + + protected override TaikoJudgementInfo CreateJudgementInfo() => new TaikoJudgementInfo(); + + protected override void UpdateState(ArmedState state) + { + } + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 68aed38b34..e63306300d 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -23,7 +23,7 @@ false LocalIntranet v4.5 - true + true publish\ true Disk @@ -194,6 +194,7 @@ + @@ -204,9 +205,15 @@ + + + + + +