osu/osu.Game.Tests/Visual/TestSceneOsuGame.cs

128 lines
3.9 KiB
C#
Raw Normal View History

// 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;
using osu.Framework.Bindables;
2018-04-13 09:19:50 +00:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Textures;
2019-02-26 09:02:24 +00:00
using osu.Framework.Platform;
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;
using osu.Game.Scoring;
2018-04-13 09:19:50 +00:00
using osu.Game.Screens.Menu;
using osu.Game.Skinning;
using osu.Game.Utils;
2018-11-20 07:51:59 +00:00
using osuTK.Graphics;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Tests.Visual
{
[TestFixture]
public class TestSceneOsuGame : OsuTestScene
2018-04-13 09:19:50 +00:00
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(OsuLogo),
};
private IReadOnlyList<Type> requiredGameDependencies => new[]
{
typeof(OsuGame),
typeof(RavenLogger),
typeof(OsuLogo),
typeof(IdleTracker),
typeof(OnScreenDisplay),
typeof(NotificationOverlay),
typeof(DirectOverlay),
typeof(SocialOverlay),
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)
};
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>>),
typeof(LargeTextureStore),
typeof(OsuConfigManager),
typeof(SkinManager),
typeof(ISkinSource),
typeof(IAPIProvider),
typeof(RulesetStore),
typeof(FileStore),
typeof(ScoreManager),
typeof(BeatmapManager),
typeof(KeyBindingStore),
typeof(SettingsStore),
typeof(RulesetConfigCache),
typeof(OsuColour),
typeof(IBindable<WorkingBeatmap>),
typeof(Bindable<WorkingBeatmap>),
typeof(GlobalActionContainer),
typeof(PreviewTrackManager),
};
2019-02-26 09:02:24 +00:00
[BackgroundDependencyLoader]
2019-05-15 04:00:11 +00:00
private void load(GameHost host, OsuGameBase gameBase)
2018-04-13 09:19:50 +00:00
{
2019-02-26 09:02:24 +00:00
OsuGame game = new OsuGame();
game.SetHost(host);
Children = new Drawable[]
2018-04-13 09:19:50 +00:00
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
2019-02-26 09:02:24 +00:00
game
};
AddUntilStep("wait for load", () => game.IsLoaded);
2019-05-15 04:00:11 +00:00
AddAssert("check OsuGame DI members", () =>
{
foreach (var type in requiredGameDependencies)
if (game.Dependencies.Get(type) == null)
throw new Exception($"{type} has not been cached");
return true;
});
AddAssert("check OsuGameBase DI members", () =>
{
foreach (var type in requiredGameBaseDependencies)
if (gameBase.Dependencies.Get(type) == null)
throw new Exception($"{type} has not been cached");
return true;
});
2018-04-13 09:19:50 +00:00
}
}
}