|
2 | 2 | // See the LICENCE file in the repository root for full licence text.
|
3 | 3 |
|
4 | 4 | using System;
|
5 |
| -using System.Collections.Generic; |
6 |
| -using System.Linq; |
7 | 5 | using NUnit.Framework;
|
8 | 6 | using osu.Framework.Allocation;
|
9 | 7 | using osu.Framework.Graphics;
|
10 |
| -using osu.Framework.Graphics.Containers; |
11 | 8 | using osu.Framework.Graphics.Cursor;
|
12 | 9 | using osu.Framework.Testing;
|
13 | 10 | using osu.Game.Overlays;
|
14 | 11 | using osu.Game.Overlays.Mods;
|
15 |
| -using osu.Game.Rulesets.Mods; |
16 |
| -using osu.Game.Rulesets.Osu; |
17 |
| -using osu.Game.Rulesets.Osu.Mods; |
18 | 12 | using osu.Game.Screens.Footer;
|
19 | 13 | using osu.Game.Screens.SelectV2.Footer;
|
20 |
| -using osuTK.Input; |
21 | 14 |
|
22 | 15 | namespace osu.Game.Tests.Visual.UserInterface
|
23 | 16 | {
|
24 | 17 | public partial class TestSceneScreenFooter : OsuManualInputManagerTestScene
|
25 | 18 | {
|
26 |
| - private ScreenFooterButtonRandom randomButton = null!; |
27 |
| - private ScreenFooterButtonMods modsButton = null!; |
28 |
| - |
29 |
| - private bool nextRandomCalled; |
30 |
| - private bool previousRandomCalled; |
31 |
| - |
32 |
| - private DummyOverlay overlay = null!; |
| 19 | + private ScreenFooter screenFooter = null!; |
| 20 | + private TestModSelectOverlay overlay = null!; |
33 | 21 |
|
34 | 22 | [Cached]
|
35 | 23 | private OverlayColourProvider colourProvider { get; set; } = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
|
36 | 24 |
|
37 | 25 | [SetUp]
|
38 | 26 | public void SetUp() => Schedule(() =>
|
39 | 27 | {
|
40 |
| - nextRandomCalled = false; |
41 |
| - previousRandomCalled = false; |
42 |
| - |
43 |
| - ScreenFooter footer; |
44 |
| - |
45 | 28 | Children = new Drawable[]
|
46 | 29 | {
|
| 30 | + overlay = new TestModSelectOverlay |
| 31 | + { |
| 32 | + Padding = new MarginPadding |
| 33 | + { |
| 34 | + Bottom = ScreenFooter.HEIGHT |
| 35 | + } |
| 36 | + }, |
47 | 37 | new PopoverContainer
|
48 | 38 | {
|
49 | 39 | RelativeSizeAxes = Axes.Both,
|
50 |
| - Child = footer = new ScreenFooter(), |
| 40 | + Child = screenFooter = new ScreenFooter(), |
51 | 41 | },
|
52 |
| - overlay = new DummyOverlay() |
53 | 42 | };
|
54 | 43 |
|
55 |
| - footer.AddButton(modsButton = new ScreenFooterButtonMods { Current = SelectedMods }, overlay); |
56 |
| - footer.AddButton(randomButton = new ScreenFooterButtonRandom |
| 44 | + screenFooter.SetButtons(new ScreenFooterButton[] |
57 | 45 | {
|
58 |
| - NextRandom = () => nextRandomCalled = true, |
59 |
| - PreviousRandom = () => previousRandomCalled = true |
| 46 | + new ScreenFooterButtonMods(overlay) { Current = SelectedMods }, |
| 47 | + new ScreenFooterButtonRandom(), |
| 48 | + new ScreenFooterButtonOptions(), |
60 | 49 | });
|
61 |
| - footer.AddButton(new ScreenFooterButtonOptions()); |
62 |
| - |
63 |
| - overlay.Hide(); |
64 | 50 | });
|
65 | 51 |
|
66 | 52 | [SetUpSteps]
|
67 | 53 | public void SetUpSteps()
|
68 | 54 | {
|
69 |
| - AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>()); |
70 |
| - AddStep("set beatmap", () => Beatmap.Value = CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo))); |
| 55 | + AddStep("show footer", () => screenFooter.Show()); |
71 | 56 | }
|
72 | 57 |
|
| 58 | + /// <summary> |
| 59 | + /// Transition when moving from a screen with no buttons to a screen with buttons. |
| 60 | + /// </summary> |
73 | 61 | [Test]
|
74 |
| - public void TestMods() |
| 62 | + public void TestButtonsIn() |
75 | 63 | {
|
76 |
| - AddStep("one mod", () => SelectedMods.Value = new List<Mod> { new OsuModHidden() }); |
77 |
| - AddStep("two mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock() }); |
78 |
| - AddStep("three mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime() }); |
79 |
| - AddStep("four mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic() }); |
80 |
| - AddStep("five mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic(), new OsuModDifficultyAdjust() }); |
81 |
| - |
82 |
| - AddStep("modified", () => SelectedMods.Value = new List<Mod> { new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }); |
83 |
| - AddStep("modified + one", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }); |
84 |
| - AddStep("modified + two", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }); |
85 |
| - AddStep("modified + three", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModClassic(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }); |
86 |
| - AddStep("modified + four", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModClassic(), new OsuModDifficultyAdjust(), new OsuModDoubleTime { SpeedChange = { Value = 1.2 } } }); |
87 |
| - |
88 |
| - AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>()); |
89 |
| - AddWaitStep("wait", 3); |
90 |
| - AddStep("one mod", () => SelectedMods.Value = new List<Mod> { new OsuModHidden() }); |
91 |
| - |
92 |
| - AddStep("clear mods", () => SelectedMods.Value = Array.Empty<Mod>()); |
93 |
| - AddWaitStep("wait", 3); |
94 |
| - AddStep("five mods", () => SelectedMods.Value = new List<Mod> { new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime(), new OsuModClassic(), new OsuModDifficultyAdjust() }); |
95 | 64 | }
|
96 | 65 |
|
| 66 | + /// <summary> |
| 67 | + /// Transition when moving from a screen with buttons to a screen with no buttons. |
| 68 | + /// </summary> |
97 | 69 | [Test]
|
98 |
| - public void TestShowOptions() |
| 70 | + public void TestButtonsOut() |
99 | 71 | {
|
100 |
| - AddStep("enable options", () => |
101 |
| - { |
102 |
| - var optionsButton = this.ChildrenOfType<ScreenFooterButton>().Last(); |
103 |
| - |
104 |
| - optionsButton.Enabled.Value = true; |
105 |
| - optionsButton.TriggerClick(); |
106 |
| - }); |
| 72 | + AddStep("clear buttons", () => screenFooter.SetButtons(Array.Empty<ScreenFooterButton>())); |
107 | 73 | }
|
108 | 74 |
|
| 75 | + /// <summary> |
| 76 | + /// Transition when moving from a screen with buttons to a screen with buttons. |
| 77 | + /// </summary> |
109 | 78 | [Test]
|
110 |
| - public void TestState() |
| 79 | + public void TestReplaceButtons() |
111 | 80 | {
|
112 |
| - AddToggleStep("set options enabled state", state => this.ChildrenOfType<ScreenFooterButton>().Last().Enabled.Value = state); |
113 |
| - } |
114 |
| - |
115 |
| - [Test] |
116 |
| - public void TestFooterRandom() |
117 |
| - { |
118 |
| - AddStep("press F2", () => InputManager.Key(Key.F2)); |
119 |
| - AddAssert("next random invoked", () => nextRandomCalled && !previousRandomCalled); |
120 |
| - } |
121 |
| - |
122 |
| - [Test] |
123 |
| - public void TestFooterRandomViaMouse() |
124 |
| - { |
125 |
| - AddStep("click button", () => |
| 81 | + AddStep("replace buttons", () => screenFooter.SetButtons(new[] |
126 | 82 | {
|
127 |
| - InputManager.MoveMouseTo(randomButton); |
128 |
| - InputManager.Click(MouseButton.Left); |
129 |
| - }); |
130 |
| - AddAssert("next random invoked", () => nextRandomCalled && !previousRandomCalled); |
| 83 | + new ScreenFooterButton { Text = "One", Action = () => { } }, |
| 84 | + new ScreenFooterButton { Text = "Two", Action = () => { } }, |
| 85 | + new ScreenFooterButton { Text = "Three", Action = () => { } }, |
| 86 | + })); |
131 | 87 | }
|
132 | 88 |
|
133 |
| - [Test] |
134 |
| - public void TestFooterRewind() |
| 89 | + private partial class TestModSelectOverlay : UserModSelectOverlay |
135 | 90 | {
|
136 |
| - AddStep("press Shift+F2", () => |
137 |
| - { |
138 |
| - InputManager.PressKey(Key.LShift); |
139 |
| - InputManager.PressKey(Key.F2); |
140 |
| - InputManager.ReleaseKey(Key.F2); |
141 |
| - InputManager.ReleaseKey(Key.LShift); |
142 |
| - }); |
143 |
| - AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled); |
144 |
| - } |
145 |
| - |
146 |
| - [Test] |
147 |
| - public void TestFooterRewindViaShiftMouseLeft() |
148 |
| - { |
149 |
| - AddStep("shift + click button", () => |
150 |
| - { |
151 |
| - InputManager.PressKey(Key.LShift); |
152 |
| - InputManager.MoveMouseTo(randomButton); |
153 |
| - InputManager.Click(MouseButton.Left); |
154 |
| - InputManager.ReleaseKey(Key.LShift); |
155 |
| - }); |
156 |
| - AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled); |
157 |
| - } |
158 |
| - |
159 |
| - [Test] |
160 |
| - public void TestFooterRewindViaMouseRight() |
161 |
| - { |
162 |
| - AddStep("right click button", () => |
163 |
| - { |
164 |
| - InputManager.MoveMouseTo(randomButton); |
165 |
| - InputManager.Click(MouseButton.Right); |
166 |
| - }); |
167 |
| - AddAssert("previous random invoked", () => previousRandomCalled && !nextRandomCalled); |
168 |
| - } |
169 |
| - |
170 |
| - [Test] |
171 |
| - public void TestOverlayPresent() |
172 |
| - { |
173 |
| - AddStep("Press F1", () => |
174 |
| - { |
175 |
| - InputManager.MoveMouseTo(modsButton); |
176 |
| - InputManager.Click(MouseButton.Left); |
177 |
| - }); |
178 |
| - AddAssert("Overlay visible", () => overlay.State.Value == Visibility.Visible); |
179 |
| - AddStep("Hide", () => overlay.Hide()); |
180 |
| - } |
181 |
| - |
182 |
| - private partial class DummyOverlay : ShearedOverlayContainer |
183 |
| - { |
184 |
| - public DummyOverlay() |
185 |
| - : base(OverlayColourScheme.Green) |
186 |
| - { |
187 |
| - } |
188 |
| - |
189 |
| - [BackgroundDependencyLoader] |
190 |
| - private void load() |
191 |
| - { |
192 |
| - Header.Title = "An overlay"; |
193 |
| - } |
| 91 | + protected override bool ShowPresets => true; |
194 | 92 | }
|
195 | 93 | }
|
196 | 94 | }
|
0 commit comments