2020-01-29 05:23:23 +00: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.
|
|
|
|
|
2020-01-30 14:45:15 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2020-01-29 05:23:23 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
2022-01-24 08:05:49 +00:00
|
|
|
using osu.Framework.Development;
|
2020-01-29 05:23:23 +00:00
|
|
|
using osu.Framework.Graphics;
|
2021-08-06 19:36:40 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-01-29 05:23:23 +00:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Platform;
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
using osu.Game.Rulesets;
|
2021-02-15 06:02:58 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-06-15 11:32:27 +00:00
|
|
|
using osu.Game.Scoring;
|
2020-01-29 05:23:23 +00:00
|
|
|
using osu.Game.Screens;
|
|
|
|
using osu.Game.Screens.Menu;
|
|
|
|
using osuTK.Graphics;
|
2021-10-07 06:46:50 +00:00
|
|
|
using IntroSequence = osu.Game.Configuration.IntroSequence;
|
2020-01-29 05:23:23 +00:00
|
|
|
|
2021-08-18 07:38:54 +00:00
|
|
|
namespace osu.Game.Tests.Visual
|
2020-01-29 05:23:23 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A scene which tests full game flow.
|
|
|
|
/// </summary>
|
2020-03-23 01:01:33 +00:00
|
|
|
public abstract class OsuGameTestScene : OsuManualInputManagerTestScene
|
2020-01-29 05:23:23 +00:00
|
|
|
{
|
|
|
|
protected TestOsuGame Game;
|
|
|
|
|
2020-09-15 10:01:32 +00:00
|
|
|
protected override bool UseFreshStoragePerRun => true;
|
|
|
|
|
2021-04-06 06:05:34 +00:00
|
|
|
protected override bool CreateNestedActionContainer => false;
|
|
|
|
|
2020-01-29 05:23:23 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2021-09-13 10:38:43 +00:00
|
|
|
private void load()
|
2020-01-29 05:23:23 +00:00
|
|
|
{
|
|
|
|
Child = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[SetUpSteps]
|
2020-11-11 06:58:43 +00:00
|
|
|
public virtual void SetUpSteps()
|
2020-01-29 05:23:23 +00:00
|
|
|
{
|
|
|
|
AddStep("Create new game instance", () =>
|
|
|
|
{
|
2021-09-13 10:38:43 +00:00
|
|
|
if (Game?.Parent != null)
|
2020-01-29 05:23:23 +00:00
|
|
|
{
|
|
|
|
Remove(Game);
|
|
|
|
Game.Dispose();
|
|
|
|
}
|
|
|
|
|
2021-08-18 07:23:02 +00:00
|
|
|
RecycleLocalStorage(false);
|
2020-01-29 05:23:23 +00:00
|
|
|
|
2020-03-05 05:46:07 +00:00
|
|
|
CreateGame();
|
2020-01-29 05:23:23 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
AddUntilStep("Wait for load", () => Game.IsLoaded);
|
|
|
|
AddUntilStep("Wait for intro", () => Game.ScreenStack.CurrentScreen is IntroScreen);
|
|
|
|
|
|
|
|
ConfirmAtMainMenu();
|
|
|
|
}
|
|
|
|
|
2021-08-18 07:23:02 +00:00
|
|
|
[TearDownSteps]
|
|
|
|
public void TearDownSteps()
|
|
|
|
{
|
2022-01-24 08:05:49 +00:00
|
|
|
if (DebugUtils.IsNUnitRunning)
|
|
|
|
{
|
|
|
|
AddStep("exit game", () => Game.Exit());
|
|
|
|
AddUntilStep("wait for game exit", () => Game.Parent == null);
|
|
|
|
}
|
2021-08-18 07:23:02 +00:00
|
|
|
}
|
|
|
|
|
2020-03-05 05:46:07 +00:00
|
|
|
protected void CreateGame()
|
|
|
|
{
|
2021-10-13 03:19:10 +00:00
|
|
|
AddGame(Game = CreateTestGame());
|
2020-03-05 05:46:07 +00:00
|
|
|
}
|
|
|
|
|
2021-10-13 03:19:10 +00:00
|
|
|
protected virtual TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API);
|
|
|
|
|
2020-01-30 14:45:15 +00:00
|
|
|
protected void PushAndConfirm(Func<Screen> newScreen)
|
|
|
|
{
|
|
|
|
Screen screen = null;
|
2021-10-06 03:40:25 +00:00
|
|
|
IScreen previousScreen = null;
|
|
|
|
|
|
|
|
AddStep("Push new screen", () =>
|
|
|
|
{
|
|
|
|
previousScreen = Game.ScreenStack.CurrentScreen;
|
|
|
|
Game.ScreenStack.Push(screen = newScreen());
|
|
|
|
});
|
|
|
|
|
|
|
|
AddUntilStep("Wait for new screen", () => screen.IsLoaded
|
|
|
|
&& Game.ScreenStack.CurrentScreen != previousScreen
|
|
|
|
&& previousScreen.GetChildScreen() == screen);
|
2020-01-30 14:45:15 +00:00
|
|
|
}
|
|
|
|
|
2020-01-29 05:23:23 +00:00
|
|
|
protected void ConfirmAtMainMenu() => AddUntilStep("Wait for main menu", () => Game.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);
|
|
|
|
|
|
|
|
public class TestOsuGame : OsuGame
|
|
|
|
{
|
2021-08-13 07:29:36 +00:00
|
|
|
public new const float SIDE_OVERLAY_OFFSET_RATIO = OsuGame.SIDE_OVERLAY_OFFSET_RATIO;
|
|
|
|
|
2020-01-29 05:23:23 +00:00
|
|
|
public new ScreenStack ScreenStack => base.ScreenStack;
|
|
|
|
|
|
|
|
public new BackButton BackButton => base.BackButton;
|
|
|
|
|
|
|
|
public new BeatmapManager BeatmapManager => base.BeatmapManager;
|
|
|
|
|
2020-06-15 11:32:27 +00:00
|
|
|
public new ScoreManager ScoreManager => base.ScoreManager;
|
|
|
|
|
2021-08-06 19:36:40 +00:00
|
|
|
public new Container ScreenOffsetContainer => base.ScreenOffsetContainer;
|
|
|
|
|
|
|
|
public new SettingsOverlay Settings => base.Settings;
|
|
|
|
|
|
|
|
public new NotificationOverlay Notifications => base.Notifications;
|
2020-01-29 05:23:23 +00:00
|
|
|
|
2020-03-05 08:12:14 +00:00
|
|
|
public new MusicController MusicController => base.MusicController;
|
|
|
|
|
2020-01-29 05:23:23 +00:00
|
|
|
public new OsuConfigManager LocalConfig => base.LocalConfig;
|
|
|
|
|
|
|
|
public new Bindable<WorkingBeatmap> Beatmap => base.Beatmap;
|
|
|
|
|
|
|
|
public new Bindable<RulesetInfo> Ruleset => base.Ruleset;
|
|
|
|
|
2021-02-15 06:02:58 +00:00
|
|
|
public new Bindable<IReadOnlyList<Mod>> SelectedMods => base.SelectedMods;
|
|
|
|
|
2021-10-07 07:50:05 +00:00
|
|
|
// if we don't apply these changes, when running under nUnit the version that gets populated is that of nUnit.
|
2021-10-07 06:27:57 +00:00
|
|
|
public override Version AssemblyVersion => new Version(0, 0);
|
2020-03-05 05:46:07 +00:00
|
|
|
public override string Version => "test game";
|
|
|
|
|
2020-01-29 05:23:23 +00:00
|
|
|
protected override Loader CreateLoader() => new TestLoader();
|
|
|
|
|
2020-01-30 14:45:15 +00:00
|
|
|
public new void PerformFromScreen(Action<IScreen> action, IEnumerable<Type> validScreens = null) => base.PerformFromScreen(action, validScreens);
|
|
|
|
|
2021-10-13 03:19:10 +00:00
|
|
|
public TestOsuGame(Storage storage, IAPIProvider api, string[] args = null)
|
|
|
|
: base(args)
|
2020-01-29 05:23:23 +00:00
|
|
|
{
|
|
|
|
Storage = storage;
|
|
|
|
API = api;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2021-10-07 06:46:50 +00:00
|
|
|
|
|
|
|
LocalConfig.SetValue(OsuSetting.IntroSequence, IntroSequence.Circles);
|
|
|
|
|
2020-01-29 05:23:23 +00:00
|
|
|
API.Login("Rhythm Champion", "osu!");
|
2020-02-14 11:12:23 +00:00
|
|
|
|
2021-03-17 07:10:16 +00:00
|
|
|
Dependencies.Get<SessionStatics>().SetValue(Static.MutedAudioNotificationShownOnce, true);
|
2020-01-29 05:23:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class TestLoader : Loader
|
|
|
|
{
|
|
|
|
protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler();
|
|
|
|
|
|
|
|
private class TestShaderPrecompiler : ShaderPrecompiler
|
|
|
|
{
|
|
|
|
protected override bool AllLoaded => true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|