Skip to content

Commit

Permalink
Fix failing tests due to more textboxes being present with searchable…
Browse files Browse the repository at this point in the history
… dropdowns
  • Loading branch information
peppy committed Dec 13, 2023
1 parent 73189be commit 5e10f9f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
10 changes: 6 additions & 4 deletions osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ public void TestSongSelectBackActionHandling()

PushAndConfirm(() => songSelect = new TestPlaySongSelect());

AddStep("set filter", () => songSelect.ChildrenOfType<SearchTextBox>().Single().Current.Value = "test");
AddStep("set filter", () => filterControlTextBox().Current.Value = "test");
AddStep("press back", () => InputManager.Click(MouseButton.Button1));

AddAssert("still at song select", () => Game.ScreenStack.CurrentScreen == songSelect);
AddAssert("filter cleared", () => string.IsNullOrEmpty(songSelect.ChildrenOfType<SearchTextBox>().Single().Current.Value));
AddAssert("filter cleared", () => string.IsNullOrEmpty(filterControlTextBox().Current.Value));

AddStep("set filter again", () => songSelect.ChildrenOfType<SearchTextBox>().Single().Current.Value = "test");
AddStep("set filter again", () => filterControlTextBox().Current.Value = "test");
AddStep("open collections dropdown", () =>
{
InputManager.MoveMouseTo(songSelect.ChildrenOfType<CollectionDropdown>().Single());
Expand All @@ -163,10 +163,12 @@ public void TestSongSelectBackActionHandling()
.ChildrenOfType<Dropdown<CollectionFilterMenuItem>.DropdownMenu>().Single().State == MenuState.Closed);

AddStep("press back a second time", () => InputManager.Click(MouseButton.Button1));
AddAssert("filter cleared", () => string.IsNullOrEmpty(songSelect.ChildrenOfType<SearchTextBox>().Single().Current.Value));
AddAssert("filter cleared", () => string.IsNullOrEmpty(filterControlTextBox().Current.Value));

AddStep("press back a third time", () => InputManager.Click(MouseButton.Button1));
ConfirmAtMainMenu();

TextBox filterControlTextBox() => songSelect.ChildrenOfType<FilterControl.FilterControlTextBox>().Single();
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ public void TestChatReport()
AddAssert("Nothing happened", () => this.ChildrenOfType<ReportChatPopover>().Any());
AddStep("Set report data", () =>
{
var field = this.ChildrenOfType<ReportChatPopover>().Single().ChildrenOfType<OsuTextBox>().Single();
var field = this.ChildrenOfType<ReportChatPopover>().Single().ChildrenOfType<OsuTextBox>().First();
field.Current.Value = "test other";
});

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public void TestReport()
AddAssert("Nothing happened", () => this.ChildrenOfType<ReportCommentPopover>().Any());
AddStep("Set report data", () =>
{
var field = this.ChildrenOfType<ReportCommentPopover>().Single().ChildrenOfType<OsuTextBox>().Single();
var field = this.ChildrenOfType<ReportCommentPopover>().Single().ChildrenOfType<OsuTextBox>().First();
field.Current.Value = report_text;
var reason = this.ChildrenOfType<OsuEnumDropdown<CommentReportReason>>().Single();
reason.Current.Value = CommentReportReason.Other;
Expand Down
22 changes: 11 additions & 11 deletions osu.Game.Tests/Visual/Settings/TestSceneSettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public void TestFiltering([Values] bool beforeLoad)
AddStep("reset mouse", () => InputManager.MoveMouseTo(settings));

if (beforeLoad)
AddStep("set filter", () => settings.SectionsContainer.ChildrenOfType<SearchTextBox>().First().Current.Value = "scaling");
AddStep("set filter", () => settings.SectionsContainer.ChildrenOfType<SettingsSearchTextBox>().First().Current.Value = "scaling");

AddUntilStep("wait for items to load", () => settings.SectionsContainer.ChildrenOfType<IFilterable>().Any());

if (!beforeLoad)
AddStep("set filter", () => settings.SectionsContainer.ChildrenOfType<SearchTextBox>().First().Current.Value = "scaling");
AddStep("set filter", () => settings.SectionsContainer.ChildrenOfType<SettingsSearchTextBox>().First().Current.Value = "scaling");

AddAssert("ensure all items match filter", () => settings.SectionsContainer
.ChildrenOfType<SettingsSection>().Where(f => f.IsPresent)
Expand All @@ -76,7 +76,7 @@ public void TestFilterAfterLoad()

AddUntilStep("wait for items to load", () => settings.SectionsContainer.ChildrenOfType<IFilterable>().Any());

AddStep("set filter", () => settings.SectionsContainer.ChildrenOfType<SearchTextBox>().First().Current.Value = "scaling");
AddStep("set filter", () => settings.SectionsContainer.ChildrenOfType<SettingsSearchTextBox>().First().Current.Value = "scaling");
}

[Test]
Expand All @@ -94,7 +94,7 @@ public void TestTextboxFocusAfterNestedPanelBackButton()
AddStep("reset mouse", () => InputManager.MoveMouseTo(settings));

AddUntilStep("sections loaded", () => settings.SectionsContainer.Children.Count > 0);
AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<FocusedTextBox>().FirstOrDefault()?.HasFocus == true);
AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<SettingsSearchTextBox>().FirstOrDefault()?.HasFocus == true);

AddStep("open key binding subpanel", () =>
{
Expand All @@ -106,13 +106,13 @@ public void TestTextboxFocusAfterNestedPanelBackButton()

AddUntilStep("binding panel textbox focused", () => settings
.ChildrenOfType<KeyBindingPanel>().FirstOrDefault()?
.ChildrenOfType<FocusedTextBox>().FirstOrDefault()?.HasFocus == true);
.ChildrenOfType<SettingsSearchTextBox>().FirstOrDefault()?.HasFocus == true);

AddStep("Press back", () => settings
.ChildrenOfType<KeyBindingPanel>().FirstOrDefault()?
.ChildrenOfType<SettingsSubPanel.BackButton>().FirstOrDefault()?.TriggerClick());

AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<FocusedTextBox>().FirstOrDefault()?.HasFocus == true);
AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<SettingsSearchTextBox>().FirstOrDefault()?.HasFocus == true);
}

