2019-01-24 08:43:03 +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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using NUnit.Framework;
|
2019-02-26 09:02:24 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-05-14 02:05:53 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2021-08-20 10:45:52 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-05-14 02:05:53 +00:00
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2021-08-20 10:45:52 +00:00
|
|
|
|
using osu.Framework.Platform;
|
|
|
|
|
using osu.Framework.Testing;
|
2019-05-14 02:05:53 +00:00
|
|
|
|
using osu.Game.Audio;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
|
using osu.Game.Database;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Input;
|
|
|
|
|
using osu.Game.Input.Bindings;
|
|
|
|
|
using osu.Game.IO;
|
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osu.Game.Online.Chat;
|
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
using osu.Game.Rulesets;
|
2019-05-15 04:00:11 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-05-14 02:05:53 +00:00
|
|
|
|
using osu.Game.Scoring;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Screens.Menu;
|
2019-05-14 02:05:53 +00:00
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
using osu.Game.Utils;
|
2021-08-20 10:45:52 +00:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-08-11 07:24:47 +00:00
|
|
|
|
namespace osu.Game.Tests.Visual.Navigation
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2021-08-20 10:45:52 +00:00
|
|
|
|
public class TestSceneOsuGame : OsuTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-05-14 02:05:53 +00:00
|
|
|
|
private IReadOnlyList<Type> requiredGameDependencies => new[]
|
|
|
|
|
{
|
|
|
|
|
typeof(OsuGame),
|
2019-11-12 13:12:38 +00:00
|
|
|
|
typeof(SentryLogger),
|
2019-05-14 02:05:53 +00:00
|
|
|
|
typeof(OsuLogo),
|
|
|
|
|
typeof(IdleTracker),
|
|
|
|
|
typeof(OnScreenDisplay),
|
|
|
|
|
typeof(NotificationOverlay),
|
2020-04-21 07:03:18 +00:00
|
|
|
|
typeof(BeatmapListingOverlay),
|
2020-04-16 09:05:51 +00:00
|
|
|
|
typeof(DashboardOverlay),
|
2020-07-16 11:48:40 +00:00
|
|
|
|
typeof(NewsOverlay),
|
2019-05-14 02:05:53 +00:00
|
|
|
|
typeof(ChannelManager),
|
|
|
|
|
typeof(ChatOverlay),
|
|
|
|
|
typeof(SettingsOverlay),
|
|
|
|
|
typeof(UserProfileOverlay),
|
|
|
|
|
typeof(BeatmapSetOverlay),
|
|
|
|
|
typeof(LoginOverlay),
|
|
|
|
|
typeof(MusicController),
|
|
|
|
|
typeof(AccountCreationOverlay),
|
|
|
|
|
typeof(DialogOverlay),
|
2019-05-15 04:00:11 +00:00
|
|
|
|
typeof(ScreenshotManager)
|
2019-05-14 02:05:53 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private IReadOnlyList<Type> requiredGameBaseDependencies => new[]
|
|
|
|
|
{
|
|
|
|
|
typeof(OsuGameBase),
|
|
|
|
|
typeof(DatabaseContextFactory),
|
2019-05-15 04:00:11 +00:00
|
|
|
|
typeof(Bindable<RulesetInfo>),
|
|
|
|
|
typeof(IBindable<RulesetInfo>),
|
|
|
|
|
typeof(Bindable<IReadOnlyList<Mod>>),
|
|
|
|
|
typeof(IBindable<IReadOnlyList<Mod>>),
|
2019-05-14 02:05:53 +00:00
|
|
|
|
typeof(LargeTextureStore),
|
|
|
|
|
typeof(OsuConfigManager),
|
|
|
|
|
typeof(SkinManager),
|
|
|
|
|
typeof(ISkinSource),
|
|
|
|
|
typeof(IAPIProvider),
|
|
|
|
|
typeof(RulesetStore),
|
|
|
|
|
typeof(FileStore),
|
|
|
|
|
typeof(ScoreManager),
|
|
|
|
|
typeof(BeatmapManager),
|
|
|
|
|
typeof(RulesetConfigCache),
|
|
|
|
|
typeof(OsuColour),
|
|
|
|
|
typeof(IBindable<WorkingBeatmap>),
|
|
|
|
|
typeof(Bindable<WorkingBeatmap>),
|
|
|
|
|
typeof(GlobalActionContainer),
|
|
|
|
|
typeof(PreviewTrackManager),
|
|
|
|
|
};
|
|
|
|
|
|
2021-08-20 10:45:52 +00:00
|
|
|
|
private OsuGame game;
|
|
|
|
|
|
2021-07-26 07:33:56 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuGameBase gameBase { get; set; }
|
|
|
|
|
|
2021-08-20 10:45:52 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private GameHost host { get; set; }
|
|
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public void SetUpSteps()
|
|
|
|
|
{
|
|
|
|
|
AddStep("create game", () =>
|
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
},
|
|
|
|
|
};
|
2021-09-13 09:32:48 +00:00
|
|
|
|
|
|
|
|
|
AddGame(game = new OsuGame());
|
2021-08-20 10:45:52 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddUntilStep("wait for load", () => game.IsLoaded);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-26 07:33:56 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestNullRulesetHandled()
|
|
|
|
|
{
|
|
|
|
|
RulesetInfo ruleset = null;
|
2019-05-14 02:05:53 +00:00
|
|
|
|
|
2021-07-26 07:33:56 +00:00
|
|
|
|
AddStep("store current ruleset", () => ruleset = Ruleset.Value);
|
|
|
|
|
AddStep("set global ruleset to null value", () => Ruleset.Value = null);
|
|
|
|
|
|
|
|
|
|
AddAssert("ruleset still valid", () => Ruleset.Value.Available);
|
|
|
|
|
AddAssert("ruleset unchanged", () => ReferenceEquals(Ruleset.Value, ruleset));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestUnavailableRulesetHandled()
|
|
|
|
|
{
|
|
|
|
|
RulesetInfo ruleset = null;
|
|
|
|
|
|
|
|
|
|
AddStep("store current ruleset", () => ruleset = Ruleset.Value);
|
|
|
|
|
AddStep("set global ruleset to invalid value", () => Ruleset.Value = new RulesetInfo
|
|
|
|
|
{
|
|
|
|
|
Name = "unavailable",
|
|
|
|
|
Available = false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddAssert("ruleset still valid", () => Ruleset.Value.Available);
|
|
|
|
|
AddAssert("ruleset unchanged", () => ReferenceEquals(Ruleset.Value, ruleset));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestAvailableDependencies()
|
|
|
|
|
{
|
2019-05-15 04:00:11 +00:00
|
|
|
|
AddAssert("check OsuGame DI members", () =>
|
|
|
|
|
{
|
|
|
|
|
foreach (var type in requiredGameDependencies)
|
2019-11-11 11:53:22 +00:00
|
|
|
|
{
|
2021-08-20 10:45:52 +00:00
|
|
|
|
if (game.Dependencies.Get(type) == null)
|
2019-11-28 13:52:05 +00:00
|
|
|
|
throw new InvalidOperationException($"{type} has not been cached");
|
2019-11-11 11:53:22 +00:00
|
|
|
|
}
|
2019-05-15 04:00:11 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
});
|
2021-07-26 07:33:56 +00:00
|
|
|
|
|
2019-05-15 04:00:11 +00:00
|
|
|
|
AddAssert("check OsuGameBase DI members", () =>
|
|
|
|
|
{
|
|
|
|
|
foreach (var type in requiredGameBaseDependencies)
|
2019-11-11 11:53:22 +00:00
|
|
|
|
{
|
2019-05-15 04:00:11 +00:00
|
|
|
|
if (gameBase.Dependencies.Get(type) == null)
|
2019-11-28 13:52:05 +00:00
|
|
|
|
throw new InvalidOperationException($"{type} has not been cached");
|
2019-11-11 11:53:22 +00:00
|
|
|
|
}
|
2019-05-15 04:00:11 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
});
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|