1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 05:42:54 +08:00

Use BindableFloat in chat height tests

This commit is contained in:
Jai Sharma 2022-05-05 23:13:43 +01:00
parent 0974de8fb0
commit 7ffe3b132f

View File

@ -133,22 +133,22 @@ namespace osu.Game.Tests.Visual.Online
[Test] [Test]
public void TestChatHeight() public void TestChatHeight()
{ {
Bindable<float> configChatHeight = null; BindableFloat configChatHeight = new BindableFloat();
config.BindWith(OsuSetting.ChatDisplayHeight, configChatHeight);
float newHeight = 0; float newHeight = 0;
AddStep("Bind config chat height", () => configChatHeight = config.GetBindable<float>(OsuSetting.ChatDisplayHeight).GetBoundCopy()); AddStep("Reset config chat height", () => configChatHeight.SetDefault());
AddStep("Set config chat height", () => configChatHeight.Value = 0.4f);
AddStep("Show overlay", () => chatOverlay.Show()); AddStep("Show overlay", () => chatOverlay.Show());
AddAssert("Overlay uses config height", () => chatOverlay.Height == 0.4f); AddAssert("Overlay uses config height", () => chatOverlay.Height == configChatHeight.Default);
AddStep("Drag overlay to new height", () => AddStep("Click top bar", () =>
{ {
InputManager.MoveMouseTo(chatOverlayTopBar); InputManager.MoveMouseTo(chatOverlayTopBar);
InputManager.PressButton(MouseButton.Left); InputManager.PressButton(MouseButton.Left);
InputManager.MoveMouseTo(chatOverlayTopBar, new Vector2(0, -300));
InputManager.ReleaseButton(MouseButton.Left);
}); });
AddStep("Drag overlay to new height", () => InputManager.MoveMouseTo(chatOverlayTopBar, new Vector2(0, -300)));
AddStep("Stop dragging", () => InputManager.ReleaseButton(MouseButton.Left));
AddStep("Store new height", () => newHeight = chatOverlay.Height); AddStep("Store new height", () => newHeight = chatOverlay.Height);
AddAssert("Config height changed", () => configChatHeight.Value != 0.4f && configChatHeight.Value == newHeight); AddAssert("Config height changed", () => !configChatHeight.IsDefault && configChatHeight.Value == newHeight);
AddStep("Hide overlay", () => chatOverlay.Hide()); AddStep("Hide overlay", () => chatOverlay.Hide());
AddStep("Show overlay", () => chatOverlay.Show()); AddStep("Show overlay", () => chatOverlay.Show());
AddAssert("Overlay uses new height", () => chatOverlay.Height == newHeight); AddAssert("Overlay uses new height", () => chatOverlay.Height == newHeight);