2019-06-27 10:40:22 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Overlays;
|
2018-04-18 15:04:02 +08:00
|
|
|
|
using osu.Game.Overlays.BeatmapSet;
|
|
|
|
|
using osu.Game.Overlays.BeatmapSet.Buttons;
|
|
|
|
|
using osu.Game.Overlays.BeatmapSet.Scores;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
using osu.Game.Users;
|
2019-02-06 00:32:33 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public class TestSceneBeatmapSetOverlay : OsuTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-06-27 03:42:34 +08:00
|
|
|
|
private readonly TestBeatmapSetOverlay overlay;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-04-18 15:04:02 +08:00
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
|
{
|
|
|
|
|
typeof(Header),
|
2019-03-26 16:38:56 +08:00
|
|
|
|
typeof(ScoreTable),
|
|
|
|
|
typeof(ScoreTableRowBackground),
|
2018-04-18 15:04:02 +08:00
|
|
|
|
typeof(DrawableTopScore),
|
|
|
|
|
typeof(ScoresContainer),
|
|
|
|
|
typeof(AuthorInfo),
|
|
|
|
|
typeof(BasicStats),
|
|
|
|
|
typeof(BeatmapPicker),
|
|
|
|
|
typeof(Details),
|
|
|
|
|
typeof(DownloadButton),
|
|
|
|
|
typeof(FavouriteButton),
|
|
|
|
|
typeof(Header),
|
|
|
|
|
typeof(HeaderButton),
|
|
|
|
|
typeof(Info),
|
|
|
|
|
typeof(PreviewButton),
|
|
|
|
|
typeof(SuccessRate),
|
2019-06-27 10:40:22 +08:00
|
|
|
|
typeof(BeatmapAvailability),
|
2018-04-18 15:04:02 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-06-13 17:14:57 +08:00
|
|
|
|
private RulesetInfo taikoRuleset;
|
2019-06-19 06:14:32 +08:00
|
|
|
|
private RulesetInfo maniaRuleset;
|
2019-06-13 17:14:57 +08:00
|
|
|
|
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public TestSceneBeatmapSetOverlay()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-06-27 03:42:34 +08:00
|
|
|
|
Add(overlay = new TestBeatmapSetOverlay());
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(RulesetStore rulesets)
|
|
|
|
|
{
|
2019-06-13 17:14:57 +08:00
|
|
|
|
taikoRuleset = rulesets.GetRuleset(1);
|
2019-06-19 06:14:32 +08:00
|
|
|
|
maniaRuleset = rulesets.GetRuleset(3);
|
2019-06-13 17:14:57 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-13 17:14:57 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestLoading()
|
|
|
|
|
{
|
2018-04-18 15:04:02 +08:00
|
|
|
|
AddStep(@"show loading", () => overlay.ShowBeatmapSet(null));
|
2019-06-13 17:14:57 +08:00
|
|
|
|
}
|
2018-04-18 15:04:02 +08:00
|
|
|
|
|
2019-06-13 17:14:57 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestOnline()
|
|
|
|
|
{
|
2018-04-18 15:04:02 +08:00
|
|
|
|
AddStep(@"show online", () => overlay.FetchAndShowBeatmapSet(55));
|
2019-06-13 17:14:57 +08:00
|
|
|
|
}
|
2018-04-18 15:04:02 +08:00
|
|
|
|
|
2019-06-13 17:14:57 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestLocalBeatmaps()
|
|
|
|
|
{
|
2018-04-13 17:19:50 +08:00
|
|
|
|
AddStep(@"show first", () =>
|
|
|
|
|
{
|
|
|
|
|
overlay.ShowBeatmapSet(new BeatmapSetInfo
|
|
|
|
|
{
|
2019-06-27 11:00:31 +08:00
|
|
|
|
OnlineBeatmapSetID = 1235,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
|
{
|
2019-06-27 11:00:31 +08:00
|
|
|
|
Title = @"an awesome beatmap",
|
|
|
|
|
Artist = @"naru narusegawa",
|
|
|
|
|
Source = @"hinata sou",
|
|
|
|
|
Tags = @"test tag tag more tag",
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Author = new User
|
|
|
|
|
{
|
2019-06-27 11:00:31 +08:00
|
|
|
|
Username = @"BanchoBot",
|
|
|
|
|
Id = 3,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
OnlineInfo = new BeatmapSetOnlineInfo
|
|
|
|
|
{
|
2019-06-27 11:00:31 +08:00
|
|
|
|
Preview = @"https://b.ppy.sh/preview/12345.mp3",
|
2019-06-27 12:48:57 +08:00
|
|
|
|
PlayCount = 123,
|
|
|
|
|
FavouriteCount = 456,
|
|
|
|
|
Submitted = DateTime.Now,
|
|
|
|
|
Ranked = DateTime.Now,
|
|
|
|
|
BPM = 111,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
HasVideo = true,
|
2019-06-27 12:48:57 +08:00
|
|
|
|
HasStoryboard = true,
|
|
|
|
|
Covers = new BeatmapSetOnlineCovers(),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2019-06-13 15:52:49 +08:00
|
|
|
|
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Beatmaps = new List<BeatmapInfo>
|
|
|
|
|
{
|
|
|
|
|
new BeatmapInfo
|
|
|
|
|
{
|
2019-06-27 12:48:57 +08:00
|
|
|
|
StarDifficulty = 9.99,
|
|
|
|
|
Version = @"TEST",
|
2019-06-13 17:14:57 +08:00
|
|
|
|
Ruleset = maniaRuleset,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
BaseDifficulty = new BeatmapDifficulty
|
|
|
|
|
{
|
2019-06-27 12:48:57 +08:00
|
|
|
|
CircleSize = 1,
|
|
|
|
|
DrainRate = 2.3f,
|
|
|
|
|
OverallDifficulty = 4.5f,
|
|
|
|
|
ApproachRate = 6,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
OnlineInfo = new BeatmapOnlineInfo
|
|
|
|
|
{
|
2019-06-27 12:48:57 +08:00
|
|
|
|
Length = 456000,
|
|
|
|
|
CircleCount = 111,
|
|
|
|
|
SliderCount = 12,
|
|
|
|
|
PlayCount = 222,
|
|
|
|
|
PassCount = 21,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
Metrics = new BeatmapMetrics
|
|
|
|
|
{
|
2019-06-13 15:30:38 +08:00
|
|
|
|
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
|
|
|
|
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-06-27 11:00:31 +08:00
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
});
|
2019-06-26 10:17:28 +08:00
|
|
|
|
|
2019-06-19 08:37:08 +08:00
|
|
|
|
downloadAssert(true);
|
2019-06-26 10:01:29 +08:00
|
|
|
|
}
|
2019-06-19 08:37:08 +08:00
|
|
|
|
|
2019-06-26 10:01:29 +08:00
|
|
|
|
[Test]
|
2019-06-27 12:48:57 +08:00
|
|
|
|
public void TestAvailability()
|
2019-06-26 10:01:29 +08:00
|
|
|
|
{
|
|
|
|
|
AddStep(@"show undownloadable", () =>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
overlay.ShowBeatmapSet(new BeatmapSetInfo
|
|
|
|
|
{
|
2019-06-27 11:00:31 +08:00
|
|
|
|
OnlineBeatmapSetID = 1234,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
|
{
|
2019-06-27 12:48:57 +08:00
|
|
|
|
Title = @"undownloadable beatmap",
|
|
|
|
|
Artist = @"no one",
|
|
|
|
|
Source = @"some source",
|
|
|
|
|
Tags = @"another test tag tag more test tags",
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Author = new User
|
|
|
|
|
{
|
2019-06-27 12:48:57 +08:00
|
|
|
|
Username = @"BanchoBot",
|
|
|
|
|
Id = 3,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
OnlineInfo = new BeatmapSetOnlineInfo
|
|
|
|
|
{
|
2019-06-26 10:01:29 +08:00
|
|
|
|
Availability = new BeatmapSetOnlineAvailability
|
|
|
|
|
{
|
|
|
|
|
DownloadDisabled = true,
|
|
|
|
|
ExternalLink = "https://osu.ppy.sh",
|
|
|
|
|
},
|
2019-06-27 12:48:57 +08:00
|
|
|
|
Preview = @"https://b.ppy.sh/preview/1234.mp3",
|
|
|
|
|
PlayCount = 123,
|
|
|
|
|
FavouriteCount = 456,
|
|
|
|
|
Submitted = DateTime.Now,
|
|
|
|
|
Ranked = DateTime.Now,
|
|
|
|
|
BPM = 111,
|
|
|
|
|
HasVideo = true,
|
|
|
|
|
HasStoryboard = true,
|
|
|
|
|
Covers = new BeatmapSetOnlineCovers(),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2019-06-13 15:52:49 +08:00
|
|
|
|
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Beatmaps = new List<BeatmapInfo>
|
|
|
|
|
{
|
|
|
|
|
new BeatmapInfo
|
|
|
|
|
{
|
2019-06-27 12:48:57 +08:00
|
|
|
|
StarDifficulty = 5.67,
|
|
|
|
|
Version = @"ANOTHER TEST",
|
2019-06-13 17:14:57 +08:00
|
|
|
|
Ruleset = taikoRuleset,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
BaseDifficulty = new BeatmapDifficulty
|
|
|
|
|
{
|
2019-06-27 12:48:57 +08:00
|
|
|
|
CircleSize = 9,
|
|
|
|
|
DrainRate = 8,
|
|
|
|
|
OverallDifficulty = 7,
|
|
|
|
|
ApproachRate = 6,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
OnlineInfo = new BeatmapOnlineInfo
|
|
|
|
|
{
|
2019-06-27 12:48:57 +08:00
|
|
|
|
Length = 123000,
|
|
|
|
|
CircleCount = 123,
|
|
|
|
|
SliderCount = 45,
|
|
|
|
|
PlayCount = 567,
|
|
|
|
|
PassCount = 89,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
Metrics = new BeatmapMetrics
|
|
|
|
|
{
|
2019-06-13 15:30:38 +08:00
|
|
|
|
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
|
|
|
|
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-06-27 11:00:31 +08:00
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
});
|
2019-06-26 10:17:28 +08:00
|
|
|
|
|
2019-06-25 08:21:55 +08:00
|
|
|
|
downloadAssert(false);
|
2019-06-13 17:14:57 +08:00
|
|
|
|
}
|
2019-06-13 01:42:52 +08:00
|
|
|
|
|
2019-06-13 17:14:57 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestHide()
|
|
|
|
|
{
|
2018-04-13 17:19:50 +08:00
|
|
|
|
AddStep(@"hide", overlay.Hide);
|
2019-06-13 17:14:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestShowWithNoReload()
|
|
|
|
|
{
|
2018-04-13 17:19:50 +08:00
|
|
|
|
AddStep(@"show without reload", overlay.Show);
|
|
|
|
|
}
|
2019-06-25 08:21:55 +08:00
|
|
|
|
|
|
|
|
|
private void downloadAssert(bool shown)
|
|
|
|
|
{
|
2019-06-27 11:11:04 +08:00
|
|
|
|
AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.DownloadButtonsVisible == shown);
|
2019-06-27 03:42:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestBeatmapSetOverlay : BeatmapSetOverlay
|
|
|
|
|
{
|
2019-06-27 11:47:05 +08:00
|
|
|
|
public bool DownloadButtonsVisible => Header.DownloadButtonsVisible;
|
2019-06-25 08:21:55 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|