mirror of
https://github.com/ppy/osu.git
synced 2025-02-06 04:53:06 +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
|
public class TestSceneDisclaimer : ScreenTestScene
|
||||||
{
|
{
|
||||||
[Cached(typeof(IAPIProvider))]
|
|
||||||
private readonly DummyAPIAccess api = new DummyAPIAccess();
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
Add(api);
|
|
||||||
|
|
||||||
AddStep("load disclaimer", () => LoadScreen(new Disclaimer()));
|
AddStep("load disclaimer", () => LoadScreen(new Disclaimer()));
|
||||||
|
|
||||||
AddStep("toggle support", () =>
|
AddStep("toggle support", () =>
|
||||||
|
@ -14,6 +14,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
{
|
{
|
||||||
public class TestSceneMatchLeaderboard : MultiplayerTestScene
|
public class TestSceneMatchLeaderboard : MultiplayerTestScene
|
||||||
{
|
{
|
||||||
|
protected override bool RequiresAPIAccess => true;
|
||||||
|
|
||||||
public TestSceneMatchLeaderboard()
|
public TestSceneMatchLeaderboard()
|
||||||
{
|
{
|
||||||
Room.RoomID.Value = 3;
|
Room.RoomID.Value = 3;
|
||||||
@ -27,11 +29,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private IAPIProvider api { get; set; }
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
var req = new GetRoomScoresRequest();
|
var req = new GetRoomScoresRequest();
|
||||||
req.Success += v => { };
|
req.Success += v => { };
|
||||||
|
@ -12,6 +12,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneMultiScreen : ScreenTestScene
|
public class TestSceneMultiScreen : ScreenTestScene
|
||||||
{
|
{
|
||||||
|
protected override bool RequiresAPIAccess => true;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(Screens.Multi.Multiplayer),
|
typeof(Screens.Multi.Multiplayer),
|
||||||
|
@ -25,17 +25,14 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
typeof(AccountCreationScreen),
|
typeof(AccountCreationScreen),
|
||||||
};
|
};
|
||||||
|
|
||||||
[Cached(typeof(IAPIProvider))]
|
private readonly Container userPanelArea;
|
||||||
private DummyAPIAccess api = new DummyAPIAccess();
|
|
||||||
|
|
||||||
public TestSceneAccountCreationOverlay()
|
public TestSceneAccountCreationOverlay()
|
||||||
{
|
{
|
||||||
Container userPanelArea;
|
|
||||||
AccountCreationOverlay accountCreation;
|
AccountCreationOverlay accountCreation;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
api,
|
|
||||||
accountCreation = new AccountCreationOverlay(),
|
accountCreation = new AccountCreationOverlay(),
|
||||||
userPanelArea = new Container
|
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.Logout();
|
||||||
api.LocalUser.BindValueChanged(user => { userPanelArea.Child = new UserPanel(user.NewValue) { Width = 200 }; }, true);
|
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),
|
typeof(BeatmapAvailability),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected override bool RequiresAPIAccess => true;
|
||||||
|
|
||||||
private RulesetInfo taikoRuleset;
|
private RulesetInfo taikoRuleset;
|
||||||
private RulesetInfo maniaRuleset;
|
private RulesetInfo maniaRuleset;
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
typeof(Comments),
|
typeof(Comments),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected override bool RequiresAPIAccess => true;
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
@ -13,6 +13,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
private DirectOverlay direct;
|
private DirectOverlay direct;
|
||||||
|
|
||||||
|
protected override bool RequiresAPIAccess => true;
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
@ -17,14 +17,15 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneHistoricalSection : OsuTestScene
|
public class TestSceneHistoricalSection : OsuTestScene
|
||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes =>
|
protected override bool RequiresAPIAccess => true;
|
||||||
new[]
|
|
||||||
{
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
typeof(HistoricalSection),
|
{
|
||||||
typeof(PaginatedMostPlayedBeatmapContainer),
|
typeof(HistoricalSection),
|
||||||
typeof(DrawableMostPlayedBeatmap),
|
typeof(PaginatedMostPlayedBeatmapContainer),
|
||||||
typeof(DrawableProfileRow)
|
typeof(DrawableMostPlayedBeatmap),
|
||||||
};
|
typeof(DrawableProfileRow)
|
||||||
|
};
|
||||||
|
|
||||||
public TestSceneHistoricalSection()
|
public TestSceneHistoricalSection()
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneSocialOverlay : OsuTestScene
|
public class TestSceneSocialOverlay : OsuTestScene
|
||||||
{
|
{
|
||||||
|
protected override bool RequiresAPIAccess => true;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(UserPanel),
|
typeof(UserPanel),
|
||||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
public class TestSceneUserProfileHeader : OsuTestScene
|
public class TestSceneUserProfileHeader : OsuTestScene
|
||||||
{
|
{
|
||||||
|
protected override bool RequiresAPIAccess => true;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(ProfileHeader),
|
typeof(ProfileHeader),
|
||||||
|
@ -19,6 +19,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneUserProfileOverlay : OsuTestScene
|
public class TestSceneUserProfileOverlay : OsuTestScene
|
||||||
{
|
{
|
||||||
|
protected override bool RequiresAPIAccess => true;
|
||||||
|
|
||||||
private readonly TestUserProfileOverlay profile;
|
private readonly TestUserProfileOverlay profile;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
|
@ -18,6 +18,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneUserRanks : OsuTestScene
|
public class TestSceneUserRanks : OsuTestScene
|
||||||
{
|
{
|
||||||
|
protected override bool RequiresAPIAccess => true;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(DrawableProfileScore), typeof(RanksSection) };
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(DrawableProfileScore), typeof(RanksSection) };
|
||||||
|
|
||||||
public TestSceneUserRanks()
|
public TestSceneUserRanks()
|
||||||
|
@ -20,6 +20,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
public class TestSceneUpdateableBeatmapBackgroundSprite : OsuTestScene
|
public class TestSceneUpdateableBeatmapBackgroundSprite : OsuTestScene
|
||||||
{
|
{
|
||||||
|
protected override bool RequiresAPIAccess => true;
|
||||||
|
|
||||||
private BeatmapSetInfo testBeatmap;
|
private BeatmapSetInfo testBeatmap;
|
||||||
private IAPIProvider api;
|
private IAPIProvider api;
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
|
@ -16,6 +16,7 @@ using osu.Framework.Testing;
|
|||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
@ -47,6 +48,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
private readonly Lazy<DatabaseContextFactory> contextFactory;
|
private readonly Lazy<DatabaseContextFactory> contextFactory;
|
||||||
protected DatabaseContextFactory ContextFactory => contextFactory.Value;
|
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)
|
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
|
// 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
|
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()
|
protected OsuTestScene()
|
||||||
|
Loading…
Reference in New Issue
Block a user