Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update framework #28286

Merged
merged 5 commits into from
May 23, 2024
Merged

Update framework #28286

merged 5 commits into from
May 23, 2024

Conversation

peppy
Copy link
Member

@peppy peppy commented May 22, 2024

Reverts d7d569c, which was temporarily committed to fix some serious issues with SDL3. New framework target version now defaults back to SDL2.

@bdach bdach self-requested a review May 22, 2024 13:33
@peppy
Copy link
Member Author

peppy commented May 22, 2024

@smoogipoo there's a few cases of InputManager.ChangeFocus in tests which I'm not sure how to fix. Can you take a look and propose a solution?

@bdach
Copy link
Collaborator

bdach commented May 22, 2024

In the framework-side changes the solution seems to just be to cast InputManager to IFocusManager? I wanted to just unthinkingly apply that everywhere (although it seems dubious to me that that is required, but it passed review sooooo)

For reference:

diff --git a/osu.Game.Tests/Visual/Editing/TestSceneHitObjectSampleAdjustments.cs b/osu.Game.Tests/Visual/Editing/TestSceneHitObjectSampleAdjustments.cs
index 1415ff4b0f..0e12ed68e4 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneHitObjectSampleAdjustments.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneHitObjectSampleAdjustments.cs
@@ -5,6 +5,7 @@
 using System.Collections.Generic;
 using Humanizer;
 using NUnit.Framework;
+using osu.Framework.Input;
 using osu.Framework.Testing;
 using osu.Game.Audio;
 using osu.Game.Beatmaps;
@@ -396,7 +397,7 @@ private void dismissPopover()
             textBox.Current.Value = bank;
             // force a commit via keyboard.
             // this is needed when testing attempting to set empty bank - which should revert to the previous value, but only on commit.
-            InputManager.ChangeFocus(textBox);
+            ((IFocusManager)InputManager).ChangeFocus(textBox);
             InputManager.Key(Key.Enter);
         });
 
diff --git a/osu.Game.Tests/Visual/Editing/TestSceneLabelledTimeSignature.cs b/osu.Game.Tests/Visual/Editing/TestSceneLabelledTimeSignature.cs
index e91596b872..3d7d0797d4 100644
--- a/osu.Game.Tests/Visual/Editing/TestSceneLabelledTimeSignature.cs
+++ b/osu.Game.Tests/Visual/Editing/TestSceneLabelledTimeSignature.cs
@@ -6,6 +6,7 @@
 using System.Linq;
 using NUnit.Framework;
 using osu.Framework.Graphics;
+using osu.Framework.Input;
 using osu.Framework.Testing;
 using osu.Game.Beatmaps.Timing;
 using osu.Game.Graphics.UserInterface;
@@ -62,12 +63,12 @@ public void TestChangeNumerator()
             createLabelledTimeSignature(TimeSignature.SimpleQuadruple);
             AddAssert("current is 4/4", () => timeSignature.Current.Value.Equals(TimeSignature.SimpleQuadruple));
 
-            AddStep("focus text box", () => InputManager.ChangeFocus(numeratorTextBox));
+            AddStep("focus text box", () => ((IFocusManager)InputManager).ChangeFocus(numeratorTextBox));
 
             AddStep("set numerator to 7", () => numeratorTextBox.Current.Value = "7");
             AddAssert("current is 4/4", () => timeSignature.Current.Value.Equals(TimeSignature.SimpleQuadruple));
 
-            AddStep("drop focus", () => InputManager.ChangeFocus(null));
+            AddStep("drop focus", () => ((IFocusManager)InputManager).ChangeFocus(null));
             AddAssert("current is 7/4", () => timeSignature.Current.Value.Equals(new TimeSignature(7)));
         }
 
@@ -77,12 +78,12 @@ public void TestInvalidChangeRollbackOnCommit()
             createLabelledTimeSignature(TimeSignature.SimpleQuadruple);
             AddAssert("current is 4/4", () => timeSignature.Current.Value.Equals(TimeSignature.SimpleQuadruple));
 
-            AddStep("focus text box", () => InputManager.ChangeFocus(numeratorTextBox));
+            AddStep("focus text box", () => ((IFocusManager)InputManager).ChangeFocus(numeratorTextBox));
 
             AddStep("set numerator to 0", () => numeratorTextBox.Current.Value = "0");
             AddAssert("current is 4/4", () => timeSignature.Current.Value.Equals(TimeSignature.SimpleQuadruple));
 
-            AddStep("drop focus", () => InputManager.ChangeFocus(null));
+            AddStep("drop focus", () => ((IFocusManager)InputManager).ChangeFocus(null));
             AddAssert("current is 4/4", () => timeSignature.Current.Value.Equals(TimeSignature.SimpleQuadruple));
             AddAssert("numerator is 4", () => numeratorTextBox.Current.Value == "4");
         }
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs
index 8ddbd84890..a1452ddb31 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs
@@ -10,6 +10,7 @@
 using osu.Framework.Extensions.ObjectExtensions;
 using osu.Framework.Graphics;
 using osu.Framework.Graphics.Containers;
+using osu.Framework.Input;
 using osu.Framework.Localisation;
 using osu.Framework.Testing;
 using osu.Framework.Utils;
@@ -623,7 +624,7 @@ public void TestSearchBoxFocusToggleRespondsToExternalChanges()
             AddStep("press tab", () => InputManager.Key(Key.Tab));
             AddAssert("search text box focused", () => modSelectOverlay.SearchTextBox.HasFocus);
 
