From dbe5887f7e3f19130e724fb87d73f8c7631e2fda Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 28 Feb 2019 16:18:46 +0900 Subject: [PATCH] Fix issue for user hover blur for now by checking for current screen, fix test. --- .../Visual/TestCaseBackgroundScreenBeatmap.cs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs index 2a6bb4e691..bec113430b 100644 --- a/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/TestCaseBackgroundScreenBeatmap.cs @@ -11,6 +11,8 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; +using osu.Framework.Input.States; using osu.Framework.Platform; using osu.Framework.Screens; using osu.Game.Beatmaps; @@ -123,12 +125,11 @@ namespace osu.Game.Tests.Visual InputManager.MoveMouseTo(playerLoader.ScreenPos); }); AddUntilStep(() => player?.IsLoaded ?? false, "Wait for player to load"); + AddStep("Trigger hover event", () => playerLoader.TriggerOnHover()); AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent()); - AddStep("Trigger background preview when loaded", () => InputManager.MoveMouseTo(playerLoader.VisualSettingsPos)); - AddWaitStep(1); - AddStep("Untrigger background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos)); waitForDim(); AddAssert("Screen is dimmed", () => songSelect.IsBackgroundDimmed()); + AddAssert("Screen is unblurred", () => songSelect.IsBackgroundUnblurred()); } /// @@ -252,7 +253,7 @@ namespace osu.Game.Tests.Visual { Size = new Vector2(250, 50), Alpha = 1, - Colour = Color4.White, + Colour = Color4.Tomato, Anchor = Anchor.Centre, Origin = Anchor.Centre, Text = "THIS IS A STORYBOARD", @@ -285,6 +286,7 @@ namespace osu.Game.Tests.Visual { Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { new OsuModNoFail() }); songSelect.DimLevel.Value = 0.7f; + songSelect.BlurLevel.Value = 0.0f; }); AddUntilStep(() => songSelect.Carousel.SelectedBeatmap != null, "Song select has selection"); } @@ -300,6 +302,7 @@ namespace osu.Game.Tests.Visual public readonly Bindable DimEnabled = new Bindable(); public readonly Bindable DimLevel = new Bindable(); + public readonly Bindable BlurLevel = new Bindable(); public new BeatmapCarousel Carousel => base.Carousel; @@ -307,11 +310,13 @@ namespace osu.Game.Tests.Visual private void load(OsuConfigManager config) { config.BindWith(OsuSetting.DimLevel, DimLevel); + config.BindWith(OsuSetting.BlurLevel, BlurLevel); } - //public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)DimLevel.Value); public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)DimLevel.Value); + public bool IsBackgroundUnblurred() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0); + public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White; public bool IsBackgroundInvisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 0; @@ -396,6 +401,11 @@ namespace osu.Game.Tests.Visual { } + public void TriggerOnHover() + { + OnHover(new HoverEvent(new InputState())); + } + protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); } @@ -406,6 +416,8 @@ namespace osu.Game.Tests.Visual public Color4 CurrentColour => ((TestUserDimContainer)FadeContainer).CurrentColour; public float CurrentAlpha => ((TestUserDimContainer)FadeContainer).CurrentAlpha; + public Vector2 CurrentBlur => Background.BlurSigma; + public FadeAccessibleBackground(WorkingBeatmap beatmap) : base(beatmap) {