Skip to content

Commit

Permalink
Fix slider tests and incorrect nullability handling around `freehandT…
Browse files Browse the repository at this point in the history
…oolboxGroup`
  • Loading branch information
peppy committed Dec 13, 2023
1 parent 5e10f9f commit c2d3dcd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ public partial class SliderPlacementBlueprint : PlacementBlueprint
private int currentSegmentLength;

[Resolved(CanBeNull = true)]
[CanBeNull]
private IPositionSnapProvider positionSnapProvider { get; set; }

[Resolved(CanBeNull = true)]
[CanBeNull]
private IDistanceSnapProvider distanceSnapProvider { get; set; }

[Resolved(CanBeNull = true)]
[CanBeNull]
private FreehandSliderToolboxGroup freehandToolboxGroup { get; set; }

private readonly IncrementalBSplineBuilder bSplineBuilder = new IncrementalBSplineBuilder { Degree = 4 };
Expand Down Expand Up @@ -363,7 +366,7 @@ private void updateSliderPathFromBSplineBuilder()

private Vector2[] tryCircleArc(List<Vector2> segment)
{
if (segment.Count < 3 || freehandToolboxGroup.CircleThreshold.Value == 0) return null;
if (segment.Count < 3 || freehandToolboxGroup?.CircleThreshold.Value == 0) return null;

// Assume the segment creates a reasonable circular arc and then check if it reasonable
var points = PathApproximator.BSplineToPiecewiseLinear(segment.ToArray(), bSplineBuilder.Degree);
Expand Down Expand Up @@ -436,7 +439,7 @@ private Vector2[] tryCircleArc(List<Vector2> segment)

loss /= points.Count;

return loss > freehandToolboxGroup.CircleThreshold.Value || totalWinding > MathHelper.TwoPi ? null : circleArcControlPoints;
return loss > freehandToolboxGroup?.CircleThreshold.Value || totalWinding > MathHelper.TwoPi ? null : circleArcControlPoints;
}

private enum SliderPlacementState
Expand Down
9 changes: 4 additions & 5 deletions osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat;
using osu.Game.Overlays;
Expand Down Expand Up @@ -614,7 +613,7 @@ public void TestExternalBeatmapChangeWhileFiltered(bool differentRuleset)

AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo != null);

AddStep("set filter text", () => songSelect!.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono");
AddStep("set filter text", () => songSelect!.FilterControl.ChildrenOfType<FilterControl.FilterControlTextBox>().First().Text = "nonono");

AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap);

Expand Down Expand Up @@ -648,7 +647,7 @@ public void TestExternalBeatmapChangeWhileFiltered(bool differentRuleset)
AddUntilStep("carousel has correct", () => songSelect!.Carousel.SelectedBeatmapInfo?.MatchesOnlineID(target) == true);
AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(target));

AddStep("reset filter text", () => songSelect!.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = string.Empty);
AddStep("reset filter text", () => songSelect!.FilterControl.ChildrenOfType<FilterControl.FilterControlTextBox>().First().Text = string.Empty);

AddAssert("game still correct", () => Beatmap.Value?.BeatmapInfo.MatchesOnlineID(target) == true);
AddAssert("carousel still correct", () => songSelect!.Carousel.SelectedBeatmapInfo.MatchesOnlineID(target));
Expand All @@ -666,7 +665,7 @@ public void TestExternalBeatmapChangeWhileFilteredThenRefilter()

AddUntilStep("has selection", () => songSelect!.Carousel.SelectedBeatmapInfo != null);

AddStep("set filter text", () => songSelect!.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono");
AddStep("set filter text", () => songSelect!.FilterControl.ChildrenOfType<FilterControl.FilterControlTextBox>().First().Text = "nonono");

AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap);

Expand All @@ -689,7 +688,7 @@ public void TestExternalBeatmapChangeWhileFilteredThenRefilter()
AddUntilStep("carousel has correct", () => songSelect!.Carousel.SelectedBeatmapInfo?.MatchesOnlineID(target) == true);
AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(target));

AddStep("set filter text", () => songSelect!.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nononoo");
AddStep("set filter text", () => songSelect!.FilterControl.ChildrenOfType<FilterControl.FilterControlTextBox>().First().Text = "nononoo");

AddUntilStep("game lost selection", () => Beatmap.Value is DummyWorkingBeatmap);
AddAssert("carousel lost selection", () => songSelect!.Carousel.SelectedBeatmapInfo == null);
Expand Down

0 comments on commit c2d3dcd

Please sign in to comment.