forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b85bdd6
commit 49763eb
Showing
70 changed files
with
3,909 additions
and
128 deletions.
There are no files selected for viewing
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
229 changes: 229 additions & 0 deletions
229
osu.Game.Tests/Visual/Online/TestSceneBeatmapInfoOverlay.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,229 @@ | ||
// 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.Linq; | ||
using NUnit.Framework; | ||
using osu.Framework.Allocation; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Online.API; | ||
using osu.Game.Online.API.Requests; | ||
using osu.Game.Online.API.Requests.Responses; | ||
using osu.Game.Overlays.BeatmapSetV2; | ||
using osu.Game.Rulesets; | ||
|
||
namespace osu.Game.Tests.Visual.Online | ||
{ | ||
public class TestSceneBeatmapInfoOverlay : OsuTestScene | ||
{ | ||
private BeatmapInfoOverlay beatmapInfoOverlay; | ||
|
||
[Resolved] | ||
private RulesetStore rulesets { get; set; } | ||
|
||
[SetUp] | ||
public void SetUp() => Schedule(() => | ||
{ | ||
((DummyAPIAccess)API).HandleRequest += r => | ||
{ | ||
switch (r) | ||
{ | ||
case PostBeatmapFavouriteRequest postBeatmapFavouriteRequest: | ||
Scheduler.AddDelayed(() => postBeatmapFavouriteRequest.TriggerSuccess(), 500); | ||
return true; | ||
} | ||
return false; | ||
}; | ||
Child = beatmapInfoOverlay = new BeatmapInfoOverlay(); | ||
}); | ||
|
||
[Test] | ||
public void TestNullBeatmapSet() | ||
{ | ||
AddStep("show null", () => beatmapInfoOverlay.ShowBeatmapSet(null)); | ||
} | ||
|
||
[Test] | ||
public void TestLocalBeatmapSet([Values(false, true)] bool hasExplicitContent) | ||
{ | ||
foreach (var status in Enum.GetValues(typeof(BeatmapSetOnlineStatus)).Cast<BeatmapSetOnlineStatus>()) | ||
AddStep($"show {status.ToString().ToLower()}", () => beatmapInfoOverlay.ShowBeatmapSet(createTestBeatmapSet(status, hasExplicitContent))); | ||
} | ||
|
||
private int setID; | ||
|
||
private APIBeatmapSet createTestBeatmapSet(BeatmapSetOnlineStatus status, bool hasExplicitContent) | ||
{ | ||
var set = new APIBeatmapSet | ||
{ | ||
OnlineID = ++setID, | ||
Title = "quaver", | ||
Artist = "dj TAKA", | ||
AuthorString = "Sotarks", | ||
Source = "REFLEC BEAT limelight", | ||
Tags = "risk junk beatmania iidx 19 lincle jubeat saucer jukebeat", | ||
Status = status, | ||
HasExplicitContent = hasExplicitContent, | ||
HasFavourited = true, | ||
FavouriteCount = 2593, | ||
Genre = new BeatmapSetOnlineGenre { Name = "Video Game (Instrumental)" }, | ||
Language = new BeatmapSetOnlineLanguage { Name = "Instrumental" }, | ||
Covers = new BeatmapSetOnlineCovers | ||
{ | ||
Cover = "https://s3-alpha-sig.figma.com/img/d95c/56af/cc030fa23122fcb38db25d02288a977d?Expires=1636329600&Signature=bmpZcUhqCWXY8dqyEC5u5~Ev0L04BoxxYaBlyZiI9MyNJqj41S2869DOicjxLejNJtig5kuFaXpv31oB5qUAcve4B5xE0CVKnsKWZWHJag-N5zdIXvCciGYEPnG-YGqZJ-oICvS-Byhae6PcC0sAu0IwIHTEV-TJIhj3KTHWFEFy12fKMrElsas8BmlPF7niy7cbY3OQjcIXmeoiYUdGTBNxnLOIWhHmnQM-VzUQa~cJEATPmPAJFRw8Lolf~we754pDGwMP~joIiX0palLEbipEo~3iU4MfXoTjpYqMlE2QiH3IRwpgjD5~6rTZshv2XD8-Kkw~eka8jejpQ976xw__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA" | ||
}, | ||
Submitted = new DateTime(2018, 11, 4, 0, 0, 0), | ||
Ranked = new DateTime(2019, 1, 6, 0, 0, 0), | ||
Ratings = new[] | ||
{ | ||
0, | ||
1320, | ||
193, | ||
157, | ||
290, | ||
359, | ||
398, | ||
773, | ||
1477, | ||
2792, | ||
15922 | ||
}, | ||
}; | ||
|
||
set.Beatmaps = Enumerable.Range(0, 32).Select(i => | ||
{ | ||
var beatmap = createTestBeatmap(set, i); | ||
beatmap.RulesetID = i % 4; | ||
return beatmap; | ||
}).ToArray(); | ||
|
||
return set; | ||
} | ||
|
||
private static APIBeatmap createTestBeatmap(APIBeatmapSet beatmapSet, int index) => new APIBeatmap | ||
{ | ||
OnlineID = 1000 + index, | ||
BeatmapSet = beatmapSet, | ||
DifficultyName = "Very Long Difficulty Name", | ||
ApproachRate = 6.78f + index * 0.09f, | ||
CircleSize = 4f + (index / 5) * 1, | ||
DrainRate = 5.29f + index * 0.2f, | ||
OverallDifficulty = 4.6f + index * 0.19f, | ||
StarRating = 1.50 + index * 0.525, | ||
Length = 203000 + index * 1234, | ||
BPM = 140 + index * 5, | ||
CircleCount = 325 + index * 4, | ||
SliderCount = 140 + index * 2, | ||
PlayCount = 3945834 + index * 164348, | ||
PassCount = 3274821 + index * 73234, | ||
FailTimes = new APIFailTimes | ||
{ | ||
Fails = new[] | ||
{ | ||
1208, | ||
144, | ||
135, | ||
933, | ||
646, | ||
186, | ||
2543, | ||
1913, | ||
392571, | ||
2683758, | ||
2056339, | ||
6948934, | ||
343499, | ||
126522, | ||
349490, | ||
729544, | ||
1027766, | ||
1409685, | ||
1377226, | ||
478937, | ||
224993, | ||
285757, | ||
46954, | ||
31898, | ||
26637, | ||
131522, | ||
92903, | ||
140571, | ||
25960, | ||
165, | ||
145, | ||
156, | ||
160, | ||
143, | ||
159, | ||
161, | ||
10076, | ||
36669, | ||
36215, | ||
20036, | ||
43462, | ||
124668, | ||
81752, | ||
9792, | ||
2909, | ||
5338, | ||
1046, | ||
769, | ||
8945, | ||
12281, | ||
5424, | ||
3685, | ||
14123, | ||
26408, | ||
16485, | ||
5824, | ||
1915, | ||
1781, | ||
494, | ||
4262, | ||
1896, | ||
155, | ||
149, | ||
197, | ||
153, | ||
151, | ||
155, | ||
365, | ||
26386, | ||
89990, | ||
61557, | ||
36736, | ||
18618, | ||
39772, | ||
20801, | ||
3528, | ||
1525, | ||
2882, | ||
3944, | ||
12139, | ||
8329, | ||
12280, | ||
15101, | ||
3929, | ||
14595, | ||
9096, | ||
19166, | ||
35912, | ||
22182, | ||
32425, | ||
85420, | ||
25018, | ||
12053, | ||
26222, | ||
12151, | ||
123739, | ||
28766, | ||
4664, | ||
26386, | ||
118075 | ||
}, | ||
}, | ||
}; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
osu.Game.Tests/Visual/Online/TestSceneBeatmapInfoOverlayDetails.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,40 @@ | ||
// 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 NUnit.Framework; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Overlays; | ||
using osu.Game.Overlays.BeatmapSetV2.Info; | ||
using osu.Game.Tests.Beatmaps; | ||
|
||
namespace osu.Game.Tests.Visual.Online | ||
{ | ||
public class TestSceneBeatmapInfoOverlayDetails : OsuTestScene | ||
{ | ||
private Bindable<BeatmapInfo> beatmap; | ||
|
||
[SetUp] | ||
public void SetUp() => Schedule(() => | ||
{ | ||
beatmap = new Bindable<BeatmapInfo>(new TestBeatmap(Ruleset.Value).BeatmapInfo); | ||
Child = new DependencyProvidingContainer | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
CachedDependencies = new (Type, object)[] | ||
{ | ||
(typeof(Bindable<BeatmapInfo>), beatmap), | ||
(typeof(OverlayColourProvider), new OverlayColourProvider(OverlayColourScheme.Seafoam)) | ||
}, | ||
Child = new BeatmapInfoDetails | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
}, | ||
}; | ||
}); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
osu.Game.Tests/Visual/Online/TestSceneOnlineBeatmapInfoOverlay.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,25 @@ | ||
// 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.Game.Overlays.BeatmapSetV2; | ||
|
||
namespace osu.Game.Tests.Visual.Online | ||
{ | ||
public class TestSceneOnlineBeatmapInfoOverlay : OsuTestScene | ||
{ | ||
protected override bool UseOnlineAPI => true; | ||
|
||
private BeatmapInfoOverlay beatmapInfoOverlay; | ||
|
||
[SetUp] | ||
public void SetUp() => Schedule(() => Child = beatmapInfoOverlay = new BeatmapInfoOverlay()); | ||
|
||
[Test] | ||
public void TestOnlineBeatmapSet() | ||
{ | ||
AddStep("show 'my love'", () => beatmapInfoOverlay.FetchAndShowBeatmapSet(163112)); | ||
AddStep("show 'soleily' mania", () => beatmapInfoOverlay.FetchAndShowBeatmap(557819)); | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
osu.Game/Beatmaps/Drawables/BeatmapSetOnlineExplicitPill.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,61 @@ | ||
// 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 osu.Framework.Extensions.LocalisationExtensions; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Shapes; | ||
using osu.Game.Graphics; | ||
using osu.Game.Graphics.Sprites; | ||
using osu.Game.Resources.Localisation.Web; | ||
using osuTK.Graphics; | ||
|
||
namespace osu.Game.Beatmaps.Drawables | ||
{ | ||
public class BeatmapSetOnlineExplicitPill : CircularContainer | ||
{ | ||
private readonly Box background; | ||
private readonly OsuSpriteText label; | ||
|
||
public float BackgroundAlpha | ||
{ | ||
get => background.Alpha; | ||
set => background.Alpha = value; | ||
} | ||
|
||
public float TextSize | ||
{ | ||
get => label.Font.Size; | ||
set => label.Font = label.Font.With(size: value); | ||
} | ||
|
||
public MarginPadding TextPadding | ||
{ | ||
get => label.Padding; | ||
set => label.Padding = value; | ||
} | ||
|
||
public BeatmapSetOnlineExplicitPill() | ||
{ | ||
Masking = true; | ||
|
||
Children = new Drawable[] | ||
{ | ||
background = new Box | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Colour = Color4.Black, | ||
}, | ||
label = new OsuSpriteText | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
Font = OsuFont.GetFont(weight: FontWeight.Bold), | ||
Text = BeatmapsetsStrings.NsfwBadgeLabel.ToUpper(), | ||
}, | ||
}; | ||
|
||
TextPadding = new MarginPadding { Horizontal = 5f, Bottom = 1f }; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.