2021-10-16 11:34:24 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Game.Online.API;
|
2021-11-04 09:02:44 +00:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2021-10-16 11:34:24 +00:00
|
|
|
using osu.Game.Online.Spectator;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Mania;
|
|
|
|
using osu.Game.Tests.Visual.Spectator;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
|
|
|
public class TestSceneSpectatorHost : PlayerTestScene
|
|
|
|
{
|
|
|
|
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();
|
|
|
|
|
|
|
|
[Cached(typeof(SpectatorClient))]
|
|
|
|
private TestSpectatorClient spectatorClient { get; } = new TestSpectatorClient();
|
|
|
|
|
|
|
|
private DummyAPIAccess dummyAPIAccess => (DummyAPIAccess)API;
|
|
|
|
private const int dummy_user_id = 42;
|
|
|
|
|
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
2021-11-04 09:02:44 +00:00
|
|
|
AddStep("set dummy user", () => dummyAPIAccess.LocalUser.Value = new APIUser
|
2021-10-16 11:34:24 +00:00
|
|
|
{
|
|
|
|
Id = dummy_user_id,
|
|
|
|
Username = "DummyUser"
|
|
|
|
});
|
|
|
|
AddStep("add test spectator client", () => Add(spectatorClient));
|
|
|
|
AddStep("add watching user", () => spectatorClient.WatchUser(dummy_user_id));
|
|
|
|
base.SetUpSteps();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestClientSendsCorrectRuleset()
|
|
|
|
{
|
2022-02-09 03:09:04 +00:00
|
|
|
AddUntilStep("spectator client sending frames", () => spectatorClient.WatchedUserStates.ContainsKey(dummy_user_id));
|
|
|
|
AddAssert("spectator client sent correct ruleset", () => spectatorClient.WatchedUserStates[dummy_user_id].RulesetID == Ruleset.Value.OnlineID);
|
2021-10-16 11:34:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void TearDownSteps()
|
|
|
|
{
|
|
|
|
base.TearDownSteps();
|
|
|
|
AddStep("stop watching user", () => spectatorClient.StopWatchingUser(dummy_user_id));
|
|
|
|
AddStep("remove test spectator client", () => Remove(spectatorClient));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|