mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 20:07:29 +08:00
Use DummyAPIAccess for non-online tests (#5550)
Use DummyAPIAccess for non-online tests Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
c2d48656be
@ -10,14 +10,9 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
public class TestSceneDisclaimer : ScreenTestScene
|
||||
{
|
||||
[Cached(typeof(IAPIProvider))]
|
||||
private readonly DummyAPIAccess api = new DummyAPIAccess();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(IAPIProvider api)
|
||||
{
|
||||
Add(api);
|
||||
|
||||
AddStep("load disclaimer", () => LoadScreen(new Disclaimer()));
|
||||
|
||||
AddStep("toggle support", () =>
|
||||
|
@ -14,6 +14,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneMatchLeaderboard : MultiplayerTestScene
|
||||
{
|
||||
protected override bool RequiresAPIAccess => true;
|
||||
|
||||
public TestSceneMatchLeaderboard()
|
||||
{
|
||||
Room.RoomID.Value = 3;
|
||||
@ -27,11 +29,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
});
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(IAPIProvider api)
|
||||
{
|
||||
var req = new GetRoomScoresRequest();
|
||||
req.Success += v => { };
|
||||
|
@ -12,6 +12,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[TestFixture]
|
||||
public class TestSceneMultiScreen : ScreenTestScene
|
||||
{
|
||||
protected override bool RequiresAPIAccess => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(Screens.Multi.Multiplayer),
|
||||
|
@ -25,17 +25,14 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(AccountCreationScreen),
|
||||
};
|
||||
|
||||
[Cached(typeof(IAPIProvider))]
|
||||
private DummyAPIAccess api = new DummyAPIAccess();
|
||||
private readonly Container userPanelArea;
|
||||
|
||||
public TestSceneAccountCreationOverlay()
|
||||
{
|
||||
Container userPanelArea;
|
||||
AccountCreationOverlay accountCreation;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
api,
|
||||
accountCreation = new AccountCreationOverlay(),
|
||||
userPanelArea = new Container
|
||||
{
|
||||
@ -46,11 +43,16 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
};
|
||||
|
||||
AddStep("show", () => accountCreation.Show());
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAPIProvider api)
|
||||
{
|
||||
api.Logout();
|
||||
api.LocalUser.BindValueChanged(user => { userPanelArea.Child = new UserPanel(user.NewValue) { Width = 200 }; }, true);
|
||||
|
||||
AddStep("show", () => accountCreation.Show());
|
||||
AddStep("logout", () => api.Logout());
|
||||
AddStep("logout", api.Logout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(BeatmapAvailability),
|
||||
};
|
||||
|
||||
protected override bool RequiresAPIAccess => true;
|
||||
|
||||
private RulesetInfo taikoRuleset;
|
||||
private RulesetInfo maniaRuleset;
|
||||
|
||||
|
@ -27,6 +27,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(Comments),
|
||||
};
|
||||
|
||||
protected override bool RequiresAPIAccess => true;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
@ -13,6 +13,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
private DirectOverlay direct;
|
||||
|
||||
protected override bool RequiresAPIAccess => true;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
@ -17,14 +17,15 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[TestFixture]
|
||||
public class TestSceneHistoricalSection : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes =>
|
||||
new[]
|
||||
{
|
||||
typeof(HistoricalSection),
|
||||
typeof(PaginatedMostPlayedBeatmapContainer),
|
||||
typeof(DrawableMostPlayedBeatmap),
|
||||
typeof(DrawableProfileRow)
|
||||
};
|
||||
protected override bool RequiresAPIAccess => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(HistoricalSection),
|
||||
typeof(PaginatedMostPlayedBeatmapContainer),
|
||||
typeof(DrawableMostPlayedBeatmap),
|
||||
typeof(DrawableProfileRow)
|
||||
};
|
||||
|
||||
public TestSceneHistoricalSection()
|
||||
{
|
||||
|
@ -13,6 +13,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[TestFixture]
|
||||
public class TestSceneSocialOverlay : OsuTestScene
|
||||
{
|
||||
protected override bool RequiresAPIAccess => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(UserPanel),
|
||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneUserProfileHeader : OsuTestScene
|
||||
{
|
||||
protected override bool RequiresAPIAccess => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ProfileHeader),
|
||||
|
@ -19,6 +19,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[TestFixture]
|
||||
public class TestSceneUserProfileOverlay : OsuTestScene
|
||||
{
|
||||
protected override bool RequiresAPIAccess => true;
|
||||
|
||||
private readonly TestUserProfileOverlay profile;
|
||||
|
||||
[Resolved]
|
||||
|
@ -18,6 +18,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[TestFixture]
|
||||
public class TestSceneUserRanks : OsuTestScene
|
||||
{
|
||||
protected override bool RequiresAPIAccess => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(DrawableProfileScore), typeof(RanksSection) };
|
||||
|
||||
public TestSceneUserRanks()
|
||||
|
@ -20,6 +20,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneUpdateableBeatmapBackgroundSprite : OsuTestScene
|
||||
{
|
||||
protected override bool RequiresAPIAccess => true;
|
||||
|
||||
private BeatmapSetInfo testBeatmap;
|
||||
private IAPIProvider api;
|
||||
private RulesetStore rulesets;
|
||||
|
@ -16,6 +16,7 @@ using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
@ -47,6 +48,12 @@ namespace osu.Game.Tests.Visual
|
||||
private readonly Lazy<DatabaseContextFactory> contextFactory;
|
||||
protected DatabaseContextFactory ContextFactory => contextFactory.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this test scene requires API access
|
||||
/// Setting this will cache an actual <see cref="APIAccess"/>.
|
||||
/// </summary>
|
||||
protected virtual bool RequiresAPIAccess => false;
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
// This is the earliest we can get OsuGameBase, which is used by the dummy working beatmap to find textures
|
||||
@ -57,7 +64,17 @@ namespace osu.Game.Tests.Visual
|
||||
Default = working
|
||||
};
|
||||
|
||||
return Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
|
||||
if (!RequiresAPIAccess)
|
||||
{
|
||||
var dummyAPI = new DummyAPIAccess();
|
||||
|
||||
Dependencies.CacheAs<IAPIProvider>(dummyAPI);
|
||||
Add(dummyAPI);
|
||||
}
|
||||
|
||||
return Dependencies;
|
||||
}
|
||||
|
||||
protected OsuTestScene()
|
||||
|
Loading…
Reference in New Issue
Block a user