2017-09-18 21:32:49 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2017-10-05 03:52:12 +08:00
|
|
|
using System.Linq;
|
2017-09-19 16:22:45 +08:00
|
|
|
using osu.Framework.Allocation;
|
2017-09-18 21:32:49 +08:00
|
|
|
using osu.Framework.MathUtils;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Database;
|
2017-09-19 16:22:45 +08:00
|
|
|
using osu.Game.IO;
|
2017-09-18 21:32:49 +08:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Screens.Select;
|
|
|
|
using osu.Game.Screens.Select.Filter;
|
|
|
|
using osu.Game.Tests.Platform;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
{
|
|
|
|
internal class TestCasePlaySongSelect : OsuTestCase
|
|
|
|
{
|
2017-09-19 16:22:45 +08:00
|
|
|
private BeatmapManager manager;
|
2017-09-18 21:32:49 +08:00
|
|
|
|
|
|
|
public override string Description => @"with fake data";
|
|
|
|
|
2017-09-19 16:22:45 +08:00
|
|
|
private RulesetStore rulesets;
|
2017-09-18 21:32:49 +08:00
|
|
|
|
2017-09-19 16:22:45 +08:00
|
|
|
private DependencyContainer dependencies;
|
|
|
|
|
|
|
|
private FileStore files;
|
|
|
|
|
|
|
|
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
|
|
|
PlaySongSelect songSelect;
|
|
|
|
|
|
|
|
if (manager == null)
|
|
|
|
{
|
|
|
|
var storage = new TestStorage(@"TestCasePlaySongSelect");
|
|
|
|
|
2017-10-05 03:52:12 +08:00
|
|
|
var dbConnectionString = storage.GetDatabaseConnectionString(@"client");
|
2017-09-18 21:32:49 +08:00
|
|
|
|
2017-10-05 03:52:12 +08:00
|
|
|
dependencies.Cache(rulesets = new RulesetStore(new OsuDbContext(dbConnectionString)));
|
|
|
|
dependencies.Cache(files = new FileStore(new OsuDbContext(dbConnectionString), storage));
|
|
|
|
dependencies.Cache(manager = new BeatmapManager(storage, files, new OsuDbContext(dbConnectionString), rulesets, null));
|
2017-09-18 21:32:49 +08:00
|
|
|
|
|
|
|
for (int i = 0; i < 100; i += 10)
|
|
|
|
manager.Import(createTestBeatmapSet(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
Add(songSelect = new PlaySongSelect());
|
|
|
|
|
|
|
|
AddStep(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; });
|
|
|
|
AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });
|
|
|
|
AddStep(@"Sort by Author", delegate { songSelect.FilterControl.Sort = SortMode.Author; });
|
|
|
|
AddStep(@"Sort by Difficulty", delegate { songSelect.FilterControl.Sort = SortMode.Difficulty; });
|
|
|
|
}
|
|
|
|
|
|
|
|
private BeatmapSetInfo createTestBeatmapSet(int i)
|
|
|
|
{
|
|
|
|
return new BeatmapSetInfo
|
|
|
|
{
|
2017-10-14 13:28:25 +08:00
|
|
|
OnlineBeatmapSetID = 1234 + i,
|
2017-09-18 21:32:49 +08:00
|
|
|
Hash = "d8e8fca2dc0f896fd7cb4cb0031ba249",
|
2017-10-06 05:23:26 +08:00
|
|
|
Metadata = new BeatmapMetadata
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
2017-10-14 13:28:25 +08:00
|
|
|
OnlineBeatmapSetID = 1234 + i,
|
2017-09-18 21:32:49 +08:00
|
|
|
// Create random metadata, then we can check if sorting works based on these
|
|
|
|
Artist = "MONACA " + RNG.Next(0, 9),
|
|
|
|
Title = "Black Song " + RNG.Next(0, 9),
|
2017-10-13 19:25:27 +08:00
|
|
|
AuthorString = "Some Guy " + RNG.Next(0, 9),
|
2017-09-18 21:32:49 +08:00
|
|
|
},
|
|
|
|
Beatmaps = new List<BeatmapInfo>(new[]
|
|
|
|
{
|
|
|
|
new BeatmapInfo
|
|
|
|
{
|
2017-10-14 13:28:25 +08:00
|
|
|
OnlineBeatmapID = 1234 + i,
|
2017-10-16 11:56:58 +08:00
|
|
|
Ruleset = rulesets.QueryRulesets().First(),
|
2017-09-18 21:32:49 +08:00
|
|
|
Path = "normal.osu",
|
|
|
|
Version = "Normal",
|
2017-10-06 05:23:26 +08:00
|
|
|
Difficulty = new BeatmapDifficulty
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
|
|
|
OverallDifficulty = 3.5f,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new BeatmapInfo
|
|
|
|
{
|
2017-10-14 13:28:25 +08:00
|
|
|
OnlineBeatmapID = 1235 + i,
|
2017-10-16 11:56:58 +08:00
|
|
|
Ruleset = rulesets.QueryRulesets().First(),
|
2017-09-18 21:32:49 +08:00
|
|
|
Path = "hard.osu",
|
|
|
|
Version = "Hard",
|
2017-10-06 05:23:26 +08:00
|
|
|
Difficulty = new BeatmapDifficulty
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
|
|
|
OverallDifficulty = 5,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new BeatmapInfo
|
|
|
|
{
|
2017-10-14 13:28:25 +08:00
|
|
|
OnlineBeatmapID = 1236 + i,
|
2017-10-16 11:56:58 +08:00
|
|
|
Ruleset = rulesets.QueryRulesets().First(),
|
2017-09-18 21:32:49 +08:00
|
|
|
Path = "insane.osu",
|
|
|
|
Version = "Insane",
|
2017-10-06 05:23:26 +08:00
|
|
|
Difficulty = new BeatmapDifficulty
|
2017-09-18 21:32:49 +08:00
|
|
|
{
|
|
|
|
OverallDifficulty = 7,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|