mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:25:11 +08:00
Merge remote-tracking branch 'upstream/master' into fix-catch-rewind
This commit is contained in:
commit
efadbefc3b
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Online.API;
|
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
@ -11,17 +10,17 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
public class TestSceneDisclaimer : ScreenTestScene
|
public class TestSceneDisclaimer : ScreenTestScene
|
||||||
{
|
{
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IAPIProvider api)
|
private void load()
|
||||||
{
|
{
|
||||||
AddStep("load disclaimer", () => LoadScreen(new Disclaimer()));
|
AddStep("load disclaimer", () => LoadScreen(new Disclaimer()));
|
||||||
|
|
||||||
AddStep("toggle support", () =>
|
AddStep("toggle support", () =>
|
||||||
{
|
{
|
||||||
api.LocalUser.Value = new User
|
API.LocalUser.Value = new User
|
||||||
{
|
{
|
||||||
Username = api.LocalUser.Value.Username,
|
Username = API.LocalUser.Value.Username,
|
||||||
Id = api.LocalUser.Value.Id,
|
Id = API.LocalUser.Value.Id,
|
||||||
IsSupporter = !api.LocalUser.Value.IsSupporter,
|
IsSupporter = !API.LocalUser.Value.IsSupporter,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
public class TestSceneMatchLeaderboard : MultiplayerTestScene
|
public class TestSceneMatchLeaderboard : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
protected override bool RequiresAPIAccess => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
public TestSceneMatchLeaderboard()
|
public TestSceneMatchLeaderboard()
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneMultiScreen : ScreenTestScene
|
public class TestSceneMultiScreen : ScreenTestScene
|
||||||
{
|
{
|
||||||
protected override bool RequiresAPIAccess => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Online.API;
|
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.AccountCreation;
|
using osu.Game.Overlays.AccountCreation;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -27,6 +27,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
private readonly Container userPanelArea;
|
private readonly Container userPanelArea;
|
||||||
|
|
||||||
|
private Bindable<User> localUser;
|
||||||
|
|
||||||
public TestSceneAccountCreationOverlay()
|
public TestSceneAccountCreationOverlay()
|
||||||
{
|
{
|
||||||
AccountCreationOverlay accountCreation;
|
AccountCreationOverlay accountCreation;
|
||||||
@ -47,12 +49,14 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IAPIProvider api)
|
private void load()
|
||||||
{
|
{
|
||||||
api.Logout();
|
API.Logout();
|
||||||
api.LocalUser.BindValueChanged(user => { userPanelArea.Child = new UserPanel(user.NewValue) { Width = 200 }; }, true);
|
|
||||||
|
|
||||||
AddStep("logout", api.Logout);
|
localUser = API.LocalUser.GetBoundCopy();
|
||||||
|
localUser.BindValueChanged(user => { userPanelArea.Child = new UserPanel(user.NewValue) { Width = 200 }; }, true);
|
||||||
|
|
||||||
|
AddStep("logout", API.Logout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
typeof(BeatmapAvailability),
|
typeof(BeatmapAvailability),
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override bool RequiresAPIAccess => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
private RulesetInfo taikoRuleset;
|
private RulesetInfo taikoRuleset;
|
||||||
private RulesetInfo maniaRuleset;
|
private RulesetInfo maniaRuleset;
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
typeof(Comments),
|
typeof(Comments),
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override bool RequiresAPIAccess => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
private DirectOverlay direct;
|
private DirectOverlay direct;
|
||||||
|
|
||||||
protected override bool RequiresAPIAccess => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneHistoricalSection : OsuTestScene
|
public class TestSceneHistoricalSection : OsuTestScene
|
||||||
{
|
{
|
||||||
protected override bool RequiresAPIAccess => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneSocialOverlay : OsuTestScene
|
public class TestSceneSocialOverlay : OsuTestScene
|
||||||
{
|
{
|
||||||
protected override bool RequiresAPIAccess => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
public class TestSceneUserProfileHeader : OsuTestScene
|
public class TestSceneUserProfileHeader : OsuTestScene
|
||||||
{
|
{
|
||||||
protected override bool RequiresAPIAccess => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneUserProfileOverlay : OsuTestScene
|
public class TestSceneUserProfileOverlay : OsuTestScene
|
||||||
{
|
{
|
||||||
protected override bool RequiresAPIAccess => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
private readonly TestUserProfileOverlay profile;
|
private readonly TestUserProfileOverlay profile;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneUserRanks : OsuTestScene
|
public class TestSceneUserRanks : OsuTestScene
|
||||||
{
|
{
|
||||||
protected override bool RequiresAPIAccess => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(DrawableProfileScore), typeof(RanksSection) };
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(DrawableProfileScore), typeof(RanksSection) };
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
public class TestSceneUpdateableBeatmapBackgroundSprite : OsuTestScene
|
public class TestSceneUpdateableBeatmapBackgroundSprite : OsuTestScene
|
||||||
{
|
{
|
||||||
protected override bool RequiresAPIAccess => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
private BeatmapSetInfo testBeatmap;
|
private BeatmapSetInfo testBeatmap;
|
||||||
private IAPIProvider api;
|
private IAPIProvider api;
|
||||||
|
@ -170,7 +170,7 @@ namespace osu.Game.Overlays
|
|||||||
var tcs = new TaskCompletionSource<bool>();
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
var req = new GetChangelogRequest();
|
var req = new GetChangelogRequest();
|
||||||
req.Success += res =>
|
req.Success += res => Schedule(() =>
|
||||||
{
|
{
|
||||||
// remap streams to builds to ensure model equality
|
// remap streams to builds to ensure model equality
|
||||||
res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id));
|
res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id));
|
||||||
@ -182,7 +182,7 @@ namespace osu.Game.Overlays
|
|||||||
header.Streams.Populate(res.Streams);
|
header.Streams.Populate(res.Streams);
|
||||||
|
|
||||||
tcs.SetResult(true);
|
tcs.SetResult(true);
|
||||||
};
|
});
|
||||||
req.Failure += _ => initialFetchTask = null;
|
req.Failure += _ => initialFetchTask = null;
|
||||||
req.Perform(API);
|
req.Perform(API);
|
||||||
|
|
||||||
|
@ -46,13 +46,27 @@ namespace osu.Game.Tests.Visual
|
|||||||
protected Storage LocalStorage => localStorage.Value;
|
protected Storage LocalStorage => localStorage.Value;
|
||||||
|
|
||||||
private readonly Lazy<DatabaseContextFactory> contextFactory;
|
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;
|
protected DatabaseContextFactory ContextFactory => contextFactory.Value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this test scene requires API access
|
/// Whether this test scene requires real-world API access.
|
||||||
/// Setting this will cache an actual <see cref="APIAccess"/>.
|
/// If true, this will bypass the local <see cref="DummyAPIAccess"/> and use the <see cref="OsuGameBase"/> provided one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual bool RequiresAPIAccess => false;
|
protected virtual bool UseOnlineAPI => false;
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
@ -66,10 +80,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
if (!RequiresAPIAccess)
|
if (!UseOnlineAPI)
|
||||||
{
|
{
|
||||||
var dummyAPI = new DummyAPIAccess();
|
dummyAPI = new DummyAPIAccess();
|
||||||
|
|
||||||
Dependencies.CacheAs<IAPIProvider>(dummyAPI);
|
Dependencies.CacheAs<IAPIProvider>(dummyAPI);
|
||||||
Add(dummyAPI);
|
Add(dummyAPI);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user