forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestSceneOsuGame.cs
More file actions
147 lines (131 loc) · 4.97 KB
/
Copy pathTestSceneOsuGame.cs
File metadata and controls
147 lines (131 loc) · 4.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// 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.
#nullable disable
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Input;
using osu.Game.Input.Bindings;
using osu.Game.Online.API;
using osu.Game.Online.Chat;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Menu;
using osu.Game.Skinning;
using osuTK;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Navigation
{
[TestFixture]
public partial class TestSceneOsuGame : OsuGameTestScene
{
private IReadOnlyList<Type> requiredGameDependencies => new[]
{
typeof(OsuGame),
typeof(OsuLogo),
typeof(IdleTracker),
typeof(OnScreenDisplay),
typeof(INotificationOverlay),
typeof(BeatmapListingOverlay),
typeof(DashboardOverlay),
typeof(NewsOverlay),
typeof(ChannelManager),
typeof(ChatOverlay),
typeof(SettingsOverlay),
typeof(UserProfileOverlay),
typeof(BeatmapSetOverlay),
typeof(LoginOverlay),
typeof(MusicController),
typeof(AccountCreationOverlay),
typeof(IDialogOverlay),
typeof(ScreenshotManager)
};
private IReadOnlyList<Type> requiredGameBaseDependencies => new[]
{
typeof(OsuGameBase),
typeof(Bindable<RulesetInfo>),
typeof(IBindable<RulesetInfo>),
typeof(Bindable<IReadOnlyList<Mod>>),
typeof(IBindable<IReadOnlyList<Mod>>),
typeof(LargeTextureStore),
typeof(OsuConfigManager),
typeof(SkinManager),
typeof(ISkinSource),
typeof(IAPIProvider),
typeof(RulesetStore),
typeof(ScoreManager),
typeof(BeatmapManager),
typeof(IRulesetConfigCache),
typeof(OsuColour),
typeof(IBindable<WorkingBeatmap>),
typeof(Bindable<WorkingBeatmap>),
typeof(GlobalActionContainer),
typeof(PreviewTrackManager),
};
[Resolved]
private OsuGameBase gameBase { get; set; }
[Test]
public void TestCursorHidesWhenIdle()
{
AddStep("move mouse inside game bounds", () => InputManager.MoveMouseTo(Game.ScreenSpaceDrawQuad.TopLeft + new Vector2(20)));
AddStep("click mouse", () => InputManager.Click(MouseButton.Left));
AddUntilStep("wait until idle", () => Game.IsIdle.Value);
AddUntilStep("menu cursor hidden", () => Game.GlobalCursorDisplay.MenuCursor.ActiveCursor.Alpha == 0);
AddStep("click mouse", () => InputManager.Click(MouseButton.Left));
AddUntilStep("menu cursor shown", () => Game.GlobalCursorDisplay.MenuCursor.ActiveCursor.Alpha == 1);
}
[Test]
public void TestNullRulesetHandled()
{
RulesetInfo ruleset = null;
AddStep("store current ruleset", () => ruleset = Ruleset.Value);
AddStep("set global ruleset to null value", () => Ruleset.Value = null);
AddAssert("ruleset still valid", () => Ruleset.Value.Available);
AddAssert("ruleset unchanged", () => ReferenceEquals(Ruleset.Value, ruleset));
}
[Test]
public void TestUnavailableRulesetHandled()
{
RulesetInfo ruleset = null;
AddStep("store current ruleset", () => ruleset = Ruleset.Value);
AddStep("set global ruleset to invalid value", () => Ruleset.Value = new RulesetInfo
{
Name = "unavailable",
Available = false,
});
AddAssert("ruleset still valid", () => Ruleset.Value.Available);
AddAssert("ruleset unchanged", () => ReferenceEquals(Ruleset.Value, ruleset));
}
[Test]
public void TestAvailableDependencies()
{
AddAssert("check OsuGame DI members", () =>
{
foreach (var type in requiredGameDependencies)
{
if (Game.Dependencies.Get(type) == null)
throw new InvalidOperationException($"{type} has not been cached");
}
return true;
});
AddAssert("check OsuGameBase DI members", () =>
{
foreach (var type in requiredGameBaseDependencies)
{
if (gameBase.Dependencies.Get(type) == null)
throw new InvalidOperationException($"{type} has not been cached");
}
return true;
});
}
}
}