-            AddStep("unfocus search text box externally", () => InputManager.ChangeFocus(null));
+            AddStep("unfocus search text box externally", () => ((IFocusManager)InputManager).ChangeFocus(null));
 
             AddStep("press tab", () => InputManager.Key(Key.Tab));
             AddAssert("search text box focused", () => modSelectOverlay.SearchTextBox.HasFocus);
diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneSliderWithTextBoxInput.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneSliderWithTextBoxInput.cs
index d23fcebae3..06b9623508 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneSliderWithTextBoxInput.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneSliderWithTextBoxInput.cs
@@ -5,6 +5,7 @@
 using NUnit.Framework;
 using osu.Framework.Bindables;
 using osu.Framework.Graphics;
+using osu.Framework.Input;
 using osu.Framework.Testing;
 using osu.Game.Graphics.UserInterface;
 using osu.Game.Graphics.UserInterfaceV2;
@@ -42,7 +43,7 @@ public void TestNonInstantaneousMode()
         {
             AddStep("set instantaneous to false", () => sliderWithTextBoxInput.Instantaneous = false);
 
-            AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
+            AddStep("focus textbox", () => ((IFocusManager)InputManager).ChangeFocus(textBox));
             AddStep("change text", () => textBox.Text = "3");
             AddAssert("slider not moved", () => slider.Current.Value, () => Is.Zero);
             AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.Zero);
@@ -61,7 +62,7 @@ public void TestNonInstantaneousMode()
             AddAssert("textbox changed", () => textBox.Current.Value, () => Is.EqualTo("-5"));
             AddAssert("current changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
 
-            AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
+            AddStep("focus textbox", () => ((IFocusManager)InputManager).ChangeFocus(textBox));
             AddStep("set text to invalid", () => textBox.Text = "garbage");
             AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
             AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
@@ -71,12 +72,12 @@ public void TestNonInstantaneousMode()
             AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
             AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
 
-            AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
+            AddStep("focus textbox", () => ((IFocusManager)InputManager).ChangeFocus(textBox));
             AddStep("set text to invalid", () => textBox.Text = "garbage");
             AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
             AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
 
-            AddStep("lose focus", () => InputManager.ChangeFocus(null));
+            AddStep("lose focus", () => ((IFocusManager)InputManager).ChangeFocus(null));
             AddAssert("text restored", () => textBox.Text, () => Is.EqualTo("-5"));
             AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
             AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
@@ -87,7 +88,7 @@ public void TestInstantaneousMode()
         {
             AddStep("set instantaneous to true", () => sliderWithTextBoxInput.Instantaneous = true);
 
-            AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
+            AddStep("focus textbox", () => ((IFocusManager)InputManager).ChangeFocus(textBox));
             AddStep("change text", () => textBox.Text = "3");
             AddAssert("slider moved", () => slider.Current.Value, () => Is.EqualTo(3));
             AddAssert("current changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(3));
@@ -106,7 +107,7 @@ public void TestInstantaneousMode()
             AddAssert("textbox not changed", () => textBox.Current.Value, () => Is.EqualTo("-5"));
             AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
 
-            AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
+            AddStep("focus textbox", () => ((IFocusManager)InputManager).ChangeFocus(textBox));
             AddStep("set text to invalid", () => textBox.Text = "garbage");
             AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
             AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
@@ -116,12 +117,12 @@ public void TestInstantaneousMode()
             AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
             AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
 
-            AddStep("focus textbox", () => InputManager.ChangeFocus(textBox));
+            AddStep("focus textbox", () => ((IFocusManager)InputManager).ChangeFocus(textBox));
             AddStep("set text to invalid", () => textBox.Text = "garbage");
             AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
             AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));
 
-            AddStep("lose focus", () => InputManager.ChangeFocus(null));
+            AddStep("lose focus", () => ((IFocusManager)InputManager).ChangeFocus(null));
             AddAssert("text restored", () => textBox.Text, () => Is.EqualTo("-5"));
             AddAssert("slider not moved", () => slider.Current.Value, () => Is.EqualTo(-5));
             AddAssert("current not changed", () => sliderWithTextBoxInput.Current.Value, () => Is.EqualTo(-5));

@peppy
Copy link
Member Author

peppy commented May 22, 2024

There's also one failing test (TestSceneOsuDropdown doesn't manage to perform the actions it needs to). I'll look at a fix unless a branch already exists.

@smoogipoo
Copy link
Contributor

Wow. That test is really dodge.

@peppy
Copy link
Member Author

peppy commented May 22, 2024

Wow. That test is really dodge.

Is it? I can't figure what broke it, but one would assume calling Open() should work, and it isn't anymore.

In addition, TestSceneFilterControl.TestButtonAddsAndRemovesBeatmap is not happy.

@smoogipoo
Copy link
Contributor

For TestSceneFilterControl, I propose this change: ppy/osu-framework#6297

@smoogipoo
Copy link
Contributor

smoogipoo commented May 22, 2024

but one would assume calling Open() should work

All I'll say is there's a reason private and public exist, and why this test is using ChildrenOfType<> to achieve this. I'll add back support for everything this is doing in o!f.

@peppy
Copy link
Member Author

peppy commented May 22, 2024

All I'll say is there's a reason private and public exist

This is a bit cryptic, can you explain?

@smoogipoo
Copy link
Contributor

Should be supported by ppy/osu-framework#6298

@peppy peppy merged commit 1267536 into ppy:master May 23, 2024
15 of 17 checks passed
@peppy peppy deleted the framework-update-rollback-revert branch May 23, 2024 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants