2017-02-07 12:59:30 +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
|
2016-11-23 19:38:33 +08:00
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Desktop.VisualTests.Platform;
|
2017-03-28 20:03:34 +08:00
|
|
|
using osu.Framework.Testing;
|
2017-02-21 00:49:02 +08:00
|
|
|
using osu.Framework.MathUtils;
|
2016-11-23 19:38:33 +08:00
|
|
|
using osu.Game.Database;
|
|
|
|
using osu.Game.Modes;
|
|
|
|
using osu.Game.Screens.Select;
|
2017-03-05 12:07:47 +08:00
|
|
|
using osu.Game.Screens.Select.Filter;
|
2016-11-23 19:38:33 +08:00
|
|
|
|
|
|
|
namespace osu.Desktop.VisualTests.Tests
|
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
internal class TestCasePlaySongSelect : TestCase
|
2016-11-23 19:38:33 +08:00
|
|
|
{
|
2016-11-25 18:12:01 +08:00
|
|
|
private BeatmapDatabase db, oldDb;
|
2016-11-23 19:38:33 +08:00
|
|
|
private TestStorage storage;
|
2017-02-18 23:45:46 +08:00
|
|
|
private PlaySongSelect songSelect;
|
2016-11-23 19:38:33 +08:00
|
|
|
|
2016-10-27 16:38:23 +08:00
|
|
|
public override string Description => @"with fake data";
|
2016-10-27 16:08:53 +08:00
|
|
|
|
2016-11-23 19:38:33 +08:00
|
|
|
public override void Reset()
|
|
|
|
{
|
2016-10-27 16:08:53 +08:00
|
|
|
base.Reset();
|
2016-10-27 16:38:38 +08:00
|
|
|
if (db == null)
|
|
|
|
{
|
|
|
|
storage = new TestStorage(@"TestCasePlaySongSelect");
|
|
|
|
db = new BeatmapDatabase(storage);
|
2016-10-27 16:35:00 +08:00
|
|
|
|
2016-10-27 16:38:38 +08:00
|
|
|
var sets = new List<BeatmapSetInfo>();
|
|
|
|
|
|
|
|
for (int i = 0; i < 100; i += 10)
|
|
|
|
sets.Add(createTestBeatmapSet(i));
|
|
|
|
|
|
|
|
db.Import(sets);
|
|
|
|
}
|
2017-02-18 23:23:13 +08:00
|
|
|
|
2017-02-18 23:45:46 +08:00
|
|
|
Add(songSelect = new PlaySongSelect());
|
2017-02-18 22:11:40 +08:00
|
|
|
|
2017-03-31 16:55:07 +08:00
|
|
|
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; });
|
2016-10-27 16:08:53 +08:00
|
|
|
}
|
2017-02-18 22:56:29 +08:00
|
|
|
|
2016-11-25 18:12:01 +08:00
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
2016-11-28 11:25:20 +08:00
|
|
|
if (oldDb != null)
|
2017-01-24 16:02:11 +08:00
|
|
|
db = null;
|
|
|
|
|
2016-11-25 18:12:01 +08:00
|
|
|
base.Dispose(isDisposing);
|
|
|
|
}
|
2016-10-27 16:08:53 +08:00
|
|
|
|
|
|
|
private BeatmapSetInfo createTestBeatmapSet(int i)
|
|
|
|
{
|
|
|
|
return new BeatmapSetInfo
|
|
|
|
{
|
2017-01-09 21:05:01 +08:00
|
|
|
OnlineBeatmapSetID = 1234 + i,
|
2016-10-27 16:08:53 +08:00
|
|
|
Hash = "d8e8fca2dc0f896fd7cb4cb0031ba249",
|
|
|
|
Path = string.Empty,
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
{
|
2017-01-09 21:05:01 +08:00
|
|
|
OnlineBeatmapSetID = 1234 + i,
|
2017-02-18 22:11:40 +08:00
|
|
|
// Create random metadata, then we can check if sorting works based on these
|
2017-02-21 00:49:02 +08:00
|
|
|
Artist = "MONACA " + RNG.Next(0, 9),
|
|
|
|
Title = "Black Song " + RNG.Next(0, 9),
|
|
|
|
Author = "Some Guy " + RNG.Next(0, 9),
|
2016-10-27 16:08:53 +08:00
|
|
|
},
|
|
|
|
Beatmaps = new List<BeatmapInfo>(new[]
|
|
|
|
{
|
|
|
|
new BeatmapInfo
|
|
|
|
{
|
2017-01-09 21:05:01 +08:00
|
|
|
OnlineBeatmapID = 1234 + i,
|
2016-10-27 16:08:53 +08:00
|
|
|
Mode = PlayMode.Osu,
|
|
|
|
Path = "normal.osu",
|
|
|
|
Version = "Normal",
|
2017-03-16 22:18:02 +08:00
|
|
|
Difficulty = new BeatmapDifficulty
|
2016-10-27 16:08:53 +08:00
|
|
|
{
|
|
|
|
OverallDifficulty = 3.5f,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new BeatmapInfo
|
|
|
|
{
|
2017-01-09 21:05:01 +08:00
|
|
|
OnlineBeatmapID = 1235 + i,
|
2016-10-27 16:08:53 +08:00
|
|
|
Mode = PlayMode.Osu,
|
|
|
|
Path = "hard.osu",
|
|
|
|
Version = "Hard",
|
2017-03-16 22:18:02 +08:00
|
|
|
Difficulty = new BeatmapDifficulty
|
2016-10-27 16:08:53 +08:00
|
|
|
{
|
|
|
|
OverallDifficulty = 5,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new BeatmapInfo
|
|
|
|
{
|
2017-01-09 21:05:01 +08:00
|
|
|
OnlineBeatmapID = 1236 + i,
|
2016-10-27 16:08:53 +08:00
|
|
|
Mode = PlayMode.Osu,
|
|
|
|
Path = "insane.osu",
|
|
|
|
Version = "Insane",
|
2017-03-16 22:18:02 +08:00
|
|
|
Difficulty = new BeatmapDifficulty
|
2016-10-27 16:08:53 +08:00
|
|
|
{
|
|
|
|
OverallDifficulty = 7,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
};
|
2016-11-23 19:38:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|