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;
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
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;
|
|
|
|
using osu.Game.Screens;
|
|
|
|
using osu.Game.Screens.Menu;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
using IntroSequence = osu.Game.Configuration.IntroSequence;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Navigation
|
|
|
|
{
|
|
|
|
/// <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
|
|
|
{
|
|
|
|
private GameHost host;
|
|
|
|
|
|
|
|
protected TestOsuGame Game;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(GameHost host)
|
|
|
|
{
|
|
|
|
this.host = host;
|
|
|
|
|
|
|
|
Child = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
public void SetUpSteps()
|
|
|
|
{
|
|
|
|
AddStep("Create new game instance", () =>
|
|
|
|
{
|
|
|
|
if (Game != null)
|
|
|
|
{
|
|
|
|
Remove(Game);
|
|
|
|
Game.Dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
RecycleLocalStorage();
|
|
|
|
|
|
|
|
// see MouseSettings
|
|
|
|
var frameworkConfig = host.Dependencies.Get<FrameworkConfigManager>();
|
|
|
|
frameworkConfig.GetBindable<double>(FrameworkSetting.CursorSensitivity).Disabled = false;
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2020-03-05 05:46:07 +00:00
|
|
|
protected void CreateGame()
|
|
|
|
{
|
|
|
|
Game = new TestOsuGame(LocalStorage, API);
|
|
|
|
Game.SetHost(host);
|
|
|
|
|
|
|
|
// todo: this can be removed once we can run audio tracks without a device present
|
|
|
|
// see https://github.com/ppy/osu/issues/1302
|
|
|
|
Game.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles);
|
|
|
|
|
|
|
|
Add(Game);
|
|
|
|
}
|
|
|
|
|
2020-01-30 14:45:15 +00:00
|
|
|
protected void PushAndConfirm(Func<Screen> newScreen)
|
|
|
|
{
|
|
|
|
Screen screen = null;
|
|
|
|
AddStep("Push new screen", () => Game.ScreenStack.Push(screen = newScreen()));
|
|
|
|
AddUntilStep("Wait for new screen", () => Game.ScreenStack.CurrentScreen == screen && screen.IsLoaded);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
public new ScreenStack ScreenStack => base.ScreenStack;
|
|
|
|
|
|
|
|
public new BackButton BackButton => base.BackButton;
|
|
|
|
|
|
|
|
public new BeatmapManager BeatmapManager => base.BeatmapManager;
|
|
|
|
|
|
|
|
public new SettingsPanel Settings => base.Settings;
|
|
|
|
|
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;
|
|
|
|
|
2020-03-05 06:40:48 +00:00
|
|
|
// if we don't do this, when running under nUnit the version that gets populated is that of nUnit.
|
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);
|
|
|
|
|
2020-01-29 05:23:23 +00:00
|
|
|
public TestOsuGame(Storage storage, IAPIProvider api)
|
|
|
|
{
|
|
|
|
Storage = storage;
|
|
|
|
API = api;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
API.Login("Rhythm Champion", "osu!");
|
2020-02-14 11:12:23 +00:00
|
|
|
|
|
|
|
Dependencies.Get<SessionStatics>().Set(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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|