Add tests for cached types in OsuGame and OsuGameBase

This commit is contained in:
Dean Herbert 2019-05-14 11:05:53 +09:00
parent 7553e2da25
commit a98accb4d4

View File

@ -3,12 +3,30 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Textures;
using osu.Framework.Platform; 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;
using osu.Game.Scoring;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Skinning;
using osu.Game.Utils;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
@ -21,6 +39,52 @@ namespace osu.Game.Tests.Visual
typeof(OsuLogo), typeof(OsuLogo),
}; };
private IReadOnlyList<Type> requiredGameDependencies => new[]
{
typeof(OsuGame),
typeof(RavenLogger),
typeof(Bindable<RulesetInfo>),
typeof(IBindable<RulesetInfo>),
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),
};
private IReadOnlyList<Type> requiredGameBaseDependencies => new[]
{
typeof(OsuGameBase),
typeof(DatabaseContextFactory),
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),
};
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(GameHost host) private void load(GameHost host)
{ {
@ -36,6 +100,11 @@ namespace osu.Game.Tests.Visual
}, },
game game
}; };
AddUntilStep("wait for load", () => game.IsLoaded);
AddAssert("check OsuGame DI members", () => requiredGameDependencies.All(d => game.Dependencies.Get(d) != null));
AddAssert("check OsuGameBase DI members", () => requiredGameBaseDependencies.All(d => Dependencies.Get(d) != null));
} }
} }
} }