2019-01-24 16:43:03 +08:00
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2019-05-31 13:40:53 +08:00
|
|
|
using osu.Framework.Audio;
|
2019-02-21 18:04:31 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Extensions;
|
2020-01-09 12:43:44 +08:00
|
|
|
using osu.Framework.Utils;
|
2019-01-22 19:37:41 +08:00
|
|
|
using osu.Framework.Platform;
|
2019-02-15 16:01:06 +08:00
|
|
|
using osu.Framework.Screens;
|
2020-01-27 11:21:17 +08:00
|
|
|
using osu.Framework.Testing;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2019-08-27 13:31:34 +08:00
|
|
|
using osu.Game.Configuration;
|
2020-02-10 15:59:49 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2019-10-08 15:37:34 +08:00
|
|
|
using osu.Game.Overlays;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Rulesets;
|
2018-08-14 13:18:46 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-06-14 19:18:22 +08:00
|
|
|
using osu.Game.Rulesets.Osu;
|
2018-08-14 13:18:46 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
using osu.Game.Rulesets.Taiko;
|
2020-02-03 15:04:32 +08:00
|
|
|
using osu.Game.Screens.Play;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Screens.Select;
|
|
|
|
using osu.Game.Screens.Select.Carousel;
|
|
|
|
using osu.Game.Screens.Select.Filter;
|
2020-01-27 11:21:17 +08:00
|
|
|
using osuTK.Input;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
namespace osu.Game.Tests.Visual.SongSelect
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
[TestFixture]
|
2019-05-15 03:37:25 +08:00
|
|
|
public class TestScenePlaySongSelect : ScreenTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
private BeatmapManager manager;
|
|
|
|
|
|
|
|
private RulesetStore rulesets;
|
|
|
|
|
2019-10-08 15:37:34 +08:00
|
|
|
private MusicController music;
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
private WorkingBeatmap defaultBeatmap;
|
|
|
|
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
{
|
2019-03-25 00:02:36 +08:00
|
|
|
typeof(Screens.Select.SongSelect),
|
2018-04-13 17:19:50 +08:00
|
|
|
typeof(BeatmapCarousel),
|
|
|
|
|
|
|
|
typeof(CarouselItem),
|
|
|
|
typeof(CarouselGroup),
|
|
|
|
typeof(CarouselGroupEagerSelect),
|
|
|
|
typeof(CarouselBeatmap),
|
|
|
|
typeof(CarouselBeatmapSet),
|
|
|
|
|
|
|
|
typeof(DrawableCarouselItem),
|
|
|
|
typeof(CarouselItemState),
|
|
|
|
|
|
|
|
typeof(DrawableCarouselBeatmap),
|
|
|
|
typeof(DrawableCarouselBeatmapSet),
|
|
|
|
};
|
|
|
|
|
2018-07-18 11:58:45 +08:00
|
|
|
private TestSongSelect songSelect;
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2019-05-31 13:40:53 +08:00
|
|
|
private void load(GameHost host, AudioManager audio)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-07-29 15:55:19 +08:00
|
|
|
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
|
|
|
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, defaultBeatmap = Beatmap.Default));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-10-08 15:37:34 +08:00
|
|
|
Dependencies.Cache(music = new MusicController());
|
|
|
|
|
|
|
|
// required to get bindables attached
|
|
|
|
Add(music);
|
|
|
|
|
2019-08-27 13:31:34 +08:00
|
|
|
Dependencies.Cache(config = new OsuConfigManager(LocalStorage));
|
2018-07-18 11:58:45 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-08-27 13:31:34 +08:00
|
|
|
private OsuConfigManager config;
|
|
|
|
|
2020-01-31 12:54:26 +08:00
|
|
|
public override void SetUpSteps()
|
2019-06-14 19:18:22 +08:00
|
|
|
{
|
2020-01-31 12:54:26 +08:00
|
|
|
base.SetUpSteps();
|
|
|
|
|
|
|
|
AddStep("delete all beatmaps", () =>
|
|
|
|
{
|
|
|
|
Ruleset.Value = new OsuRuleset().RulesetInfo;
|
|
|
|
manager?.Delete(manager.GetAllUsableBeatmapSets());
|
2020-01-31 15:14:55 +08:00
|
|
|
|
|
|
|
Beatmap.SetDefault();
|
2020-01-31 12:54:26 +08:00
|
|
|
});
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-11-13 17:54:33 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSingleFilterOnEnter()
|
|
|
|
{
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
|
|
|
|
createSongSelect();
|
|
|
|
|
|
|
|
AddAssert("filter count is 1", () => songSelect.FilterCount == 1);
|
|
|
|
}
|
|
|
|
|
2020-01-27 11:21:17 +08:00
|
|
|
[Test]
|
|
|
|
public void TestChangeBeatmapBeforeEnter()
|
|
|
|
{
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
|
|
|
|
createSongSelect();
|
|
|
|
|
2020-01-27 17:26:44 +08:00
|
|
|
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
|
|
|
|
|
2020-01-27 11:21:17 +08:00
|
|
|
WorkingBeatmap selected = null;
|
|
|
|
|
|
|
|
AddStep("store selected beatmap", () => selected = Beatmap.Value);
|
|
|
|
|
|
|
|
AddStep("select next and enter", () =>
|
|
|
|
{
|
|
|
|
InputManager.PressKey(Key.Down);
|
|
|
|
InputManager.ReleaseKey(Key.Down);
|
|
|
|
InputManager.PressKey(Key.Enter);
|
|
|
|
InputManager.ReleaseKey(Key.Enter);
|
|
|
|
});
|
|
|
|
|
2020-01-29 12:54:12 +08:00
|
|
|
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
|
2020-01-27 11:21:17 +08:00
|
|
|
AddAssert("ensure selection changed", () => selected != Beatmap.Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestChangeBeatmapAfterEnter()
|
|
|
|
{
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
|
|
|
|
createSongSelect();
|
|
|
|
|
2020-01-27 17:26:44 +08:00
|
|
|
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
|
|
|
|
|
2020-01-27 11:21:17 +08:00
|
|
|
WorkingBeatmap selected = null;
|
|
|
|
|
|
|
|
AddStep("store selected beatmap", () => selected = Beatmap.Value);
|
|
|
|
|
|
|
|
AddStep("select next and enter", () =>
|
|
|
|
{
|
|
|
|
InputManager.PressKey(Key.Enter);
|
|
|
|
InputManager.ReleaseKey(Key.Enter);
|
|
|
|
InputManager.PressKey(Key.Down);
|
|
|
|
InputManager.ReleaseKey(Key.Down);
|
|
|
|
});
|
|
|
|
|
2020-01-29 12:54:12 +08:00
|
|
|
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
|
2020-01-27 11:21:17 +08:00
|
|
|
AddAssert("ensure selection didn't change", () => selected == Beatmap.Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestChangeBeatmapViaMouseBeforeEnter()
|
|
|
|
{
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
|
|
|
|
createSongSelect();
|
|
|
|
|
2020-01-27 17:26:44 +08:00
|
|
|
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
|
|
|
|
|
2020-01-27 11:21:17 +08:00
|
|
|
WorkingBeatmap selected = null;
|
|
|
|
|
|
|
|
AddStep("store selected beatmap", () => selected = Beatmap.Value);
|
|
|
|
|
|
|
|
AddStep("select next and enter", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
|
|
|
|
.First(b => ((CarouselBeatmap)b.Item).Beatmap != songSelect.Carousel.SelectedBeatmap));
|
|
|
|
|
|
|
|
InputManager.PressButton(MouseButton.Left);
|
|
|
|
InputManager.ReleaseButton(MouseButton.Left);
|
|
|
|
|
|
|
|
InputManager.PressKey(Key.Enter);
|
|
|
|
InputManager.ReleaseKey(Key.Enter);
|
|
|
|
});
|
|
|
|
|
2020-01-29 12:54:12 +08:00
|
|
|
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
|
2020-01-27 11:21:17 +08:00
|
|
|
AddAssert("ensure selection changed", () => selected != Beatmap.Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestChangeBeatmapViaMouseAfterEnter()
|
|
|
|
{
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
|
|
|
|
createSongSelect();
|
|
|
|
|
2020-01-27 17:26:44 +08:00
|
|
|
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
|
|
|
|
|
2020-01-27 11:21:17 +08:00
|
|
|
WorkingBeatmap selected = null;
|
|
|
|
|
|
|
|
AddStep("store selected beatmap", () => selected = Beatmap.Value);
|
|
|
|
|
|
|
|
AddStep("select next and enter", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
|
|
|
|
.First(b => ((CarouselBeatmap)b.Item).Beatmap != songSelect.Carousel.SelectedBeatmap));
|
|
|
|
|
|
|
|
InputManager.PressButton(MouseButton.Left);
|
|
|
|
|
|
|
|
InputManager.PressKey(Key.Enter);
|
|
|
|
InputManager.ReleaseKey(Key.Enter);
|
|
|
|
|
|
|
|
InputManager.ReleaseButton(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
2020-01-29 12:54:12 +08:00
|
|
|
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
|
2020-01-27 11:21:17 +08:00
|
|
|
AddAssert("ensure selection didn't change", () => selected == Beatmap.Value);
|
|
|
|
}
|
|
|
|
|
2019-12-10 01:30:23 +08:00
|
|
|
[Test]
|
|
|
|
public void TestNoFilterOnSimpleResume()
|
|
|
|
{
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
|
|
|
|
createSongSelect();
|
|
|
|
|
|
|
|
AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child")));
|
|
|
|
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
|
|
|
|
|
|
|
|
AddStep("return", () => songSelect.MakeCurrent());
|
|
|
|
AddUntilStep("wait for current", () => songSelect.IsCurrentScreen());
|
|
|
|
AddAssert("filter count is 1", () => songSelect.FilterCount == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFilterOnResumeAfterChange()
|
|
|
|
{
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
|
|
|
|
AddStep("change convert setting", () => config.Set(OsuSetting.ShowConvertedBeatmaps, false));
|
|
|
|
|
|
|
|
createSongSelect();
|
|
|
|
|
|
|
|
AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child")));
|
|
|
|
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
|
|
|
|
|
|
|
|
AddStep("change convert setting", () => config.Set(OsuSetting.ShowConvertedBeatmaps, true));
|
|
|
|
|
|
|
|
AddStep("return", () => songSelect.MakeCurrent());
|
|
|
|
AddUntilStep("wait for current", () => songSelect.IsCurrentScreen());
|
|
|
|
AddAssert("filter count is 2", () => songSelect.FilterCount == 2);
|
|
|
|
}
|
|
|
|
|
2019-10-08 15:37:34 +08:00
|
|
|
[Test]
|
|
|
|
public void TestAudioResuming()
|
|
|
|
{
|
|
|
|
createSongSelect();
|
|
|
|
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
|
|
|
|
checkMusicPlaying(true);
|
|
|
|
AddStep("select first", () => songSelect.Carousel.SelectBeatmap(songSelect.Carousel.BeatmapSets.First().Beatmaps.First()));
|
|
|
|
checkMusicPlaying(true);
|
|
|
|
|
|
|
|
AddStep("manual pause", () => music.TogglePause());
|
|
|
|
checkMusicPlaying(false);
|
|
|
|
AddStep("select next difficulty", () => songSelect.Carousel.SelectNext(skipDifficulties: false));
|
|
|
|
checkMusicPlaying(false);
|
|
|
|
|
|
|
|
AddStep("select next set", () => songSelect.Carousel.SelectNext());
|
|
|
|
checkMusicPlaying(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(false)]
|
|
|
|
[TestCase(true)]
|
|
|
|
public void TestAudioRemainsCorrectOnRulesetChange(bool rulesetsInSameBeatmap)
|
|
|
|
{
|
|
|
|
createSongSelect();
|
|
|
|
|
|
|
|
// start with non-osu! to avoid convert confusion
|
|
|
|
changeRuleset(1);
|
|
|
|
|
|
|
|
if (rulesetsInSameBeatmap)
|
2019-11-11 19:53:22 +08:00
|
|
|
{
|
2019-10-08 15:37:34 +08:00
|
|
|
AddStep("import multi-ruleset map", () =>
|
|
|
|
{
|
|
|
|
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray();
|
|
|
|
manager.Import(createTestBeatmapSet(0, usableRulesets)).Wait();
|
|
|
|
});
|
2019-11-11 19:53:22 +08:00
|
|
|
}
|
2019-10-08 15:37:34 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
addRulesetImportStep(1);
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
checkMusicPlaying(true);
|
|
|
|
|
|
|
|
AddStep("manual pause", () => music.TogglePause());
|
|
|
|
checkMusicPlaying(false);
|
|
|
|
|
|
|
|
changeRuleset(0);
|
|
|
|
checkMusicPlaying(!rulesetsInSameBeatmap);
|
|
|
|
}
|
|
|
|
|
2018-07-20 10:32:00 +08:00
|
|
|
[Test]
|
2018-07-18 11:58:45 +08:00
|
|
|
public void TestDummy()
|
|
|
|
{
|
2019-02-15 20:50:40 +08:00
|
|
|
createSongSelect();
|
2018-04-13 17:19:50 +08:00
|
|
|
AddAssert("dummy selected", () => songSelect.CurrentBeatmap == defaultBeatmap);
|
|
|
|
|
2019-03-19 16:24:26 +08:00
|
|
|
AddUntilStep("dummy shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap == defaultBeatmap);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-07-18 11:58:45 +08:00
|
|
|
addManyTestMaps();
|
2019-03-19 16:24:26 +08:00
|
|
|
AddWaitStep("wait for select", 3);
|
2018-07-18 11:58:45 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
2018-07-18 11:58:45 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-07-20 10:32:00 +08:00
|
|
|
[Test]
|
2018-07-18 11:58:45 +08:00
|
|
|
public void TestSorting()
|
|
|
|
{
|
2019-02-15 20:50:40 +08:00
|
|
|
createSongSelect();
|
2018-07-18 11:58:45 +08:00
|
|
|
addManyTestMaps();
|
2019-03-19 16:24:26 +08:00
|
|
|
AddWaitStep("wait for add", 3);
|
2018-07-18 11:58:45 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
|
|
|
|
|
2019-08-27 13:31:34 +08:00
|
|
|
var sortMode = config.GetBindable<SortMode>(OsuSetting.SongSelectSortingMode);
|
|
|
|
|
|
|
|
AddStep(@"Sort by Artist", delegate { sortMode.Value = SortMode.Artist; });
|
|
|
|
AddStep(@"Sort by Title", delegate { sortMode.Value = SortMode.Title; });
|
|
|
|
AddStep(@"Sort by Author", delegate { sortMode.Value = SortMode.Author; });
|
|
|
|
AddStep(@"Sort by DateAdded", delegate { sortMode.Value = SortMode.DateAdded; });
|
|
|
|
AddStep(@"Sort by BPM", delegate { sortMode.Value = SortMode.BPM; });
|
|
|
|
AddStep(@"Sort by Length", delegate { sortMode.Value = SortMode.Length; });
|
|
|
|
AddStep(@"Sort by Difficulty", delegate { sortMode.Value = SortMode.Difficulty; });
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
2018-07-18 11:58:45 +08:00
|
|
|
[Test]
|
2018-08-14 13:19:26 +08:00
|
|
|
public void TestImportUnderDifferentRuleset()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-02-15 20:50:40 +08:00
|
|
|
createSongSelect();
|
2019-10-08 15:37:47 +08:00
|
|
|
addRulesetImportStep(2);
|
2019-03-19 16:24:26 +08:00
|
|
|
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
2018-07-20 10:32:00 +08:00
|
|
|
}
|
2018-07-19 17:51:08 +08:00
|
|
|
|
2018-07-20 10:32:00 +08:00
|
|
|
[Test]
|
2018-08-14 13:19:26 +08:00
|
|
|
public void TestImportUnderCurrentRuleset()
|
2018-07-20 10:32:00 +08:00
|
|
|
{
|
2019-02-15 20:50:40 +08:00
|
|
|
createSongSelect();
|
2018-07-20 10:32:00 +08:00
|
|
|
changeRuleset(2);
|
2019-06-10 17:34:24 +08:00
|
|
|
addRulesetImportStep(2);
|
|
|
|
addRulesetImportStep(1);
|
2019-03-19 16:24:26 +08:00
|
|
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.RulesetID == 2);
|
2018-07-19 17:51:08 +08:00
|
|
|
|
2018-07-20 10:32:00 +08:00
|
|
|
changeRuleset(1);
|
2019-03-19 16:24:26 +08:00
|
|
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.RulesetID == 1);
|
2018-07-19 17:51:08 +08:00
|
|
|
|
2018-07-20 10:32:00 +08:00
|
|
|
changeRuleset(0);
|
2019-03-19 16:24:26 +08:00
|
|
|
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
2018-07-18 11:58:45 +08:00
|
|
|
}
|
|
|
|
|
2018-08-14 13:18:46 +08:00
|
|
|
[Test]
|
|
|
|
public void TestRulesetChangeResetsMods()
|
|
|
|
{
|
2019-02-15 20:50:40 +08:00
|
|
|
createSongSelect();
|
2018-08-14 13:18:46 +08:00
|
|
|
changeRuleset(0);
|
|
|
|
|
|
|
|
changeMods(new OsuModHardRock());
|
|
|
|
|
|
|
|
int actionIndex = 0;
|
|
|
|
int modChangeIndex = 0;
|
|
|
|
int rulesetChangeIndex = 0;
|
|
|
|
|
|
|
|
AddStep("change ruleset", () =>
|
|
|
|
{
|
2019-12-13 20:45:38 +08:00
|
|
|
SelectedMods.ValueChanged += onModChange;
|
2018-08-14 13:18:46 +08:00
|
|
|
songSelect.Ruleset.ValueChanged += onRulesetChange;
|
|
|
|
|
|
|
|
Ruleset.Value = new TaikoRuleset().RulesetInfo;
|
|
|
|
|
2019-12-13 20:45:38 +08:00
|
|
|
SelectedMods.ValueChanged -= onModChange;
|
2018-08-14 13:18:46 +08:00
|
|
|
songSelect.Ruleset.ValueChanged -= onRulesetChange;
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("mods changed before ruleset", () => modChangeIndex < rulesetChangeIndex);
|
2019-12-13 20:45:38 +08:00
|
|
|
AddAssert("empty mods", () => !SelectedMods.Value.Any());
|
2018-08-14 13:18:46 +08:00
|
|
|
|
2019-04-10 16:13:12 +08:00
|
|
|
void onModChange(ValueChangedEvent<IReadOnlyList<Mod>> e) => modChangeIndex = actionIndex++;
|
2019-06-14 19:18:22 +08:00
|
|
|
void onRulesetChange(ValueChangedEvent<RulesetInfo> e) => rulesetChangeIndex = actionIndex++;
|
2018-08-14 13:18:46 +08:00
|
|
|
}
|
|
|
|
|
2019-11-14 12:28:13 +08:00
|
|
|
[Test]
|
|
|
|
public void TestModsRetainedBetweenSongSelect()
|
|
|
|
{
|
2019-12-13 20:45:38 +08:00
|
|
|
AddAssert("empty mods", () => !SelectedMods.Value.Any());
|
2019-11-14 12:28:13 +08:00
|
|
|
|
|
|
|
createSongSelect();
|
|
|
|
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
|
|
|
|
changeMods(new OsuModHardRock());
|
|
|
|
|
|
|
|
createSongSelect();
|
|
|
|
|
2019-12-13 20:45:38 +08:00
|
|
|
AddAssert("mods retained", () => SelectedMods.Value.Any());
|
2019-11-14 12:28:13 +08:00
|
|
|
}
|
|
|
|
|
2019-01-10 14:25:07 +08:00
|
|
|
[Test]
|
|
|
|
public void TestStartAfterUnMatchingFilterDoesNotStart()
|
|
|
|
{
|
2019-02-15 20:50:40 +08:00
|
|
|
createSongSelect();
|
2019-01-10 14:25:07 +08:00
|
|
|
addManyTestMaps();
|
2019-03-19 16:24:26 +08:00
|
|
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
2019-01-10 14:25:07 +08:00
|
|
|
|
|
|
|
bool startRequested = false;
|
|
|
|
|
|
|
|
AddStep("set filter and finalize", () =>
|
|
|
|
{
|
|
|
|
songSelect.StartRequested = () => startRequested = true;
|
|
|
|
|
|
|
|
songSelect.Carousel.Filter(new FilterCriteria { SearchText = "somestringthatshouldn'tbematchable" });
|
|
|
|
songSelect.FinaliseSelection();
|
|
|
|
|
|
|
|
songSelect.StartRequested = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("start not requested", () => !startRequested);
|
|
|
|
}
|
|
|
|
|
2020-02-10 15:59:49 +08:00
|
|
|
[TestCase(false)]
|
|
|
|
[TestCase(true)]
|
|
|
|
public void TestExternalBeatmapChangeWhileFiltered(bool differentRuleset)
|
|
|
|
{
|
|
|
|
createSongSelect();
|
|
|
|
addManyTestMaps();
|
|
|
|
|
|
|
|
changeRuleset(0);
|
|
|
|
|
|
|
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
|
|
|
|
|
|
|
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono");
|
|
|
|
|
|
|
|
AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap);
|
|
|
|
|
2020-02-11 16:41:48 +08:00
|
|
|
AddUntilStep("has no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
|
|
|
|
2020-02-10 15:59:49 +08:00
|
|
|
BeatmapInfo target = null;
|
|
|
|
|
|
|
|
AddStep("select beatmap externally", () =>
|
|
|
|
{
|
2020-02-11 16:41:48 +08:00
|
|
|
target = manager.GetAllUsableBeatmapSets().Where(b => b.Beatmaps.Any(bi => bi.RulesetID == (differentRuleset ? 1 : 0)))
|
2020-02-10 15:59:49 +08:00
|
|
|
.ElementAt(5).Beatmaps.First();
|
|
|
|
|
|
|
|
Beatmap.Value = manager.GetWorkingBeatmap(target);
|
|
|
|
});
|
|
|
|
|
2020-02-11 16:41:48 +08:00
|
|
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
|
|
|
|
2020-02-10 17:17:27 +08:00
|
|
|
AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmap?.OnlineBeatmapID == target.OnlineBeatmapID);
|
|
|
|
AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID);
|
2020-02-10 15:59:49 +08:00
|
|
|
|
|
|
|
AddStep("reset filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = string.Empty);
|
|
|
|
|
2020-02-10 17:17:27 +08:00
|
|
|
AddAssert("game still correct", () => Beatmap.Value?.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID);
|
|
|
|
AddAssert("carousel still correct", () => songSelect.Carousel.SelectedBeatmap.OnlineBeatmapID == target.OnlineBeatmapID);
|
2020-02-10 15:59:49 +08:00
|
|
|
}
|
|
|
|
|
2020-03-11 01:59:24 +08:00
|
|
|
[Test]
|
|
|
|
public void TestExternalBeatmapChangeWhileFilteredThenRefilter()
|
|
|
|
{
|
|
|
|
createSongSelect();
|
|
|
|
addManyTestMaps();
|
|
|
|
|
|
|
|
changeRuleset(0);
|
|
|
|
|
|
|
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
|
|
|
|
|
|
|
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono");
|
|
|
|
|
|
|
|
AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap);
|
|
|
|
|
|
|
|
AddUntilStep("has no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
|
|
|
|
|
|
|
BeatmapInfo target = null;
|
|
|
|
|
|
|
|
AddStep("select beatmap externally", () =>
|
|
|
|
{
|
|
|
|
target = manager.GetAllUsableBeatmapSets().Where(b => b.Beatmaps.Any(bi => bi.RulesetID == 1))
|
|
|
|
.ElementAt(5).Beatmaps.First();
|
|
|
|
|
|
|
|
Beatmap.Value = manager.GetWorkingBeatmap(target);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
|
|
|
|
|
|
|
AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmap?.OnlineBeatmapID == target.OnlineBeatmapID);
|
|
|
|
AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID);
|
|
|
|
|
|
|
|
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nononoo");
|
|
|
|
|
|
|
|
AddUntilStep("game lost selection", () => Beatmap.Value is DummyWorkingBeatmap);
|
|
|
|
AddAssert("carousel lost selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
|
|
|
}
|
|
|
|
|
2020-02-03 15:04:32 +08:00
|
|
|
[Test]
|
|
|
|
public void TestAutoplayViaCtrlEnter()
|
|
|
|
{
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
|
|
|
|
createSongSelect();
|
|
|
|
|
|
|
|
AddStep("press ctrl+enter", () =>
|
|
|
|
{
|
|
|
|
InputManager.PressKey(Key.ControlLeft);
|
|
|
|
InputManager.PressKey(Key.Enter);
|
|
|
|
|
|
|
|
InputManager.ReleaseKey(Key.ControlLeft);
|
|
|
|
InputManager.ReleaseKey(Key.Enter);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader);
|
|
|
|
|
|
|
|
AddAssert("autoplay enabled", () => songSelect.Mods.Value.FirstOrDefault() is ModAutoplay);
|
|
|
|
|
|
|
|
AddUntilStep("wait for return to ss", () => songSelect.IsCurrentScreen());
|
|
|
|
|
|
|
|
AddAssert("mod disabled", () => songSelect.Mods.Value.Count == 0);
|
|
|
|
}
|
|
|
|
|
2019-06-12 15:45:29 +08:00
|
|
|
[Test]
|
|
|
|
public void TestHideSetSelectsCorrectBeatmap()
|
|
|
|
{
|
|
|
|
int? previousID = null;
|
|
|
|
createSongSelect();
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
AddStep("Move to last difficulty", () => songSelect.Carousel.SelectBeatmap(songSelect.Carousel.BeatmapSets.First().Beatmaps.Last()));
|
|
|
|
AddStep("Store current ID", () => previousID = songSelect.Carousel.SelectedBeatmap.ID);
|
|
|
|
AddStep("Hide first beatmap", () => manager.Hide(songSelect.Carousel.SelectedBeatmapSet.Beatmaps.First()));
|
|
|
|
AddAssert("Selected beatmap has not changed", () => songSelect.Carousel.SelectedBeatmap.ID == previousID);
|
|
|
|
}
|
|
|
|
|
2020-02-15 09:23:24 +08:00
|
|
|
[Test]
|
|
|
|
public void TestDifficultyIconSelecting()
|
|
|
|
{
|
|
|
|
addRulesetImportStep(0);
|
|
|
|
createSongSelect();
|
|
|
|
|
2020-02-16 09:51:55 +08:00
|
|
|
DrawableCarouselBeatmapSet set = null;
|
|
|
|
AddStep("Find the DrawableCarouselBeatmapSet", () =>
|
|
|
|
{
|
|
|
|
set = songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmapSet>().First();
|
|
|
|
});
|
|
|
|
|
|
|
|
DrawableCarouselBeatmapSet.FilterableDifficultyIcon difficultyIcon = null;
|
|
|
|
AddStep("Find an icon", () =>
|
|
|
|
{
|
|
|
|
difficultyIcon = set.ChildrenOfType<DrawableCarouselBeatmapSet.FilterableDifficultyIcon>()
|
|
|
|
.First(icon => getDifficultyIconIndex(set, icon) != getCurrentBeatmapIndex());
|
|
|
|
});
|
2020-02-15 09:23:24 +08:00
|
|
|
AddStep("Click on a difficulty", () =>
|
|
|
|
{
|
2020-02-16 09:51:55 +08:00
|
|
|
InputManager.MoveMouseTo(difficultyIcon);
|
2020-02-15 09:23:24 +08:00
|
|
|
|
|
|
|
InputManager.PressButton(MouseButton.Left);
|
|
|
|
InputManager.ReleaseButton(MouseButton.Left);
|
|
|
|
});
|
2020-02-16 09:51:55 +08:00
|
|
|
AddAssert("Selected beatmap correct", () => getCurrentBeatmapIndex() == getDifficultyIconIndex(set, difficultyIcon));
|
2020-02-15 09:23:24 +08:00
|
|
|
|
2020-02-16 09:51:55 +08:00
|
|
|
double? maxBPM = null;
|
2020-02-15 09:23:24 +08:00
|
|
|
AddStep("Filter some difficulties", () => songSelect.Carousel.Filter(new FilterCriteria
|
|
|
|
{
|
|
|
|
BPM = new FilterCriteria.OptionalRange<double>
|
|
|
|
{
|
2020-02-16 09:51:55 +08:00
|
|
|
Min = maxBPM = songSelect.Carousel.SelectedBeatmapSet.MaxBPM,
|
2020-02-15 09:23:24 +08:00
|
|
|
IsLowerInclusive = true
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2020-02-16 09:51:55 +08:00
|
|
|
DrawableCarouselBeatmapSet.FilterableDifficultyIcon filteredIcon = null;
|
|
|
|
AddStep("Get filtered icon", () =>
|
|
|
|
{
|
|
|
|
var filteredBeatmap = songSelect.Carousel.SelectedBeatmapSet.Beatmaps.Find(b => b.BPM < maxBPM);
|
|
|
|
int filteredBeatmapIndex = getBeatmapIndex(filteredBeatmap.BeatmapSet, filteredBeatmap);
|
|
|
|
filteredIcon = set.ChildrenOfType<DrawableCarouselBeatmapSet.FilterableDifficultyIcon>().ElementAt(filteredBeatmapIndex);
|
|
|
|
});
|
|
|
|
|
|
|
|
int? previousID = null;
|
2020-02-15 09:23:24 +08:00
|
|
|
AddStep("Store current ID", () => previousID = songSelect.Carousel.SelectedBeatmap.ID);
|
|
|
|
AddStep("Click on a filtered difficulty", () =>
|
|
|
|
{
|
2020-02-16 09:51:55 +08:00
|
|
|
InputManager.MoveMouseTo(filteredIcon);
|
2020-02-15 09:23:24 +08:00
|
|
|
|
|
|
|
InputManager.PressButton(MouseButton.Left);
|
|
|
|
InputManager.ReleaseButton(MouseButton.Left);
|
|
|
|
});
|
|
|
|
AddAssert("Selected beatmap has not changed", () => songSelect.Carousel.SelectedBeatmap.ID == previousID);
|
|
|
|
}
|
|
|
|
|
2020-02-16 09:51:55 +08:00
|
|
|
private int getBeatmapIndex(BeatmapSetInfo set, BeatmapInfo info) => set.Beatmaps.FindIndex(b => b == info);
|
|
|
|
|
|
|
|
private int getCurrentBeatmapIndex() => getBeatmapIndex(songSelect.Carousel.SelectedBeatmapSet, songSelect.Carousel.SelectedBeatmap);
|
|
|
|
|
|
|
|
private int getDifficultyIconIndex(DrawableCarouselBeatmapSet set, DrawableCarouselBeatmapSet.FilterableDifficultyIcon icon)
|
|
|
|
{
|
|
|
|
return set.ChildrenOfType<DrawableCarouselBeatmapSet.FilterableDifficultyIcon>().ToList().FindIndex(i => i == icon);
|
|
|
|
}
|
|
|
|
|
2019-06-12 15:45:29 +08:00
|
|
|
private void addRulesetImportStep(int id) => AddStep($"import test map for ruleset {id}", () => importForRuleset(id));
|
|
|
|
|
|
|
|
private void importForRuleset(int id) => manager.Import(createTestBeatmapSet(getImportId(), rulesets.AvailableRulesets.Where(r => r.ID == id).ToArray())).Wait();
|
2018-07-20 10:32:00 +08:00
|
|
|
|
|
|
|
private static int importId;
|
2020-02-10 15:59:49 +08:00
|
|
|
|
2018-07-20 10:32:00 +08:00
|
|
|
private int getImportId() => ++importId;
|
|
|
|
|
2019-10-08 15:37:34 +08:00
|
|
|
private void checkMusicPlaying(bool playing) =>
|
|
|
|
AddUntilStep($"music {(playing ? "" : "not ")}playing", () => music.IsPlaying == playing);
|
|
|
|
|
2019-12-13 20:45:38 +08:00
|
|
|
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => SelectedMods.Value = mods);
|
2018-08-14 13:18:46 +08:00
|
|
|
|
2018-07-20 10:32:00 +08:00
|
|
|
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id));
|
|
|
|
|
2019-02-15 20:50:40 +08:00
|
|
|
private void createSongSelect()
|
|
|
|
{
|
|
|
|
AddStep("create song select", () => LoadScreen(songSelect = new TestSongSelect()));
|
2019-03-19 16:24:26 +08:00
|
|
|
AddUntilStep("wait for present", () => songSelect.IsCurrentScreen());
|
2019-02-15 20:50:40 +08:00
|
|
|
}
|
|
|
|
|
2018-07-18 11:58:45 +08:00
|
|
|
private void addManyTestMaps()
|
|
|
|
{
|
|
|
|
AddStep("import test maps", () =>
|
|
|
|
{
|
|
|
|
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray();
|
|
|
|
|
|
|
|
for (int i = 0; i < 100; i += 10)
|
2019-06-10 11:46:21 +08:00
|
|
|
manager.Import(createTestBeatmapSet(i, usableRulesets)).Wait();
|
2018-07-18 11:58:45 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-07-20 10:32:00 +08:00
|
|
|
private BeatmapSetInfo createTestBeatmapSet(int setId, RulesetInfo[] rulesets)
|
2018-07-18 11:58:45 +08:00
|
|
|
{
|
|
|
|
int j = 0;
|
|
|
|
RulesetInfo getRuleset() => rulesets[j++ % rulesets.Length];
|
|
|
|
|
|
|
|
var beatmaps = new List<BeatmapInfo>();
|
|
|
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
{
|
2018-07-20 10:32:00 +08:00
|
|
|
int beatmapId = setId * 10 + i;
|
2019-07-08 15:43:35 +08:00
|
|
|
|
2019-07-07 23:27:12 +08:00
|
|
|
int length = RNG.Next(30000, 200000);
|
2019-07-08 15:43:35 +08:00
|
|
|
double bpm = RNG.NextSingle(80, 200);
|
2018-07-18 11:58:45 +08:00
|
|
|
|
|
|
|
beatmaps.Add(new BeatmapInfo
|
|
|
|
{
|
|
|
|
Ruleset = getRuleset(),
|
|
|
|
OnlineBeatmapID = beatmapId,
|
|
|
|
Path = "normal.osu",
|
2019-07-08 15:43:35 +08:00
|
|
|
Version = $"{beatmapId} (length {TimeSpan.FromMilliseconds(length):m\\:ss}, bpm {bpm:0.#})",
|
2019-07-08 01:25:36 +08:00
|
|
|
Length = length,
|
2019-07-08 15:43:35 +08:00
|
|
|
BPM = bpm,
|
2018-07-18 11:58:45 +08:00
|
|
|
BaseDifficulty = new BeatmapDifficulty
|
|
|
|
{
|
|
|
|
OverallDifficulty = 3.5f,
|
2019-07-07 23:27:12 +08:00
|
|
|
},
|
2018-07-18 11:58:45 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
return new BeatmapSetInfo
|
|
|
|
{
|
2018-07-18 11:58:45 +08:00
|
|
|
OnlineBeatmapSetID = setId,
|
2018-04-13 17:19:50 +08:00
|
|
|
Hash = new MemoryStream(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())).ComputeMD5Hash(),
|
|
|
|
Metadata = new BeatmapMetadata
|
|
|
|
{
|
|
|
|
// Create random metadata, then we can check if sorting works based on these
|
2018-07-18 11:58:45 +08:00
|
|
|
Artist = "Some Artist " + RNG.Next(0, 9),
|
2019-07-08 15:43:35 +08:00
|
|
|
Title = $"Some Song (set id {setId}, max bpm {beatmaps.Max(b => b.BPM):0.#})",
|
2018-04-13 17:19:50 +08:00
|
|
|
AuthorString = "Some Guy " + RNG.Next(0, 9),
|
|
|
|
},
|
2019-07-07 23:27:12 +08:00
|
|
|
Beatmaps = beatmaps,
|
|
|
|
DateAdded = DateTimeOffset.UtcNow,
|
2018-04-13 17:19:50 +08:00
|
|
|
};
|
|
|
|
}
|
2019-10-15 15:14:06 +08:00
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
rulesets?.Dispose();
|
|
|
|
}
|
2019-11-13 17:54:33 +08:00
|
|
|
|
|
|
|
private class TestSongSelect : PlaySongSelect
|
|
|
|
{
|
|
|
|
public Action StartRequested;
|
|
|
|
|
|
|
|
public new Bindable<RulesetInfo> Ruleset => base.Ruleset;
|
|
|
|
|
2020-02-10 15:59:49 +08:00
|
|
|
public new FilterControl FilterControl => base.FilterControl;
|
|
|
|
|
2019-11-13 17:54:33 +08:00
|
|
|
public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
|
|
|
|
public WorkingBeatmap CurrentBeatmapDetailsBeatmap => BeatmapDetails.Beatmap;
|
|
|
|
public new BeatmapCarousel Carousel => base.Carousel;
|
|
|
|
|
|
|
|
protected override bool OnStart()
|
|
|
|
{
|
|
|
|
StartRequested?.Invoke();
|
|
|
|
return base.OnStart();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int FilterCount;
|
|
|
|
|
|
|
|
protected override void ApplyFilterToCarousel(FilterCriteria criteria)
|
|
|
|
{
|
|
|
|
FilterCount++;
|
|
|
|
base.ApplyFilterToCarousel(criteria);
|
|
|
|
}
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|