[Test]
Expand All @@ -121,7 +121,7 @@ public void TestTextboxFocusAfterNestedPanelEscape()
AddStep("reset mouse", () => InputManager.MoveMouseTo(settings));

AddUntilStep("sections loaded", () => settings.SectionsContainer.Children.Count > 0);
AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<FocusedTextBox>().FirstOrDefault()?.HasFocus == true);
AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<SettingsSearchTextBox>().FirstOrDefault()?.HasFocus == true);

AddStep("open key binding subpanel", () =>
{
Expand All @@ -133,19 +133,19 @@ public void TestTextboxFocusAfterNestedPanelEscape()

AddUntilStep("binding panel textbox focused", () => settings
.ChildrenOfType<KeyBindingPanel>().FirstOrDefault()?
.ChildrenOfType<FocusedTextBox>().FirstOrDefault()?.HasFocus == true);
.ChildrenOfType<SettingsSearchTextBox>().FirstOrDefault()?.HasFocus == true);

AddStep("Escape", () => InputManager.Key(Key.Escape));

AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<FocusedTextBox>().FirstOrDefault()?.HasFocus == true);
AddUntilStep("top-level textbox focused", () => settings.SectionsContainer.ChildrenOfType<SettingsSearchTextBox>().FirstOrDefault()?.HasFocus == true);
}

[Test]
public void TestSearchTextBoxSelectedOnShow()
{
SearchTextBox searchTextBox = null!;
SettingsSearchTextBox searchTextBox = null!;

AddStep("set text", () => (searchTextBox = settings.SectionsContainer.ChildrenOfType<SearchTextBox>().First()).Current.Value = "some text");
AddStep("set text", () => (searchTextBox = settings.SectionsContainer.ChildrenOfType<SettingsSearchTextBox>().First()).Current.Value = "some text");
AddAssert("no text selected", () => searchTextBox.SelectedText == string.Empty);
AddRepeatStep("toggle visibility", () => settings.ToggleVisibility(), 2);
AddAssert("search text selected", () => searchTextBox.SelectedText == searchTextBox.Current.Value);
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ public void TestCutInFilterTextBox()
{
createSongSelect();

AddStep("set filter text", () => songSelect!.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono");
AddStep("set filter text", () => songSelect!.FilterControl.ChildrenOfType<FilterControl.FilterControlTextBox>().First().Text = "nonono");
AddStep("select all", () => InputManager.Keys(PlatformAction.SelectAll));
AddStep("press ctrl-x", () =>
{
Expand All @@ -1144,7 +1144,7 @@ public void TestCutInFilterTextBox()
InputManager.ReleaseKey(Key.ControlLeft);
});

AddAssert("filter text cleared", () => songSelect!.FilterControl.ChildrenOfType<SearchTextBox>().First().Text, () => Is.Empty);
AddAssert("filter text cleared", () => songSelect!.FilterControl.ChildrenOfType<FilterControl.FilterControlTextBox>().First().Text, () => Is.Empty);
}

private void waitForInitialSelection()
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Screens/Select/FilterControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void Activate()

protected override bool OnHover(HoverEvent e) => true;

private partial class FilterControlTextBox : SeekLimitedSearchTextBox
internal partial class FilterControlTextBox : SeekLimitedSearchTextBox
{
private const float filter_text_size = 12;

Expand Down

0 comments on commit 5e10f9f

Please sign in to comment.