Fix textbox focus test in ChatOverlayV2

This commit is contained in:
Jai Sharma
2022-05-14 12:16:00 +01:00
parent 2163a78b7f
commit bd68ffa805
2 changed files with 6 additions and 5 deletions

View File

@ -365,19 +365,19 @@ namespace osu.Game.Tests.Visual.Online
} }
[Test] [Test]
public void TextBoxRetainsFocus() public void TestTextBoxRetainsFocus()
{ {
AddStep("Show overlay", () => chatOverlay.Show()); AddStep("Show overlay", () => chatOverlay.Show());
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
AddStep("Join channel 1", () => channelManager.JoinChannel(testChannel1)); AddStep("Join channel 1", () => channelManager.JoinChannel(testChannel1));
AddStep("Select channel 1", () => clickDrawable(getChannelListItem(testChannel1))); AddStep("Select channel 1", () => clickDrawable(getChannelListItem(testChannel1)));
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
AddStep("Click drawable channel", () => clickDrawable(currentDrawableChannel));
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
AddStep("Click selector", () => clickDrawable(chatOverlay.ChildrenOfType<ChannelListSelector>().Single())); AddStep("Click selector", () => clickDrawable(chatOverlay.ChildrenOfType<ChannelListSelector>().Single()));
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
AddStep("Click listing", () => clickDrawable(chatOverlay.ChildrenOfType<ChannelListing>().Single())); AddStep("Click listing", () => clickDrawable(chatOverlay.ChildrenOfType<ChannelListing>().Single()));
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
AddStep("Click drawable channel", () => clickDrawable(currentDrawableChannel));
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
AddStep("Click channel list", () => clickDrawable(chatOverlay.ChildrenOfType<ChannelList>().Single())); AddStep("Click channel list", () => clickDrawable(chatOverlay.ChildrenOfType<ChannelList>().Single()));
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
AddStep("Click top bar", () => clickDrawable(chatOverlay.ChildrenOfType<ChatOverlayTopBar>().Single())); AddStep("Click top bar", () => clickDrawable(chatOverlay.ChildrenOfType<ChatOverlayTopBar>().Single()));

View File

@ -242,12 +242,12 @@ namespace osu.Game.Overlays
{ {
// null channel denotes that we should be showing the listing. // null channel denotes that we should be showing the listing.
currentChannelContainer.Clear(false); currentChannelContainer.Clear(false);
channelListing.State.Value = Visibility.Visible; channelListing.Show();
textBar.ShowSearch.Value = true; textBar.ShowSearch.Value = true;
} }
else else
{ {
channelListing.State.Value = Visibility.Hidden; channelListing.Hide();
textBar.ShowSearch.Value = false; textBar.ShowSearch.Value = false;
if (loadedChannels.ContainsKey(newChannel)) if (loadedChannels.ContainsKey(newChannel))
@ -299,6 +299,7 @@ namespace osu.Game.Overlays
foreach (var channel in leftChannels) foreach (var channel in leftChannels)
{ {
channelList.RemoveChannel(channel); channelList.RemoveChannel(channel);
if (loadedChannels.ContainsKey(channel)) if (loadedChannels.ContainsKey(channel))
{ {
ChatOverlayDrawableChannel loaded = loadedChannels[channel]; ChatOverlayDrawableChannel loaded = loadedChannels[channel];