Merge branch 'master' into beatmap-video

This commit is contained in:
Dean Herbert
2019-09-13 23:08:57 +09:00
committed by GitHub
18 changed files with 63 additions and 31 deletions

View File

@ -46,13 +46,27 @@ namespace osu.Game.Tests.Visual
protected Storage LocalStorage => localStorage.Value;
private readonly Lazy<DatabaseContextFactory> contextFactory;
protected IAPIProvider API
{
get
{
if (UseOnlineAPI)
throw new InvalidOperationException($"Using the {nameof(OsuTestScene)} dummy API is not supported when {nameof(UseOnlineAPI)} is true");
return dummyAPI;
}
}
private DummyAPIAccess dummyAPI;
protected DatabaseContextFactory ContextFactory => contextFactory.Value;
/// <summary>
/// Whether this test scene requires API access
/// Setting this will cache an actual <see cref="APIAccess"/>.
/// Whether this test scene requires real-world API access.
/// If true, this will bypass the local <see cref="DummyAPIAccess"/> and use the <see cref="OsuGameBase"/> provided one.
/// </summary>
protected virtual bool RequiresAPIAccess => false;
protected virtual bool UseOnlineAPI => false;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
@ -66,10 +80,9 @@ namespace osu.Game.Tests.Visual
Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
if (!RequiresAPIAccess)
if (!UseOnlineAPI)
{
var dummyAPI = new DummyAPIAccess();
dummyAPI = new DummyAPIAccess();
Dependencies.CacheAs<IAPIProvider>(dummyAPI);
Add(dummyAPI);
}