|
6 | 6 | using osu.Framework.Bindables;
|
7 | 7 | using osu.Framework.Graphics;
|
8 | 8 | using osu.Framework.Utils;
|
| 9 | +using osu.Game.Beatmaps; |
9 | 10 | using osu.Game.Graphics;
|
10 | 11 | using osu.Game.Online.Spectator;
|
| 12 | +using osu.Game.Rulesets.Osu; |
| 13 | +using osu.Game.Rulesets.Osu.Scoring; |
11 | 14 | using osu.Game.Screens.Play;
|
12 | 15 | using osu.Game.Screens.Play.HUD;
|
| 16 | +using osu.Game.Tests.Visual.Spectator; |
13 | 17 |
|
14 | 18 | namespace osu.Game.Tests.Visual.Gameplay
|
15 | 19 | {
|
16 | 20 | [TestFixture]
|
17 | 21 | public partial class TestSceneSpectatorList : OsuTestScene
|
18 | 22 | {
|
19 |
| - private readonly BindableList<SpectatorUser> spectators = new BindableList<SpectatorUser>(); |
20 |
| - private readonly Bindable<LocalUserPlayingState> localUserPlayingState = new Bindable<LocalUserPlayingState>(); |
21 |
| - |
22 | 23 | private int counter;
|
23 | 24 |
|
24 | 25 | [Test]
|
25 | 26 | public void TestBasics()
|
26 | 27 | {
|
27 | 28 | SpectatorList list = null!;
|
28 |
| - AddStep("create spectator list", () => Child = list = new SpectatorList |
| 29 | + Bindable<LocalUserPlayingState> playingState = new Bindable<LocalUserPlayingState>(); |
| 30 | + GameplayState gameplayState = new GameplayState(new Beatmap(), new OsuRuleset(), healthProcessor: new OsuHealthProcessor(0), localUserPlayingState: playingState); |
| 31 | + TestSpectatorClient client = new TestSpectatorClient(); |
| 32 | + |
| 33 | + AddStep("create spectator list", () => |
29 | 34 | {
|
30 |
| - Anchor = Anchor.Centre, |
31 |
| - Origin = Anchor.Centre, |
32 |
| - Spectators = { BindTarget = spectators }, |
33 |
| - UserPlayingState = { BindTarget = localUserPlayingState } |
| 35 | + Children = new Drawable[] |
| 36 | + { |
| 37 | + client, |
| 38 | + new DependencyProvidingContainer |
| 39 | + { |
| 40 | + RelativeSizeAxes = Axes.Both, |
| 41 | + CachedDependencies = |
| 42 | + [ |
| 43 | + (typeof(GameplayState), gameplayState), |
| 44 | + (typeof(SpectatorClient), client) |
| 45 | + ], |
| 46 | + Child = list = new SpectatorList |
| 47 | + { |
| 48 | + Anchor = Anchor.Centre, |
| 49 | + Origin = Anchor.Centre, |
| 50 | + } |
| 51 | + } |
| 52 | + }; |
34 | 53 | });
|
35 | 54 |
|
36 |
| - AddStep("start playing", () => localUserPlayingState.Value = LocalUserPlayingState.Playing); |
| 55 | + AddStep("start playing", () => playingState.Value = LocalUserPlayingState.Playing); |
37 | 56 |
|
38 | 57 | AddRepeatStep("add a user", () =>
|
39 | 58 | {
|
40 | 59 | int id = Interlocked.Increment(ref counter);
|
41 |
| - spectators.Add(new SpectatorUser |
| 60 | + ((ISpectatorClient)client).UserStartedWatching([new SpectatorUser |
42 | 61 | {
|
43 | 62 | OnlineID = id,
|
44 | 63 | Username = $"User {id}"
|
45 |
| - }); |
| 64 | + }]); |
46 | 65 | }, 10);
|
47 | 66 |
|
48 |
| - AddRepeatStep("remove random user", () => spectators.RemoveAt(RNG.Next(0, spectators.Count)), 5); |
| 67 | + AddRepeatStep("remove random user", () => ((ISpectatorClient)client).UserEndedWatching(client.WatchingUsers[RNG.Next(client.WatchingUsers.Count)].OnlineID), 5); |
49 | 68 |
|
50 | 69 | AddStep("change font to venera", () => list.Font.Value = Typeface.Venera);
|
51 | 70 | AddStep("change font to torus", () => list.Font.Value = Typeface.Torus);
|
52 | 71 | AddStep("change header colour", () => list.HeaderColour.Value = new Colour4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1));
|
53 | 72 |
|
54 |
| - AddStep("enter break", () => localUserPlayingState.Value = LocalUserPlayingState.Break); |
55 |
| - AddStep("stop playing", () => localUserPlayingState.Value = LocalUserPlayingState.NotPlaying); |
| 73 | + AddStep("enter break", () => playingState.Value = LocalUserPlayingState.Break); |
| 74 | + AddStep("stop playing", () => playingState.Value = LocalUserPlayingState.NotPlaying); |
56 | 75 | }
|
57 | 76 | }
|
58 | 77 | }
|
0 commit comments