1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 07:32:55 +08:00

Implemented sorting in TestCasePlaySong

This commit is contained in:
Alex Amadori 2017-02-18 15:11:40 +01:00
parent 1cd93f79b3
commit 6bbbbd8f96
4 changed files with 39 additions and 9 deletions

View File

@ -1,6 +1,7 @@
// 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;
using System.Collections.Generic;
using osu.Desktop.VisualTests.Platform;
using osu.Framework.GameModes.Testing;
@ -14,10 +15,17 @@ namespace osu.Desktop.VisualTests.Tests
{
private BeatmapDatabase db, oldDb;
private TestStorage storage;
private Random rnd = new Random();
private PlaySongSelect SongSelect = new PlaySongSelect();
public override string Name => @"Song Select";
public override string Description => @"with fake data";
public Action OnArtist;
public Action OnTitle;
public Action OnAuthor;
public Action OnDifficulty;
public override void Reset()
{
base.Reset();
@ -35,6 +43,16 @@ namespace osu.Desktop.VisualTests.Tests
db.Import(sets);
}
OnArtist = () => SongSelect.Filter.Sort = FilterControl.SortMode.Artist;
OnTitle = () => SongSelect.Filter.Sort = FilterControl.SortMode.Title;
OnAuthor = () => SongSelect.Filter.Sort = FilterControl.SortMode.Author;
OnDifficulty = () => SongSelect.Filter.Sort = FilterControl.SortMode.Difficulty;
AddButton(@"Sort by Artist", OnArtist);
AddButton(@"Sort by Artist", OnTitle);
AddButton(@"Sort by Artist", OnAuthor);
AddButton(@"Sort by Artist", OnDifficulty);
Add(new PlaySongSelect());
}
@ -59,9 +77,10 @@ namespace osu.Desktop.VisualTests.Tests
Metadata = new BeatmapMetadata
{
OnlineBeatmapSetID = 1234 + i,
Artist = "MONACA",
Title = "Black Song",
Author = "Some Guy",
// Create random metadata, then we can check if sorting works based on these
Artist = "MONACA " + rnd.Next(0, 9),
Title = "Black Song " + rnd.Next(0, 9),
Author = "Some Guy " + rnd.Next(0, 9),
},
Beatmaps = new List<BeatmapInfo>(new[]
{

View File

@ -199,13 +199,12 @@ namespace osu.Game.Screens.Select
case FilterControl.SortMode.Difficulty:
groups.Sort((x, y) =>
{
// TODO: replace with star rating once implemented
/*TODO: replace with star rating once implemented
* Assumes BeatmapSets not to be grouped - or to be by difficulty,
* otherwise this sorting makes little sense - or does it? */
if (x.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty >
y.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty)
return 1;
else if (Equals(x.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty,
y.BeatmapSet.Beatmaps.First().BaseDifficulty.OverallDifficulty))
return 0;
else
return -1;
});

View File

@ -21,7 +21,15 @@ namespace osu.Game.Screens.Select
public Action FilterChanged;
public string Search => searchTextBox.Text;
public SortMode Sort { get; private set; } = SortMode.Title;
private SortMode sort = SortMode.Title;
public SortMode Sort {
get { return sort; }
set {
sort = value;
FilterChanged?.Invoke();
}
}
public Action Exit;
private SearchTextBox searchTextBox;

View File

@ -54,8 +54,12 @@ namespace osu.Game.Screens.Select
private Footer footer;
private FilterControl filter;
public FilterControl Filter {
get; private set;
}
Player player;
FilterControl filter;
private void start()
{