Skip to content

Commit

Permalink
Update channel visibility tests to be more correct
Browse files Browse the repository at this point in the history
  • Loading branch information
jai-x committed May 9, 2022
1 parent 5f3bea8 commit 9ec8b60
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions osu.Game.Tests/Visual/Online/TestSceneChatOverlayV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ public void SetUpSteps()
});
}

[Test]
public void TestBasic()
{
AddStep("Show overlay with channel", () =>
{
chatOverlay.Show();
Channel joinedChannel = channelManager.JoinChannel(testChannel1);
channelManager.CurrentChannel.Value = joinedChannel;
});
AddAssert("Overlay is visible", () => chatOverlay.State.Value == Visibility.Visible);
AddAssert("Channel is visible", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
}

[Test]
public void TestShowHide()
{
Expand Down Expand Up @@ -158,20 +171,17 @@ public void TestChatHeight()
public void TestChannelSelection()
{
AddStep("Show overlay", () => chatOverlay.Show());
AddAssert("Listing is visible", () => listingVisibility == Visibility.Visible);
AddAssert("Listing is visible", () => listingIsVisible);
AddStep("Join channel 1", () => channelManager.JoinChannel(testChannel1));
AddStep("Select channel 1", () => clickDrawable(getChannelListItem(testChannel1)));
AddAssert("Listing is hidden", () => listingVisibility == Visibility.Hidden);
AddAssert("Loading is hidden", () => loadingVisibility == Visibility.Hidden);
AddAssert("Current channel is correct", () => channelManager.CurrentChannel.Value == testChannel1);
AddAssert("DrawableChannel is correct", () => currentDrawableChannel.Channel == testChannel1);
AddAssert("Channel 1 is visible", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
}

[Test]
public void TestSearchInListing()
{
AddStep("Show overlay", () => chatOverlay.Show());
AddAssert("Listing is visible", () => listingVisibility == Visibility.Visible);
AddAssert("Listing is visible", () => listingIsVisible);
AddStep("Search for 'number 2'", () => chatOverlayTextBox.Text = "number 2");
AddUntilStep("Only channel 2 visibile", () =>
{
Expand Down Expand Up @@ -263,6 +273,7 @@ public void TestHighlightOnCurrentChannel()
});
});
AddStep("Highlight message", () => chatOverlay.HighlightMessage(message, testChannel1));
AddAssert("Channel 1 is visible", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
}

[Test]
Expand All @@ -285,8 +296,7 @@ public void TestHighlightOnAnotherChannel()
});
});
AddStep("Highlight message", () => chatOverlay.HighlightMessage(message, testChannel2));
AddAssert("Channel 2 is selected", () => channelManager.CurrentChannel.Value == testChannel2);
AddAssert("Channel 2 is visible", () => currentDrawableChannel.Channel == testChannel2);
AddAssert("Channel 2 is visible", () => channelIsVisible && currentDrawableChannel.Channel == testChannel2);
}

[Test]
Expand All @@ -310,8 +320,7 @@ public void TestHighlightOnLeftChannel()
});
AddStep("Leave channel 2", () => channelManager.LeaveChannel(testChannel2));
AddStep("Highlight message", () => chatOverlay.HighlightMessage(message, testChannel2));
AddAssert("Channel 2 is selected", () => channelManager.CurrentChannel.Value == testChannel2);
AddAssert("Channel 2 is visible", () => currentDrawableChannel.Channel == testChannel2);
AddAssert("Channel 2 is visible", () => channelIsVisible && currentDrawableChannel.Channel == testChannel2);
}

[Test]
Expand All @@ -331,6 +340,7 @@ public void TestHighlightWhileChatNeverOpen()
});
});
AddStep("Highlight message", () => chatOverlay.HighlightMessage(message, testChannel1));
AddAssert("Channel 1 is visible", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
}

[Test]
Expand All @@ -351,6 +361,7 @@ public void TestHighlightWithNullChannel()
});
AddStep("Set null channel", () => channelManager.CurrentChannel.Value = null);
AddStep("Highlight message", () => chatOverlay.HighlightMessage(message, testChannel1));
AddAssert("Channel 1 is visible", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
}

[Test]
Expand All @@ -375,11 +386,14 @@ public void TextBoxRetainsFocus()
AddAssert("TextBox is not focused", () => InputManager.FocusedDrawable == null);
}

private Visibility listingVisibility =>
chatOverlay.ChildrenOfType<ChannelListing>().Single().State.Value;
private bool listingIsVisible =>
chatOverlay.ChildrenOfType<ChannelListing>().Single().State.Value == Visibility.Visible;

private bool loadingIsVisible =>
chatOverlay.ChildrenOfType<LoadingLayer>().Single().State.Value == Visibility.Visible;

private Visibility loadingVisibility =>
chatOverlay.ChildrenOfType<LoadingLayer>().Single().State.Value;
private bool channelIsVisible =>
!listingIsVisible && !loadingIsVisible;

private DrawableChannel currentDrawableChannel =>
chatOverlay.ChildrenOfType<DrawableChannel>().Single();
Expand Down

0 comments on commit 9ec8b60

Please sign in to comment.