mirror of
https://github.com/ppy/osu.git
synced 2026-05-30 11:30:36 +08:00
Merge branch 'master' into add-rank-display
This commit is contained in:
@@ -181,6 +181,54 @@ namespace osu.Game.Tests.Visual.Background
|
||||
AddStep("restore default beatmap", () => Beatmap.SetDefault());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBeatmapBackgroundWithStoryboardUnloadedOnSuspension()
|
||||
{
|
||||
BackgroundScreenBeatmap nestedScreen = null;
|
||||
|
||||
setSupporter(true);
|
||||
setSourceMode(BackgroundSource.BeatmapWithStoryboard);
|
||||
|
||||
AddStep("change beatmap", () => Beatmap.Value = createTestWorkingBeatmapWithStoryboard());
|
||||
AddAssert("background changed", () => screen.CheckLastLoadChange() == true);
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => getCurrentBackground()?.GetType() == typeof(BeatmapBackgroundWithStoryboard));
|
||||
|
||||
AddUntilStep("storyboard present", () => screen.ChildrenOfType<DrawableStoryboard>().SingleOrDefault()?.IsLoaded == true);
|
||||
|
||||
AddStep("push new background to stack", () => stack.Push(nestedScreen = new BackgroundScreenBeatmap(Beatmap.Value)));
|
||||
AddUntilStep("wait for screen to load", () => nestedScreen.IsLoaded && nestedScreen.IsCurrentScreen());
|
||||
|
||||
AddUntilStep("storyboard unloaded", () => !screen.ChildrenOfType<DrawableStoryboard>().Any());
|
||||
|
||||
AddStep("go back", () => screen.MakeCurrent());
|
||||
|
||||
AddUntilStep("storyboard reloaded", () => screen.ChildrenOfType<DrawableStoryboard>().SingleOrDefault()?.IsLoaded == true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBeatmapBackgroundWithStoryboardButBeatmapHasNone()
|
||||
{
|
||||
BackgroundScreenBeatmap nestedScreen = null;
|
||||
|
||||
setSupporter(true);
|
||||
setSourceMode(BackgroundSource.BeatmapWithStoryboard);
|
||||
|
||||
AddStep("change beatmap", () => Beatmap.Value = createTestWorkingBeatmapWithUniqueBackground());
|
||||
AddAssert("background changed", () => screen.CheckLastLoadChange() == true);
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => getCurrentBackground()?.GetType() == typeof(BeatmapBackgroundWithStoryboard));
|
||||
|
||||
AddUntilStep("no storyboard loaded", () => !screen.ChildrenOfType<DrawableStoryboard>().Any());
|
||||
|
||||
AddStep("push new background to stack", () => stack.Push(nestedScreen = new BackgroundScreenBeatmap(Beatmap.Value)));
|
||||
AddUntilStep("wait for screen to load", () => nestedScreen.IsLoaded && nestedScreen.IsCurrentScreen());
|
||||
|
||||
AddUntilStep("still no storyboard", () => !screen.ChildrenOfType<DrawableStoryboard>().Any());
|
||||
|
||||
AddStep("go back", () => screen.MakeCurrent());
|
||||
|
||||
AddUntilStep("still no storyboard", () => !screen.ChildrenOfType<DrawableStoryboard>().Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBackgroundTypeSwitch()
|
||||
{
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace osu.Game.Tests.Visual.Background
|
||||
ColourDark = Color4.Gray,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(0.9f)
|
||||
Size = new Vector2(0.9f),
|
||||
ClampAxes = Axes.None
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -40,7 +41,10 @@ namespace osu.Game.Tests.Visual.Background
|
||||
|
||||
AddSliderStep("Triangle scale", 0f, 10f, 1f, s => triangles.TriangleScale = s);
|
||||
AddSliderStep("Seed", 0, 1000, 0, s => triangles.Reset(s));
|
||||
AddToggleStep("Masking", m => triangles.Masking = m);
|
||||
AddStep("ClampAxes X", () => triangles.ClampAxes = Axes.X);
|
||||
AddStep("ClampAxes Y", () => triangles.ClampAxes = Axes.Y);
|
||||
AddStep("ClampAxes Both", () => triangles.ClampAxes = Axes.Both);
|
||||
AddStep("ClampAxes None", () => triangles.ClampAxes = Axes.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,8 @@ namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ClampAxes = Axes.None
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -128,7 +129,10 @@ namespace osu.Game.Tests.Visual.Background
|
||||
AddStep("White colour", () => box.Colour = triangles.Colour = maskedTriangles.Colour = Color4.White);
|
||||
AddStep("Vertical gradient", () => box.Colour = triangles.Colour = maskedTriangles.Colour = ColourInfo.GradientVertical(Color4.White, Color4.Red));
|
||||
AddStep("Horizontal gradient", () => box.Colour = triangles.Colour = maskedTriangles.Colour = ColourInfo.GradientHorizontal(Color4.White, Color4.Red));
|
||||
AddToggleStep("Masking", m => maskedTriangles.Masking = m);
|
||||
AddStep("ClampAxes X", () => maskedTriangles.ClampAxes = Axes.X);
|
||||
AddStep("ClampAxes Y", () => maskedTriangles.ClampAxes = Axes.Y);
|
||||
AddStep("ClampAxes Both", () => maskedTriangles.ClampAxes = Axes.Both);
|
||||
AddStep("ClampAxes None", () => maskedTriangles.ClampAxes = Axes.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,13 +89,18 @@ namespace osu.Game.Tests.Visual.Background
|
||||
setupUserSettings();
|
||||
AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new LoadBlockingTestPlayer { BlockLoad = true })));
|
||||
AddUntilStep("Wait for Player Loader to load", () => playerLoader?.IsLoaded ?? false);
|
||||
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
||||
AddStep("Trigger background preview", () =>
|
||||
AddAssert("Background retained from song select", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(playerLoader.ScreenPos);
|
||||
InputManager.MoveMouseTo(playerLoader.VisualSettingsPos);
|
||||
InputManager.MoveMouseTo(playerLoader);
|
||||
return songSelect.IsBackgroundCurrent();
|
||||
});
|
||||
AddUntilStep("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
|
||||
AddUntilStep("Screen is dimmed and blur applied", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(playerLoader.VisualSettingsPos);
|
||||
return songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied();
|
||||
});
|
||||
|
||||
AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||
AddUntilStep("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.CheckBackgroundBlur(playerLoader.ExpectedBackgroundBlur));
|
||||
}
|
||||
@@ -349,8 +354,9 @@ namespace osu.Game.Tests.Visual.Background
|
||||
private partial class FadeAccessibleResults : ResultsScreen
|
||||
{
|
||||
public FadeAccessibleResults(ScoreInfo score)
|
||||
: base(score, true)
|
||||
: base(score)
|
||||
{
|
||||
AllowRetry = true;
|
||||
}
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||
|
||||
@@ -260,6 +260,12 @@ namespace osu.Game.Tests.Visual.Beatmaps
|
||||
AddStep($"set {scheme} scheme", () => Child = createContent(scheme, creationFunc));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNano()
|
||||
{
|
||||
createTestCase(beatmapSetInfo => new BeatmapCardNano(beatmapSetInfo));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNormal()
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
|
||||
var beatmapSet = CreateAPIBeatmapSet(Ruleset.Value);
|
||||
beatmapSet.OnlineID = 241526; // ID hardcoded to ensure that the preview track exists online.
|
||||
|
||||
Child = thumbnail = new BeatmapCardThumbnail(beatmapSet)
|
||||
Child = thumbnail = new BeatmapCardThumbnail(beatmapSet, beatmapSet)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
||||
@@ -47,7 +47,35 @@ namespace osu.Game.Tests.Visual.Beatmaps
|
||||
pill.AutoSizeAxes = Axes.Y;
|
||||
pill.Width = 90;
|
||||
}));
|
||||
|
||||
AddStep("unset fixed width", () => statusPills.ForEach(pill => pill.AutoSizeAxes = Axes.Both));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChangeLabels()
|
||||
{
|
||||
AddStep("Change labels", () =>
|
||||
{
|
||||
foreach (var pill in this.ChildrenOfType<BeatmapSetOnlineStatusPill>())
|
||||
{
|
||||
switch (pill.Status)
|
||||
{
|
||||
// cycle at end
|
||||
case BeatmapOnlineStatus.Loved:
|
||||
pill.Status = BeatmapOnlineStatus.LocallyModified;
|
||||
break;
|
||||
|
||||
// skip none
|
||||
case BeatmapOnlineStatus.LocallyModified:
|
||||
pill.Status = BeatmapOnlineStatus.Graveyard;
|
||||
break;
|
||||
|
||||
default:
|
||||
pill.Status = (pill.Status + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Beatmaps
|
||||
{
|
||||
public partial class TestSceneDifficultyIcon : OsuTestScene
|
||||
{
|
||||
private FillFlowContainer<DifficultyIcon> fill = null!;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Child = fill = new FillFlowContainer<DifficultyIcon>
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Width = 300,
|
||||
Direction = FillDirection.Full,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateDifficultyIcon()
|
||||
{
|
||||
AddRepeatStep("create difficulty icon", () =>
|
||||
{
|
||||
var rulesetInfo = new OsuRuleset().RulesetInfo;
|
||||
var beatmapInfo = new TestBeatmap(rulesetInfo).BeatmapInfo;
|
||||
|
||||
beatmapInfo.Difficulty.ApproachRate = RNG.Next(0, 10);
|
||||
beatmapInfo.Difficulty.CircleSize = RNG.Next(0, 10);
|
||||
beatmapInfo.Difficulty.OverallDifficulty = RNG.Next(0, 10);
|
||||
beatmapInfo.Difficulty.DrainRate = RNG.Next(0, 10);
|
||||
beatmapInfo.StarRating = RNG.NextSingle(0, 10);
|
||||
beatmapInfo.BPM = RNG.Next(60, 300);
|
||||
|
||||
fill.Add(new DifficultyIcon(beatmapInfo, rulesetInfo)
|
||||
{
|
||||
Scale = new Vector2(2),
|
||||
});
|
||||
}, 10);
|
||||
|
||||
AddStep("no tooltip", () => fill.ForEach(icon => icon.TooltipType = DifficultyIconTooltipType.None));
|
||||
AddStep("basic tooltip", () => fill.ForEach(icon => icon.TooltipType = DifficultyIconTooltipType.StarRating));
|
||||
AddStep("extended tooltip", () => fill.ForEach(icon => icon.TooltipType = DifficultyIconTooltipType.Extended));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,6 +166,29 @@ namespace osu.Game.Tests.Visual.Collections
|
||||
})));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCollectionNameCollisionsWithBuiltInItems()
|
||||
{
|
||||
AddStep("add dropdown", () =>
|
||||
{
|
||||
Add(new CollectionDropdown
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.4f,
|
||||
});
|
||||
});
|
||||
AddStep("add two collections which collide with default items", () => Realm.Write(r => r.Add(new[]
|
||||
{
|
||||
new BeatmapCollection(name: "All beatmaps"),
|
||||
new BeatmapCollection(name: "Manage collections...")
|
||||
{
|
||||
BeatmapMD5Hashes = { beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps[0].MD5Hash }
|
||||
},
|
||||
})));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemoveCollectionViaButton()
|
||||
{
|
||||
|
||||
@@ -210,6 +210,13 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
switchPresets(-1);
|
||||
assertPreset(BeatDivisorType.Custom, 15);
|
||||
assertBeatSnap(15);
|
||||
|
||||
setDivisorViaInput(24);
|
||||
assertPreset(BeatDivisorType.Custom, 24);
|
||||
switchPresets(1);
|
||||
assertPreset(BeatDivisorType.Common);
|
||||
switchPresets(-2);
|
||||
assertPreset(BeatDivisorType.Triplets);
|
||||
}
|
||||
|
||||
private void switchBeatSnap(int direction) => AddRepeatStep($"move snap {(direction > 0 ? "forward" : "backward")}", () =>
|
||||
|
||||
@@ -10,9 +10,11 @@ using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
@@ -26,9 +28,13 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
[Cached(typeof(SelectionRotationHandler))]
|
||||
private TestSelectionRotationHandler rotationHandler;
|
||||
|
||||
[Cached(typeof(SelectionScaleHandler))]
|
||||
private TestSelectionScaleHandler scaleHandler;
|
||||
|
||||
public TestSceneComposeSelectBox()
|
||||
{
|
||||
rotationHandler = new TestSelectionRotationHandler(() => selectionArea);
|
||||
scaleHandler = new TestSelectionScaleHandler(() => selectionArea);
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
@@ -45,12 +51,8 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
|
||||
CanScaleX = true,
|
||||
CanScaleY = true,
|
||||
CanFlipX = true,
|
||||
CanFlipY = true,
|
||||
|
||||
OnScale = handleScale
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -59,27 +61,6 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
InputManager.ReleaseButton(MouseButton.Left);
|
||||
});
|
||||
|
||||
private bool handleScale(Vector2 amount, Anchor reference)
|
||||
{
|
||||
if ((reference & Anchor.y1) == 0)
|
||||
{
|
||||
int directionY = (reference & Anchor.y0) > 0 ? -1 : 1;
|
||||
if (directionY < 0)
|
||||
selectionArea.Y += amount.Y;
|
||||
selectionArea.Height += directionY * amount.Y;
|
||||
}
|
||||
|
||||
if ((reference & Anchor.x1) == 0)
|
||||
{
|
||||
int directionX = (reference & Anchor.x0) > 0 ? -1 : 1;
|
||||
if (directionX < 0)
|
||||
selectionArea.X += amount.X;
|
||||
selectionArea.Width += directionX * amount.X;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private partial class TestSelectionRotationHandler : SelectionRotationHandler
|
||||
{
|
||||
private readonly Func<Container> getTargetContainer;
|
||||
@@ -88,7 +69,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
this.getTargetContainer = getTargetContainer;
|
||||
|
||||
CanRotate.Value = true;
|
||||
CanRotateAroundSelectionOrigin.Value = true;
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
@@ -124,6 +105,51 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
}
|
||||
}
|
||||
|
||||
private partial class TestSelectionScaleHandler : SelectionScaleHandler
|
||||
{
|
||||
private readonly Func<Container> getTargetContainer;
|
||||
|
||||
public TestSelectionScaleHandler(Func<Container> getTargetContainer)
|
||||
{
|
||||
this.getTargetContainer = getTargetContainer;
|
||||
|
||||
CanScaleX.Value = true;
|
||||
CanScaleY.Value = true;
|
||||
CanScaleDiagonally.Value = true;
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
private Container targetContainer;
|
||||
|
||||
public override void Begin()
|
||||
{
|
||||
if (targetContainer != null)
|
||||
throw new InvalidOperationException($"Cannot {nameof(Begin)} a scale operation while another is in progress!");
|
||||
|
||||
targetContainer = getTargetContainer();
|
||||
OriginalSurroundingQuad = new Quad(targetContainer!.X, targetContainer.Y, targetContainer.Width, targetContainer.Height);
|
||||
}
|
||||
|
||||
public override void Update(Vector2 scale, Vector2? origin = null, Axes adjustAxis = Axes.Both)
|
||||
{
|
||||
if (targetContainer == null)
|
||||
throw new InvalidOperationException($"Cannot {nameof(Update)} a scale operation without calling {nameof(Begin)} first!");
|
||||
|
||||
Vector2 actualOrigin = origin ?? Vector2.Zero;
|
||||
|
||||
targetContainer.Position = GeometryUtils.GetScaledPosition(scale, actualOrigin, OriginalSurroundingQuad!.Value.TopLeft);
|
||||
targetContainer.Size = OriginalSurroundingQuad!.Value.Size * scale;
|
||||
}
|
||||
|
||||
public override void Commit()
|
||||
{
|
||||
if (targetContainer == null)
|
||||
throw new InvalidOperationException($"Cannot {nameof(Commit)} a scale operation without calling {nameof(Begin)} first!");
|
||||
|
||||
targetContainer = null;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRotationHandleShownOnHover()
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
using osuTK.Input;
|
||||
@@ -83,6 +84,49 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeleteDifficultyWithPendingChanges()
|
||||
{
|
||||
Guid deletedDifficultyID = Guid.Empty;
|
||||
int countBeforeDeletion = 0;
|
||||
string beatmapSetHashBefore = string.Empty;
|
||||
|
||||
AddUntilStep("wait for editor to load", () => Editor?.ReadyForUse == true);
|
||||
|
||||
AddStep("store selected difficulty", () =>
|
||||
{
|
||||
deletedDifficultyID = EditorBeatmap.BeatmapInfo.ID;
|
||||
countBeforeDeletion = Beatmap.Value.BeatmapSetInfo.Beatmaps.Count;
|
||||
beatmapSetHashBefore = Beatmap.Value.BeatmapSetInfo.Hash;
|
||||
});
|
||||
|
||||
AddStep("make change to difficulty", () =>
|
||||
{
|
||||
EditorBeatmap.BeginChange();
|
||||
EditorBeatmap.BeatmapInfo.DifficultyName = "changin' things";
|
||||
EditorBeatmap.EndChange();
|
||||
});
|
||||
|
||||
AddStep("click File", () => this.ChildrenOfType<DrawableOsuMenuItem>().First().TriggerClick());
|
||||
|
||||
AddStep("click delete", () => getDeleteMenuItem().TriggerClick());
|
||||
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog != null);
|
||||
AddAssert("dialog is deletion confirmation dialog", () => DialogOverlay.CurrentDialog, Is.InstanceOf<DeleteDifficultyConfirmationDialog>);
|
||||
AddStep("confirm", () => InputManager.Key(Key.Number1));
|
||||
|
||||
AddUntilStep("no next dialog", () => DialogOverlay.CurrentDialog == null);
|
||||
AddUntilStep("switched to different difficulty",
|
||||
() => this.ChildrenOfType<EditorBeatmap>().SingleOrDefault() != null && EditorBeatmap.BeatmapInfo.ID != deletedDifficultyID);
|
||||
|
||||
AddAssert("difficulty is unattached from set",
|
||||
() => Beatmap.Value.BeatmapSetInfo.Beatmaps.Select(b => b.ID), () => Does.Not.Contain(deletedDifficultyID));
|
||||
AddAssert("beatmap set difficulty count decreased by one",
|
||||
() => Beatmap.Value.BeatmapSetInfo.Beatmaps.Count, () => Is.EqualTo(countBeforeDeletion - 1));
|
||||
AddAssert("set hash changed", () => Beatmap.Value.BeatmapSetInfo.Hash, () => Is.Not.EqualTo(beatmapSetHashBefore));
|
||||
AddAssert("difficulty is deleted from realm",
|
||||
() => Realm.Run(r => r.Find<BeatmapInfo>(deletedDifficultyID)), () => Is.Null);
|
||||
}
|
||||
|
||||
private DrawableOsuMenuItem getDeleteMenuItem() => this.ChildrenOfType<DrawableOsuMenuItem>()
|
||||
.Single(item => item.ChildrenOfType<SpriteText>().Any(text => text.Text.ToString().StartsWith("Delete", StringComparison.Ordinal)));
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
if (sameRuleset)
|
||||
{
|
||||
AddUntilStep("prompt for save dialog shown", () => DialogOverlay.CurrentDialog is PromptForSaveDialog);
|
||||
AddStep("discard changes", () => ((PromptForSaveDialog)DialogOverlay.CurrentDialog).PerformOkAction());
|
||||
AddStep("discard changes", () => ((PromptForSaveDialog)DialogOverlay.CurrentDialog)?.PerformOkAction());
|
||||
}
|
||||
|
||||
// ensure editor loader didn't resume.
|
||||
|
||||
@@ -187,11 +187,9 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
private class SnapProvider : IDistanceSnapProvider
|
||||
{
|
||||
public SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition, SnapType snapType = SnapType.AllGrids) => new SnapResult(screenSpacePosition, 0);
|
||||
|
||||
public Bindable<double> DistanceSpacingMultiplier { get; } = new BindableDouble(1);
|
||||
|
||||
IBindable<double> IDistanceSnapProvider.DistanceSpacingMultiplier => DistanceSpacingMultiplier;
|
||||
Bindable<double> IDistanceSnapProvider.DistanceSpacingMultiplier => DistanceSpacingMultiplier;
|
||||
|
||||
public float GetBeatSnapDistanceAt(HitObject referenceObject, bool useReferenceSliderVelocity = true) => beat_snap_distance;
|
||||
|
||||
|
||||
@@ -18,12 +18,14 @@ using osu.Game.Database;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osu.Game.Screens.Edit.Setup;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Resources;
|
||||
@@ -91,29 +93,13 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
}
|
||||
|
||||
[Test]
|
||||
[FlakyTest]
|
||||
/*
|
||||
* Fail rate around 1.2%.
|
||||
*
|
||||
* Failing with realm refetch occasionally being null.
|
||||
* My only guess is that the WorkingBeatmap at SetupScreen is dummy instead of the true one.
|
||||
* If it's something else, we have larger issues with realm, but I don't think that's the case.
|
||||
*
|
||||
* at osu.Framework.Logging.ThrowingTraceListener.Fail(String message1, String message2)
|
||||
* at System.Diagnostics.TraceInternal.Fail(String message, String detailMessage)
|
||||
* at System.Diagnostics.TraceInternal.TraceProvider.Fail(String message, String detailMessage)
|
||||
* at System.Diagnostics.Debug.Fail(String message, String detailMessage)
|
||||
* at osu.Game.Database.ModelManager`1.<>c__DisplayClass8_0.<performFileOperation>b__0(Realm realm) ModelManager.cs:line 50
|
||||
* at osu.Game.Database.RealmExtensions.Write(Realm realm, Action`1 function) RealmExtensions.cs:line 14
|
||||
* at osu.Game.Database.ModelManager`1.performFileOperation(TModel item, Action`1 operation) ModelManager.cs:line 47
|
||||
* at osu.Game.Database.ModelManager`1.AddFile(TModel item, Stream contents, String filename) ModelManager.cs:line 37
|
||||
* at osu.Game.Screens.Edit.Setup.ResourcesSection.ChangeAudioTrack(FileInfo source) ResourcesSection.cs:line 115
|
||||
* at osu.Game.Tests.Visual.Editing.TestSceneEditorBeatmapCreation.<TestAddAudioTrack>b__11_0() TestSceneEditorBeatmapCreation.cs:line 101
|
||||
*/
|
||||
public void TestAddAudioTrack()
|
||||
{
|
||||
AddAssert("track is virtual", () => Beatmap.Value.Track is TrackVirtual);
|
||||
AddStep("enter compose mode", () => InputManager.Key(Key.F1));
|
||||
AddUntilStep("wait for timeline load", () => Editor.ChildrenOfType<Timeline>().FirstOrDefault()?.IsLoaded == true);
|
||||
|
||||
AddStep("enter setup mode", () => InputManager.Key(Key.F4));
|
||||
AddAssert("track is virtual", () => Beatmap.Value.Track is TrackVirtual);
|
||||
AddAssert("switch track to real track", () =>
|
||||
{
|
||||
var setup = Editor.ChildrenOfType<SetupScreen>().First();
|
||||
@@ -143,7 +129,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
});
|
||||
|
||||
AddAssert("track is not virtual", () => Beatmap.Value.Track is not TrackVirtual);
|
||||
AddAssert("track length changed", () => Beatmap.Value.Track.Length > 60000);
|
||||
AddUntilStep("track length changed", () => Beatmap.Value.Track.Length > 60000);
|
||||
|
||||
AddStep("test play", () => Editor.TestGameplay());
|
||||
|
||||
@@ -200,7 +186,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
if (sameRuleset)
|
||||
{
|
||||
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
|
||||
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog.PerformOkAction());
|
||||
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction());
|
||||
}
|
||||
|
||||
AddUntilStep("wait for created", () =>
|
||||
@@ -287,7 +273,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));
|
||||
|
||||
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
|
||||
AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog.Buttons.ElementAt(1).TriggerClick());
|
||||
AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog!.Buttons.ElementAt(1).TriggerClick());
|
||||
|
||||
AddUntilStep("wait for created", () =>
|
||||
{
|
||||
@@ -360,7 +346,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));
|
||||
|
||||
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
|
||||
AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog.Buttons.ElementAt(1).TriggerClick());
|
||||
AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog!.Buttons.ElementAt(1).TriggerClick());
|
||||
|
||||
AddUntilStep("wait for created", () =>
|
||||
{
|
||||
@@ -398,7 +384,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
AddStep("try to create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));
|
||||
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
|
||||
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog.PerformOkAction());
|
||||
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction());
|
||||
|
||||
AddUntilStep("wait for created", () =>
|
||||
{
|
||||
@@ -433,7 +419,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
if (sameRuleset)
|
||||
{
|
||||
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
|
||||
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog.PerformOkAction());
|
||||
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction());
|
||||
}
|
||||
|
||||
AddUntilStep("wait for created", () =>
|
||||
@@ -453,6 +439,51 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExitBlockedWhenSavingBeatmapWithSameNamedDifficulties()
|
||||
{
|
||||
Guid setId = Guid.Empty;
|
||||
const string duplicate_difficulty_name = "duplicate";
|
||||
|
||||
AddStep("retrieve set ID", () => setId = EditorBeatmap.BeatmapInfo.BeatmapSet!.ID);
|
||||
AddStep("set difficulty name", () => EditorBeatmap.BeatmapInfo.DifficultyName = duplicate_difficulty_name);
|
||||
AddStep("save beatmap", () => Editor.Save());
|
||||
AddAssert("new beatmap persisted", () =>
|
||||
{
|
||||
var set = beatmapManager.QueryBeatmapSet(s => s.ID == setId);
|
||||
return set != null && set.PerformRead(s => s.Beatmaps.Count == 1 && s.Files.Count == 1);
|
||||
});
|
||||
|
||||
AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new CatchRuleset().RulesetInfo));
|
||||
|
||||
AddUntilStep("wait for created", () =>
|
||||
{
|
||||
string? difficultyName = Editor.ChildrenOfType<EditorBeatmap>().SingleOrDefault()?.BeatmapInfo.DifficultyName;
|
||||
return difficultyName != null && difficultyName != duplicate_difficulty_name;
|
||||
});
|
||||
AddUntilStep("wait for editor load", () => Editor.IsLoaded && DialogOverlay.IsLoaded);
|
||||
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(new[]
|
||||
{
|
||||
new Fruit
|
||||
{
|
||||
StartTime = 0
|
||||
},
|
||||
new Fruit
|
||||
{
|
||||
StartTime = 1000
|
||||
}
|
||||
}));
|
||||
|
||||
AddStep("set difficulty name", () => EditorBeatmap.BeatmapInfo.DifficultyName = duplicate_difficulty_name);
|
||||
AddUntilStep("wait for has unsaved changes", () => Editor.HasUnsavedChanges);
|
||||
|
||||
AddStep("exit", () => Editor.Exit());
|
||||
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is PromptForSaveDialog);
|
||||
AddStep("attempt to save", () => DialogOverlay.CurrentDialog!.PerformOkAction());
|
||||
AddAssert("editor is still current", () => Editor.IsCurrentScreen());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateNewDifficultyForInconvertibleRuleset()
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
ControlPoints =
|
||||
{
|
||||
new PathControlPoint(),
|
||||
new PathControlPoint(new Vector2(100, 0), PathType.Bezier)
|
||||
new PathControlPoint(new Vector2(100, 0), PathType.BEZIER)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("seek near end", () => EditorClock.Seek(EditorClock.TrackLength - 250));
|
||||
AddUntilStep("clock stops", () => !EditorClock.IsRunning);
|
||||
|
||||
AddUntilStep("clock stopped at end", () => EditorClock.CurrentTime - EditorClock.TotalAppliedOffset, () => Is.EqualTo(EditorClock.TrackLength));
|
||||
AddUntilStep("clock stopped at end", () => EditorClock.CurrentTime, () => Is.EqualTo(EditorClock.TrackLength));
|
||||
|
||||
AddStep("start clock again", () => EditorClock.Start());
|
||||
AddAssert("clock looped to start", () => EditorClock.IsRunning && EditorClock.CurrentTime < 500);
|
||||
|
||||
@@ -34,51 +34,51 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
new MenuItem("File")
|
||||
{
|
||||
Items = new[]
|
||||
Items = new OsuMenuItem[]
|
||||
{
|
||||
new EditorMenuItem("Clear All Notes"),
|
||||
new EditorMenuItem("Open Difficulty..."),
|
||||
new EditorMenuItem("Save"),
|
||||
new EditorMenuItem("Create a new Difficulty..."),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Revert to Saved"),
|
||||
new EditorMenuItem("Revert to Saved (Full)"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Test Beatmap"),
|
||||
new EditorMenuItem("Open AiMod"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Upload Beatmap..."),
|
||||
new EditorMenuItem("Export Package"),
|
||||
new EditorMenuItem("Export Map Package"),
|
||||
new EditorMenuItem("Import from..."),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Open Song Folder"),
|
||||
new EditorMenuItem("Open .osu in Notepad"),
|
||||
new EditorMenuItem("Open .osb in Notepad"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Exit"),
|
||||
}
|
||||
},
|
||||
new MenuItem("Timing")
|
||||
{
|
||||
Items = new[]
|
||||
Items = new OsuMenuItem[]
|
||||
{
|
||||
new EditorMenuItem("Time Signature"),
|
||||
new EditorMenuItem("Metronome Clicks"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Add Timing Section"),
|
||||
new EditorMenuItem("Add Inheriting Section"),
|
||||
new EditorMenuItem("Reset Current Section"),
|
||||
new EditorMenuItem("Delete Timing Section"),
|
||||
new EditorMenuItem("Resnap Current Section"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Timing Setup"),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Resnap All Notes", MenuItemType.Destructive),
|
||||
new EditorMenuItem("Move all notes in time...", MenuItemType.Destructive),
|
||||
new EditorMenuItem("Recalculate Slider Lengths", MenuItemType.Destructive),
|
||||
new EditorMenuItem("Delete All Timing Sections", MenuItemType.Destructive),
|
||||
new EditorMenuItemSpacer(),
|
||||
new OsuMenuItemSpacer(),
|
||||
new EditorMenuItem("Set Current Position as Preview Point"),
|
||||
}
|
||||
},
|
||||
|
||||
@@ -138,11 +138,11 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
InputManager.MoveMouseTo(button);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveBeforeGameplayTestDialog);
|
||||
AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveRequiredPopupDialog);
|
||||
|
||||
AddStep("dismiss prompt", () =>
|
||||
{
|
||||
var button = DialogOverlay.CurrentDialog.Buttons.Last();
|
||||
var button = DialogOverlay.CurrentDialog!.Buttons.Last();
|
||||
InputManager.MoveMouseTo(button);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
@@ -165,9 +165,9 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
InputManager.MoveMouseTo(button);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveBeforeGameplayTestDialog);
|
||||
AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveRequiredPopupDialog);
|
||||
|
||||
AddStep("save changes", () => DialogOverlay.CurrentDialog.PerformOkAction());
|
||||
AddStep("save changes", () => DialogOverlay.CurrentDialog!.PerformOkAction());
|
||||
|
||||
EditorPlayer editorPlayer = null;
|
||||
AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null);
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
new Slider
|
||||
{
|
||||
Position = new Vector2(128, 256),
|
||||
Path = new SliderPath(PathType.Linear, new[]
|
||||
Path = new SliderPath(PathType.LINEAR, new[]
|
||||
{
|
||||
Vector2.Zero,
|
||||
new Vector2(216, 0),
|
||||
@@ -178,7 +178,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("distance spacing increased by 0.5", () => editorBeatmap.BeatmapInfo.DistanceSpacing == originalSpacing + 0.5);
|
||||
}
|
||||
|
||||
public partial class EditorBeatmapContainer : Container
|
||||
public partial class EditorBeatmapContainer : PopoverContainer
|
||||
{
|
||||
private readonly IWorkingBeatmap working;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
new PathControlPoint(new Vector2(100, 0))
|
||||
}
|
||||
},
|
||||
SliderVelocity = 2
|
||||
SliderVelocityMultiplier = 2
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -110,7 +110,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("unify slider velocity", () =>
|
||||
{
|
||||
foreach (var h in EditorBeatmap.HitObjects.OfType<IHasSliderVelocity>())
|
||||
h.SliderVelocity = 1.5;
|
||||
h.SliderVelocityMultiplier = 1.5;
|
||||
});
|
||||
|
||||
AddStep("select both objects", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
|
||||
@@ -194,7 +194,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
private void hitObjectHasVelocity(int objectIndex, double velocity) => AddAssert($"{objectIndex.ToOrdinalWords()} has velocity {velocity}", () =>
|
||||
{
|
||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex);
|
||||
return h is IHasSliderVelocity hasSliderVelocity && hasSliderVelocity.SliderVelocity == velocity;
|
||||
return h is IHasSliderVelocity hasSliderVelocity && hasSliderVelocity.SliderVelocityMultiplier == velocity;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Humanizer;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
@@ -396,7 +397,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
textBox.Current.Value = bank;
|
||||
// force a commit via keyboard.
|
||||
// this is needed when testing attempting to set empty bank - which should revert to the previous value, but only on commit.
|
||||
InputManager.ChangeFocus(textBox);
|
||||
((IFocusManager)InputManager).ChangeFocus(textBox);
|
||||
InputManager.Key(Key.Enter);
|
||||
});
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@@ -62,12 +63,12 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
createLabelledTimeSignature(TimeSignature.SimpleQuadruple);
|
||||
AddAssert("current is 4/4", () => timeSignature.Current.Value.Equals(TimeSignature.SimpleQuadruple));
|
||||
|
||||
AddStep("focus text box", () => InputManager.ChangeFocus(numeratorTextBox));
|
||||
AddStep("focus text box", () => ((IFocusManager)InputManager).ChangeFocus(numeratorTextBox));
|
||||
|
||||
AddStep("set numerator to 7", () => numeratorTextBox.Current.Value = "7");
|
||||
AddAssert("current is 4/4", () => timeSignature.Current.Value.Equals(TimeSignature.SimpleQuadruple));
|
||||
|
||||
AddStep("drop focus", () => InputManager.ChangeFocus(null));
|
||||
AddStep("drop focus", () => ((IFocusManager)InputManager).ChangeFocus(null));
|
||||
AddAssert("current is 7/4", () => timeSignature.Current.Value.Equals(new TimeSignature(7)));
|
||||
}
|
||||
|
||||
@@ -77,12 +78,12 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
createLabelledTimeSignature(TimeSignature.SimpleQuadruple);
|
||||
AddAssert("current is 4/4", () => timeSignature.Current.Value.Equals(TimeSignature.SimpleQuadruple));
|
||||
|
||||
AddStep("focus text box", () => InputManager.ChangeFocus(numeratorTextBox));
|
||||
AddStep("focus text box", () => ((IFocusManager)InputManager).ChangeFocus(numeratorTextBox));
|
||||
|
||||
AddStep("set numerator to 0", () => numeratorTextBox.Current.Value = "0");
|
||||
AddAssert("current is 4/4", () => timeSignature.Current.Value.Equals(TimeSignature.SimpleQuadruple));
|
||||
|
||||
AddStep("drop focus", () => InputManager.ChangeFocus(null));
|
||||
AddStep("drop focus", () => ((IFocusManager)InputManager).ChangeFocus(null));
|
||||
AddAssert("current is 4/4", () => timeSignature.Current.Value.Equals(TimeSignature.SimpleQuadruple));
|
||||
AddAssert("numerator is 4", () => numeratorTextBox.Current.Value == "4");
|
||||
}
|
||||
|
||||
@@ -3,17 +3,22 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Setup;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
public partial class TestSceneMetadataSection : OsuTestScene
|
||||
public partial class TestSceneMetadataSection : OsuManualInputManagerTestScene
|
||||
{
|
||||
[Cached]
|
||||
private EditorBeatmap editorBeatmap = new EditorBeatmap(new Beatmap
|
||||
@@ -26,6 +31,81 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
private TestMetadataSection metadataSection;
|
||||
|
||||
[Test]
|
||||
public void TestUpdateViaTextBoxOnFocusLoss()
|
||||
{
|
||||
AddStep("set metadata", () =>
|
||||
{
|
||||
editorBeatmap.Metadata.Artist = "Example Artist";
|
||||
editorBeatmap.Metadata.ArtistUnicode = string.Empty;
|
||||
});
|
||||
|
||||
createSection();
|
||||
|
||||
TextBox textbox;
|
||||
|
||||
AddStep("focus first textbox", () =>
|
||||
{
|
||||
textbox = metadataSection.ChildrenOfType<TextBox>().First();
|
||||
InputManager.MoveMouseTo(textbox);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddStep("simulate changing textbox", () =>
|
||||
{
|
||||
// Can't simulate text input but this should work.
|
||||
InputManager.Keys(PlatformAction.SelectAll);
|
||||
InputManager.Keys(PlatformAction.Copy);
|
||||
InputManager.Keys(PlatformAction.Paste);
|
||||
InputManager.Keys(PlatformAction.Paste);
|
||||
});
|
||||
|
||||
assertArtistMetadata("Example Artist");
|
||||
|
||||
// It's important values are committed immediately on focus loss so the editor exit sequence detects them.
|
||||
AddAssert("value immediately changed on focus loss", () =>
|
||||
{
|
||||
((IFocusManager)InputManager).TriggerFocusContention(metadataSection);
|
||||
return editorBeatmap.Metadata.Artist;
|
||||
}, () => Is.EqualTo("Example ArtistExample Artist"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUpdateViaTextBoxOnCommit()
|
||||
{
|
||||
AddStep("set metadata", () =>
|
||||
{
|
||||
editorBeatmap.Metadata.Artist = "Example Artist";
|
||||
editorBeatmap.Metadata.ArtistUnicode = string.Empty;
|
||||
});
|
||||
|
||||
createSection();
|
||||
|
||||
TextBox textbox;
|
||||
|
||||
AddStep("focus first textbox", () =>
|
||||
{
|
||||
textbox = metadataSection.ChildrenOfType<TextBox>().First();
|
||||
InputManager.MoveMouseTo(textbox);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddStep("simulate changing textbox", () =>
|
||||
{
|
||||
// Can't simulate text input but this should work.
|
||||
InputManager.Keys(PlatformAction.SelectAll);
|
||||
InputManager.Keys(PlatformAction.Copy);
|
||||
InputManager.Keys(PlatformAction.Paste);
|
||||
InputManager.Keys(PlatformAction.Paste);
|
||||
});
|
||||
|
||||
assertArtistMetadata("Example Artist");
|
||||
|
||||
AddStep("commit", () => InputManager.Key(Key.Enter));
|
||||
|
||||
assertArtistMetadata("Example ArtistExample Artist");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMinimalMetadata()
|
||||
{
|
||||
@@ -40,7 +120,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
createSection();
|
||||
|
||||
assertArtist("Example Artist");
|
||||
assertArtistTextBox("Example Artist");
|
||||
assertRomanisedArtist("Example Artist", false);
|
||||
|
||||
assertTitle("Example Title");
|
||||
@@ -61,7 +141,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
createSection();
|
||||
|
||||
assertArtist("*なみりん");
|
||||
assertArtistTextBox("*なみりん");
|
||||
assertRomanisedArtist(string.Empty, true);
|
||||
|
||||
assertTitle("コイシテイク・プラネット");
|
||||
@@ -82,7 +162,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
createSection();
|
||||
|
||||
assertArtist("*なみりん");
|
||||
assertArtistTextBox("*なみりん");
|
||||
assertRomanisedArtist("*namirin", true);
|
||||
|
||||
assertTitle("コイシテイク・プラネット");
|
||||
@@ -104,11 +184,11 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
createSection();
|
||||
|
||||
AddStep("set romanised artist name", () => metadataSection.ArtistTextBox.Current.Value = "*namirin");
|
||||
assertArtist("*namirin");
|
||||
assertArtistTextBox("*namirin");
|
||||
assertRomanisedArtist("*namirin", false);
|
||||
|
||||
AddStep("set native artist name", () => metadataSection.ArtistTextBox.Current.Value = "*なみりん");
|
||||
assertArtist("*なみりん");
|
||||
assertArtistTextBox("*なみりん");
|
||||
assertRomanisedArtist("*namirin", true);
|
||||
|
||||
AddStep("set romanised title", () => metadataSection.TitleTextBox.Current.Value = "Hitokoto no kyori");
|
||||
@@ -123,21 +203,24 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
private void createSection()
|
||||
=> AddStep("create metadata section", () => Child = metadataSection = new TestMetadataSection());
|
||||
|
||||
private void assertArtist(string expected)
|
||||
=> AddAssert($"artist is {expected}", () => metadataSection.ArtistTextBox.Current.Value == expected);
|
||||
private void assertArtistMetadata(string expected)
|
||||
=> AddAssert($"artist metadata is {expected}", () => editorBeatmap.Metadata.Artist, () => Is.EqualTo(expected));
|
||||
|
||||
private void assertArtistTextBox(string expected)
|
||||
=> AddAssert($"artist textbox is {expected}", () => metadataSection.ArtistTextBox.Current.Value, () => Is.EqualTo(expected));
|
||||
|
||||
private void assertRomanisedArtist(string expected, bool editable)
|
||||
{
|
||||
AddAssert($"romanised artist is {expected}", () => metadataSection.RomanisedArtistTextBox.Current.Value == expected);
|
||||
AddAssert($"romanised artist is {expected}", () => metadataSection.RomanisedArtistTextBox.Current.Value, () => Is.EqualTo(expected));
|
||||
AddAssert($"romanised artist is {(editable ? "" : "not ")}editable", () => metadataSection.RomanisedArtistTextBox.ReadOnly == !editable);
|
||||
}
|
||||
|
||||
private void assertTitle(string expected)
|
||||
=> AddAssert($"title is {expected}", () => metadataSection.TitleTextBox.Current.Value == expected);
|
||||
=> AddAssert($"title is {expected}", () => metadataSection.TitleTextBox.Current.Value, () => Is.EqualTo(expected));
|
||||
|
||||
private void assertRomanisedTitle(string expected, bool editable)
|
||||
{
|
||||
AddAssert($"romanised title is {expected}", () => metadataSection.RomanisedTitleTextBox.Current.Value == expected);
|
||||
AddAssert($"romanised title is {expected}", () => metadataSection.RomanisedTitleTextBox.Current.Value, () => Is.EqualTo(expected));
|
||||
AddAssert($"romanised title is {(editable ? "" : "not ")}editable", () => metadataSection.RomanisedTitleTextBox.ReadOnly == !editable);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
public partial class TestSceneOpenEditorTimestamp : OsuGameTestScene
|
||||
{
|
||||
private Editor? editor => Game.ScreenStack.CurrentScreen as Editor;
|
||||
private EditorBeatmap editorBeatmap => editor.ChildrenOfType<EditorBeatmap>().Single();
|
||||
private EditorClock editorClock => editor.ChildrenOfType<EditorClock>().Single();
|
||||
|
||||
[Test]
|
||||
public void TestErrorNotifications()
|
||||
{
|
||||
RulesetInfo rulesetInfo = new OsuRuleset().RulesetInfo;
|
||||
|
||||
addStepClickLink("00:00:000", waitForSeek: false);
|
||||
AddUntilStep("received 'must be in edit'",
|
||||
() => Game.Notifications.AllNotifications.Count(x => x.Text == EditorStrings.MustBeInEditorToHandleLinks),
|
||||
() => Is.EqualTo(1));
|
||||
|
||||
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
|
||||
AddUntilStep("entered song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect);
|
||||
|
||||
addStepClickLink("00:00:000 (1)", waitForSeek: false);
|
||||
AddUntilStep("received 'must be in edit'",
|
||||
() => Game.Notifications.AllNotifications.Count(x => x.Text == EditorStrings.MustBeInEditorToHandleLinks),
|
||||
() => Is.EqualTo(2));
|
||||
|
||||
setUpEditor(rulesetInfo);
|
||||
AddAssert("ruleset is osu!", () => editorBeatmap.BeatmapInfo.Ruleset.Equals(rulesetInfo));
|
||||
|
||||
addStepClickLink("00:000", "invalid link", waitForSeek: false);
|
||||
AddUntilStep("received 'failed to process'",
|
||||
() => Game.Notifications.AllNotifications.Count(x => x.Text == EditorStrings.FailedToParseEditorLink),
|
||||
() => Is.EqualTo(1));
|
||||
|
||||
addStepClickLink("50000:00:000", "too long link", waitForSeek: false);
|
||||
AddUntilStep("received 'failed to process'",
|
||||
() => Game.Notifications.AllNotifications.Count(x => x.Text == EditorStrings.FailedToParseEditorLink),
|
||||
() => Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHandleCurrentScreenChanges()
|
||||
{
|
||||
RulesetInfo rulesetInfo = new OsuRuleset().RulesetInfo;
|
||||
|
||||
setUpEditor(rulesetInfo);
|
||||
AddAssert("is osu! ruleset", () => editorBeatmap.BeatmapInfo.Ruleset.Equals(rulesetInfo));
|
||||
|
||||
addStepClickLink("100:00:000", "long link");
|
||||
AddUntilStep("moved to end of track", () => editorClock.CurrentTime, () => Is.EqualTo(editorClock.TrackLength));
|
||||
|
||||
addStepScreenModeTo(EditorScreenMode.SongSetup);
|
||||
addStepClickLink("00:00:000");
|
||||
assertOnScreenAt(EditorScreenMode.SongSetup, 0);
|
||||
|
||||
addStepClickLink("00:05:000 (0|0)");
|
||||
assertMovedScreenTo(EditorScreenMode.Compose);
|
||||
|
||||
addStepScreenModeTo(EditorScreenMode.Design);
|
||||
addStepClickLink("00:10:000");
|
||||
assertOnScreenAt(EditorScreenMode.Design, 10_000);
|
||||
|
||||
addStepClickLink("00:15:000 (1)");
|
||||
assertMovedScreenTo(EditorScreenMode.Compose);
|
||||
|
||||
addStepScreenModeTo(EditorScreenMode.Timing);
|
||||
addStepClickLink("00:20:000");
|
||||
assertOnScreenAt(EditorScreenMode.Timing, 20_000);
|
||||
|
||||
addStepClickLink("00:25:000 (0,1)");
|
||||
assertMovedScreenTo(EditorScreenMode.Compose);
|
||||
|
||||
addStepScreenModeTo(EditorScreenMode.Verify);
|
||||
addStepClickLink("00:30:000");
|
||||
assertOnScreenAt(EditorScreenMode.Verify, 30_000);
|
||||
|
||||
addStepClickLink("00:35:000 (0,1)");
|
||||
assertMovedScreenTo(EditorScreenMode.Compose);
|
||||
|
||||
addStepClickLink("00:00:000");
|
||||
assertOnScreenAt(EditorScreenMode.Compose, 0);
|
||||
}
|
||||
|
||||
private void addStepClickLink(string timestamp, string step = "", bool waitForSeek = true)
|
||||
{
|
||||
AddStep($"{step} {timestamp}", () =>
|
||||
Game.HandleLink(new LinkDetails(LinkAction.OpenEditorTimestamp, timestamp))
|
||||
);
|
||||
|
||||
if (waitForSeek)
|
||||
AddUntilStep("wait for seek", () => editorClock.SeekingOrStopped.Value);
|
||||
}
|
||||
|
||||
private void addStepScreenModeTo(EditorScreenMode screenMode) =>
|
||||
AddStep("change screen to " + screenMode, () => editor!.Mode.Value = screenMode);
|
||||
|
||||
private void assertOnScreenAt(EditorScreenMode screen, double time)
|
||||
{
|
||||
AddAssert($"stayed on {screen} at {time}", () =>
|
||||
editor!.Mode.Value == screen
|
||||
&& editorClock.CurrentTime == time
|
||||
);
|
||||
}
|
||||
|
||||
private void assertMovedScreenTo(EditorScreenMode screen, string text = "moved to") =>
|
||||
AddAssert($"{text} {screen}", () => editor!.Mode.Value == screen);
|
||||
|
||||
private void setUpEditor(RulesetInfo ruleset)
|
||||
{
|
||||
BeatmapSetInfo beatmapSet = null!;
|
||||
|
||||
AddStep("Import test beatmap", () =>
|
||||
Game.BeatmapManager.Import(TestResources.GetTestBeatmapForImport()).WaitSafely()
|
||||
);
|
||||
AddStep("Retrieve beatmap", () =>
|
||||
beatmapSet = Game.BeatmapManager.QueryBeatmapSet(set => !set.Protected).AsNonNull().Value.Detach()
|
||||
);
|
||||
AddStep("Present beatmap", () => Game.PresentBeatmap(beatmapSet));
|
||||
AddUntilStep("Wait for song select", () =>
|
||||
Game.Beatmap.Value.BeatmapSetInfo.Equals(beatmapSet)
|
||||
&& Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect
|
||||
&& songSelect.IsLoaded
|
||||
);
|
||||
AddStep("Switch ruleset", () => Game.Ruleset.Value = ruleset);
|
||||
AddStep("Open editor for ruleset", () =>
|
||||
((PlaySongSelect)Game.ScreenStack.CurrentScreen)
|
||||
.Edit(beatmapSet.Beatmaps.Last(beatmap => beatmap.Ruleset.Name == ruleset.Name))
|
||||
);
|
||||
AddUntilStep("Wait for editor open", () => editor?.ReadyForUse == true);
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-10
@@ -16,7 +16,7 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
public partial class TestSceneRectangularPositionSnapGrid : OsuManualInputManagerTestScene
|
||||
public partial class TestScenePositionSnapGrid : OsuManualInputManagerTestScene
|
||||
{
|
||||
private Container content;
|
||||
protected override Container<Drawable> Content => content;
|
||||
@@ -33,28 +33,34 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
},
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(10),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static readonly object[][] test_cases =
|
||||
{
|
||||
new object[] { new Vector2(0, 0), new Vector2(10, 10) },
|
||||
new object[] { new Vector2(240, 180), new Vector2(10, 15) },
|
||||
new object[] { new Vector2(160, 120), new Vector2(30, 20) },
|
||||
new object[] { new Vector2(480, 360), new Vector2(100, 100) },
|
||||
new object[] { new Vector2(0, 0), new Vector2(10, 10), 0f },
|
||||
new object[] { new Vector2(240, 180), new Vector2(10, 15), 10f },
|
||||
new object[] { new Vector2(160, 120), new Vector2(30, 20), -10f },
|
||||
new object[] { new Vector2(480, 360), new Vector2(100, 100), 0f },
|
||||
};
|
||||
|
||||
[TestCaseSource(nameof(test_cases))]
|
||||
public void TestRectangularGrid(Vector2 position, Vector2 spacing)
|
||||
public void TestRectangularGrid(Vector2 position, Vector2 spacing, float rotation)
|
||||
{
|
||||
RectangularPositionSnapGrid grid = null;
|
||||
|
||||
AddStep("create grid", () => Child = grid = new RectangularPositionSnapGrid(position)
|
||||
AddStep("create grid", () =>
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Spacing = spacing
|
||||
Child = grid = new RectangularPositionSnapGrid
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
grid.StartPosition.Value = position;
|
||||
grid.Spacing.Value = spacing;
|
||||
grid.GridLineRotation.Value = rotation;
|
||||
});
|
||||
|
||||
AddStep("add snapping cursor", () => Add(new SnappingCursorContainer
|
||||
@@ -7,8 +7,10 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
@@ -44,6 +46,47 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestContextMenuWithObjectBehind()
|
||||
{
|
||||
TimelineHitObjectBlueprint blueprint;
|
||||
|
||||
AddStep("add object", () =>
|
||||
{
|
||||
EditorBeatmap.Add(new HitCircle { StartTime = 3000 });
|
||||
});
|
||||
|
||||
AddStep("enter slider placement", () =>
|
||||
{
|
||||
InputManager.Key(Key.Number3);
|
||||
InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre);
|
||||
});
|
||||
|
||||
AddStep("start conflicting slider", () =>
|
||||
{
|
||||
InputManager.Click(MouseButton.Left);
|
||||
|
||||
blueprint = this.ChildrenOfType<TimelineHitObjectBlueprint>().First();
|
||||
InputManager.MoveMouseTo(blueprint.ScreenSpaceDrawQuad.TopLeft - new Vector2(10, 0));
|
||||
});
|
||||
|
||||
AddStep("end conflicting slider", () =>
|
||||
{
|
||||
InputManager.Click(MouseButton.Right);
|
||||
});
|
||||
|
||||
AddStep("click object", () =>
|
||||
{
|
||||
InputManager.Key(Key.Number1);
|
||||
blueprint = this.ChildrenOfType<TimelineHitObjectBlueprint>().First();
|
||||
InputManager.MoveMouseTo(blueprint);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddStep("right click", () => InputManager.Click(MouseButton.Right));
|
||||
AddAssert("context menu open", () => this.ChildrenOfType<OsuContextMenu>().SingleOrDefault()?.State == MenuState.Open);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNudgeSelection()
|
||||
{
|
||||
@@ -139,7 +182,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
AddStep("click away", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(Editor.ChildrenOfType<TimelineArea>().Single().ScreenSpaceDrawQuad.TopLeft + Vector2.One);
|
||||
InputManager.MoveMouseTo(Editor.ChildrenOfType<Timeline>().First().ScreenSpaceDrawQuad.TopLeft + new Vector2(5));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@@ -17,6 +19,7 @@ using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Timing;
|
||||
using osu.Game.Screens.Edit.Timing.RowAttributes;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
@@ -69,6 +72,48 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddUntilStep("Wait for rows to load", () => Child.ChildrenOfType<EffectRowAttribute>().Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectedRetainedOverUndo()
|
||||
{
|
||||
AddStep("Select first timing point", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(Child.ChildrenOfType<TimingRowAttribute>().First());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 2170);
|
||||
AddUntilStep("Ensure seeked to correct time", () => EditorClock.CurrentTimeAccurate == 2170);
|
||||
|
||||
AddStep("Adjust offset", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(timingScreen.ChildrenOfType<TimingAdjustButton>().First().ScreenSpaceDrawQuad.Centre + new Vector2(20, 0));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for offset changed", () =>
|
||||
{
|
||||
return timingScreen.SelectedGroup.Value.ControlPoints.Any(c => c is TimingControlPoint) && timingScreen.SelectedGroup.Value.Time > 2170;
|
||||
});
|
||||
|
||||
AddStep("simulate undo", () =>
|
||||
{
|
||||
var clone = editorBeatmap.ControlPointInfo.DeepClone();
|
||||
|
||||
editorBeatmap.ControlPointInfo.Clear();
|
||||
|
||||
foreach (var group in clone.Groups)
|
||||
{
|
||||
foreach (var cp in group.ControlPoints)
|
||||
editorBeatmap.ControlPointInfo.Add(group.Time, cp);
|
||||
}
|
||||
});
|
||||
|
||||
AddUntilStep("selection retained", () =>
|
||||
{
|
||||
return timingScreen.SelectedGroup.Value.ControlPoints.Any(c => c is TimingControlPoint) && timingScreen.SelectedGroup.Value.Time > 2170;
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTrackingCurrentTimeWhileRunning()
|
||||
{
|
||||
@@ -134,6 +179,43 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddUntilStep("Scrolled to end", () => timingScreen.ChildrenOfType<OsuScrollContainer>().First().IsScrolledToEnd());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEditThenClickAwayAppliesChanges()
|
||||
{
|
||||
AddStep("Add two control points", () =>
|
||||
{
|
||||
editorBeatmap.ControlPointInfo.Clear();
|
||||
editorBeatmap.ControlPointInfo.Add(1000, new TimingControlPoint());
|
||||
editorBeatmap.ControlPointInfo.Add(2000, new TimingControlPoint());
|
||||
});
|
||||
|
||||
AddStep("Select second timing point", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(Child.ChildrenOfType<TimingRowAttribute>().Last());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddStep("Scroll to end", () => timingScreen.ChildrenOfType<ControlPointSettings>().Single().ChildrenOfType<OsuScrollContainer>().Single().ScrollToEnd(false));
|
||||
AddStep("Modify time signature", () =>
|
||||
{
|
||||
var timeSignatureTextBox = Child.ChildrenOfType<LabelledTimeSignature.TimeSignatureBox>().Single().ChildrenOfType<TextBox>().Single();
|
||||
InputManager.MoveMouseTo(timeSignatureTextBox);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
|
||||
Debug.Assert(!timeSignatureTextBox.Current.Value.Equals("1", StringComparison.Ordinal));
|
||||
timeSignatureTextBox.Current.Value = "1";
|
||||
});
|
||||
|
||||
AddStep("Select first timing point", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(Child.ChildrenOfType<TimingRowAttribute>().First());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("Second timing point changed time signature", () => editorBeatmap.ControlPointInfo.TimingPoints.Last().TimeSignature.Numerator == 1);
|
||||
AddAssert("First timing point preserved time signature", () => editorBeatmap.ControlPointInfo.TimingPoints.First().TimeSignature.Numerator == 4);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
Beatmap.Disabled = false;
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
public void TestWidthUpdatesOnDrawSizeChanges()
|
||||
{
|
||||
AddStep("Shrink scroll container", () => scrollContainer.Width = 0.5f);
|
||||
AddAssert("Scroll container width shrunk", () => scrollContainer.DrawWidth == scrollContainer.Parent.DrawWidth / 2);
|
||||
AddAssert("Scroll container width shrunk", () => scrollContainer.DrawWidth == scrollContainer.Parent!.DrawWidth / 2);
|
||||
AddAssert("Inner container width matches scroll container", () => innerBox.DrawWidth == scrollContainer.DrawWidth);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Skinning;
|
||||
@@ -13,8 +13,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
[SetUpSteps]
|
||||
public virtual void SetUpSteps()
|
||||
{
|
||||
AddStep("setup components", SetUpComponents);
|
||||
}
|
||||
|
||||
public void SetUpComponents()
|
||||
{
|
||||
SetContents(skin =>
|
||||
{
|
||||
@@ -28,7 +33,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
implementation.Origin = Anchor.Centre;
|
||||
return implementation;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract Drawable CreateDefaultImplementation();
|
||||
protected virtual Drawable CreateArgonImplementation() => CreateDefaultImplementation();
|
||||
|
||||
@@ -67,6 +67,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private Player loadPlayerFor(RulesetInfo rulesetInfo)
|
||||
{
|
||||
// if a player screen is present already, we must exit that before loading another one,
|
||||
// otherwise it'll crash on SpectatorClient.BeginPlaying being called while client is in "playing" state already.
|
||||
if (Stack.CurrentScreen is Player)
|
||||
Stack.Exit();
|
||||
|
||||
Ruleset.Value = rulesetInfo;
|
||||
var ruleset = rulesetInfo.CreateInstance();
|
||||
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public partial class TestSceneArgonHealthDisplay : OsuTestScene
|
||||
{
|
||||
[Cached(typeof(HealthProcessor))]
|
||||
private HealthProcessor healthProcessor = new DrainingHealthProcessor(0);
|
||||
|
||||
private ArgonHealthDisplay healthDisplay = null!;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
AddSliderStep("Height", 0, 64, 0, val =>
|
||||
{
|
||||
if (healthDisplay.IsNotNull())
|
||||
healthDisplay.BarHeight.Value = val;
|
||||
});
|
||||
|
||||
AddSliderStep("Width", 0, 1f, 0.98f, val =>
|
||||
{
|
||||
if (healthDisplay.IsNotNull())
|
||||
healthDisplay.Width = val;
|
||||
});
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep(@"Reset all", delegate
|
||||
{
|
||||
healthProcessor.Health.Value = 1;
|
||||
healthProcessor.Failed += () => false; // health won't be updated if the processor gets into a "fail" state.
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Gray,
|
||||
},
|
||||
healthDisplay = new ArgonHealthDisplay
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHealthDisplayIncrementing()
|
||||
{
|
||||
AddRepeatStep("apply miss judgement", applyMiss, 5);
|
||||
|
||||
AddRepeatStep(@"decrease hp slightly", delegate
|
||||
{
|
||||
healthProcessor.Health.Value -= 0.01f;
|
||||
}, 10);
|
||||
|
||||
AddRepeatStep(@"increase hp without flash", delegate
|
||||
{
|
||||
healthProcessor.Health.Value += 0.1f;
|
||||
}, 3);
|
||||
|
||||
AddRepeatStep(@"increase hp with flash", delegate
|
||||
{
|
||||
healthProcessor.Health.Value += 0.1f;
|
||||
applyPerfectHit();
|
||||
}, 3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLateMissAfterConsequentMisses()
|
||||
{
|
||||
AddUntilStep("wait for health", () => healthDisplay.Current.Value == 1);
|
||||
AddStep("apply sequence", () =>
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
applyMiss();
|
||||
|
||||
Scheduler.AddDelayed(applyMiss, 500 + 30);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMissAlmostExactlyAfterLastMissAnimation()
|
||||
{
|
||||
AddUntilStep("wait for health", () => healthDisplay.Current.Value == 1);
|
||||
AddStep("apply sequence", () =>
|
||||
{
|
||||
const double interval = 500 + 15;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
Scheduler.AddDelayed(applyMiss, i * interval);
|
||||
else
|
||||
{
|
||||
Scheduler.AddDelayed(applyMiss, i * interval);
|
||||
Scheduler.AddDelayed(applyMiss, i * interval);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMissThenHitAtSameUpdateFrame()
|
||||
{
|
||||
AddUntilStep("wait for health", () => healthDisplay.Current.Value == 1);
|
||||
AddStep("set half health", () => healthProcessor.Health.Value = 0.5f);
|
||||
|
||||
AddStep("apply miss and hit", () =>
|
||||
{
|
||||
applyMiss();
|
||||
applyMiss();
|
||||
applyPerfectHit();
|
||||
applyPerfectHit();
|
||||
});
|
||||
|
||||
AddWaitStep("wait", 3);
|
||||
|
||||
AddStep("apply miss and cancel with hit", () =>
|
||||
{
|
||||
applyMiss();
|
||||
applyPerfectHit();
|
||||
applyPerfectHit();
|
||||
applyPerfectHit();
|
||||
applyPerfectHit();
|
||||
});
|
||||
}
|
||||
|
||||
private void applyMiss()
|
||||
{
|
||||
healthProcessor.ApplyResult(new JudgementResult(new HitObject(), new Judgement()) { Type = HitResult.Miss });
|
||||
}
|
||||
|
||||
private void applyPerfectHit()
|
||||
{
|
||||
healthProcessor.ApplyResult(new JudgementResult(new HitCircle(), new OsuJudgement())
|
||||
{
|
||||
Type = HitResult.Perfect
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSimulateDrain()
|
||||
{
|
||||
ScheduledDelegate del = null!;
|
||||
|
||||
AddStep("simulate drain", () => del = Scheduler.AddDelayed(() => healthProcessor.Health.Value -= 0.00025f * Time.Elapsed, 0, true));
|
||||
AddUntilStep("wait until zero", () => healthProcessor.Health.Value == 0);
|
||||
AddStep("cancel drain", () => del.Cancel());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,8 +47,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
seekTo(referenceBeatmap.HitObjects[^1].GetEndTime());
|
||||
AddUntilStep("results displayed", () => getResultsScreen()?.IsLoaded == true);
|
||||
|
||||
AddAssert("score has combo", () => getResultsScreen().Score.Combo > 100);
|
||||
AddAssert("score has no misses", () => getResultsScreen().Score.Statistics[HitResult.Miss] == 0);
|
||||
AddAssert("score has combo", () => getResultsScreen().Score!.Combo > 100);
|
||||
AddAssert("score has no misses", () => getResultsScreen().Score!.Statistics[HitResult.Miss] == 0);
|
||||
|
||||
AddUntilStep("avatar displayed", () => getAvatar() != null);
|
||||
AddAssert("avatar not clickable", () => getAvatar().ChildrenOfType<OsuClickableContainer>().First().Action == null);
|
||||
|
||||
@@ -12,6 +12,7 @@ using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Tests.Visual.Ranking;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
@@ -44,7 +45,23 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
offsetControl.ReferenceScore.Value = new ScoreInfo
|
||||
{
|
||||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(0, 2)
|
||||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(0, 2),
|
||||
BeatmapInfo = Beatmap.Value.BeatmapInfo,
|
||||
};
|
||||
});
|
||||
|
||||
AddAssert("No calibration button", () => !offsetControl.ChildrenOfType<SettingsButton>().Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestScoreFromDifferentBeatmap()
|
||||
{
|
||||
AddStep("Set short reference score", () =>
|
||||
{
|
||||
offsetControl.ReferenceScore.Value = new ScoreInfo
|
||||
{
|
||||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(10),
|
||||
BeatmapInfo = TestResources.CreateTestBeatmapSetInfo().Beatmaps.First(),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -59,7 +76,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
offsetControl.ReferenceScore.Value = new ScoreInfo
|
||||
{
|
||||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(10),
|
||||
Mods = new Mod[] { new OsuModRelax() }
|
||||
Mods = new Mod[] { new OsuModRelax() },
|
||||
BeatmapInfo = Beatmap.Value.BeatmapInfo,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -77,7 +95,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
offsetControl.ReferenceScore.Value = new ScoreInfo
|
||||
{
|
||||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error)
|
||||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error),
|
||||
BeatmapInfo = Beatmap.Value.BeatmapInfo,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -105,7 +124,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
offsetControl.ReferenceScore.Value = new ScoreInfo
|
||||
{
|
||||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error)
|
||||
HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents(average_error),
|
||||
BeatmapInfo = Beatmap.Value.BeatmapInfo,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
var expectedComponentsAdjustmentContainer = new DependencyProvidingContainer
|
||||
{
|
||||
Position = actualComponentsContainer.Parent.ToSpaceOfOtherDrawable(actualComponentsContainer.DrawPosition, Content),
|
||||
Position = actualComponentsContainer.Parent!.ToSpaceOfOtherDrawable(actualComponentsContainer.DrawPosition, Content),
|
||||
Size = actualComponentsContainer.DrawSize,
|
||||
Child = expectedComponentsContainer,
|
||||
// proxy the same required dependencies that `actualComponentsContainer` is using.
|
||||
|
||||
@@ -114,23 +114,25 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
}
|
||||
|
||||
[TestCase(PathType.Linear)]
|
||||
[TestCase(PathType.Bezier)]
|
||||
[TestCase(PathType.Catmull)]
|
||||
[TestCase(PathType.PerfectCurve)]
|
||||
public void TestSingleSegment(PathType type)
|
||||
=> AddStep("create path", () => path.ControlPoints.AddRange(createSegment(type, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
[TestCase(SplineType.Linear, null)]
|
||||
[TestCase(SplineType.BSpline, null)]
|
||||
[TestCase(SplineType.BSpline, 3)]
|
||||
[TestCase(SplineType.Catmull, null)]
|
||||
[TestCase(SplineType.PerfectCurve, null)]
|
||||
public void TestSingleSegment(SplineType splineType, int? degree)
|
||||
=> AddStep("create path", () => path.ControlPoints.AddRange(createSegment(new PathType { Type = splineType, Degree = degree }, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
|
||||
[TestCase(PathType.Linear)]
|
||||
[TestCase(PathType.Bezier)]
|
||||
[TestCase(PathType.Catmull)]
|
||||
[TestCase(PathType.PerfectCurve)]
|
||||
public void TestMultipleSegment(PathType type)
|
||||
[TestCase(SplineType.Linear, null)]
|
||||
[TestCase(SplineType.BSpline, null)]
|
||||
[TestCase(SplineType.BSpline, 3)]
|
||||
[TestCase(SplineType.Catmull, null)]
|
||||
[TestCase(SplineType.PerfectCurve, null)]
|
||||
public void TestMultipleSegment(SplineType splineType, int? degree)
|
||||
{
|
||||
AddStep("create path", () =>
|
||||
{
|
||||
path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero));
|
||||
path.ControlPoints.AddRange(createSegment(type, new Vector2(0, 100), new Vector2(100), Vector2.Zero));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero));
|
||||
path.ControlPoints.AddRange(createSegment(new PathType { Type = splineType, Degree = degree }, new Vector2(0, 100), new Vector2(100), Vector2.Zero));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -139,9 +141,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
AddStep("create path", () =>
|
||||
{
|
||||
path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(100, 0)));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.Bezier, new Vector2(100, 0), new Vector2(150, 30), new Vector2(100, 100)));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PerfectCurve, new Vector2(100, 100), new Vector2(25, 50), Vector2.Zero));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(100, 0)));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.BEZIER, new Vector2(100, 0), new Vector2(150, 30), new Vector2(100, 100)));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PERFECT_CURVE, new Vector2(100, 100), new Vector2(25, 50), Vector2.Zero));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -157,7 +159,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
AddStep("create path", () =>
|
||||
{
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PerfectCurve, Vector2.Zero, new Vector2(width / 2, height), new Vector2(width, 0)));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PERFECT_CURVE, Vector2.Zero, new Vector2(width / 2, height), new Vector2(width, 0)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -170,11 +172,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
switch (points)
|
||||
{
|
||||
case 2:
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PerfectCurve, Vector2.Zero, new Vector2(0, 100)));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PERFECT_CURVE, Vector2.Zero, new Vector2(0, 100)));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PerfectCurve, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0)));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PERFECT_CURVE, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0)));
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
protected override bool AllowFail => false;
|
||||
|
||||
protected override bool AllowBackwardsSeeks => true;
|
||||
|
||||
[SetUpSteps]
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Gameplay;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public partial class TestSceneDelayedResumeOverlay : OsuTestScene
|
||||
{
|
||||
private ResumeOverlay resume = null!;
|
||||
private bool resumeFired;
|
||||
|
||||
[Cached]
|
||||
private GameplayState gameplayState;
|
||||
|
||||
public TestSceneDelayedResumeOverlay()
|
||||
{
|
||||
gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(loadContent);
|
||||
|
||||
[Test]
|
||||
public void TestResume()
|
||||
{
|
||||
AddStep("show", () => resume.Show());
|
||||
AddUntilStep("dismissed", () => resumeFired && resume.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
private void loadContent()
|
||||
{
|
||||
Child = resume = new DelayedResumeOverlay();
|
||||
|
||||
resumeFired = false;
|
||||
resume.ResumeAction = () => resumeFired = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
var beatmap = createBeatmap();
|
||||
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
|
||||
beatmap.Difficulty.SliderMultiplier = 2;
|
||||
beatmap.BeatmapInfo.Difficulty.SliderMultiplier = 2;
|
||||
|
||||
createTest(beatmap);
|
||||
AddStep("adjust time range", () => drawableRuleset.TimeRange.Value = 2000);
|
||||
@@ -237,7 +237,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
});
|
||||
|
||||
private void assertPosition(int index, float relativeY) => AddAssert($"hitobject {index} at {relativeY}",
|
||||
() => Precision.AlmostEquals(getDrawableHitObject(index)?.DrawPosition.Y ?? -1, yScale * relativeY));
|
||||
() => getDrawableHitObject(index)?.DrawPosition.Y / yScale ?? -1, () => Is.EqualTo(relativeY).Within(Precision.FLOAT_EPSILON));
|
||||
|
||||
private void setTime(double time)
|
||||
{
|
||||
@@ -251,7 +251,17 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
/// <returns>The <see cref="IBeatmap"/>.</returns>
|
||||
private IBeatmap createBeatmap(Func<int, TestHitObject> createAction = null)
|
||||
{
|
||||
var beatmap = new Beatmap<TestHitObject> { BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo } };
|
||||
var beatmap = new Beatmap<TestHitObject>
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Difficulty = new BeatmapDifficulty
|
||||
{
|
||||
SliderMultiplier = 1
|
||||
},
|
||||
Ruleset = new OsuRuleset().RulesetInfo
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
@@ -311,14 +321,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
protected override bool RelativeScaleBeatLengths => RelativeScaleBeatLengthsOverride;
|
||||
|
||||
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping;
|
||||
|
||||
public new Bindable<double> TimeRange => base.TimeRange;
|
||||
|
||||
public TestDrawableScrollingRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
TimeRange.Value = time_range;
|
||||
VisualisationMethod = ScrollVisualisationMethod.Overlapping;
|
||||
}
|
||||
|
||||
public override DrawableHitObject<TestHitObject> CreateDrawableRepresentation(TestHitObject h)
|
||||
|
||||
@@ -2,17 +2,24 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
@@ -21,17 +28,21 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset();
|
||||
|
||||
[Cached]
|
||||
private Storyboard storyboard { get; set; } = new Storyboard();
|
||||
[Cached(typeof(Storyboard))]
|
||||
private TestStoryboard storyboard { get; set; } = new TestStoryboard();
|
||||
|
||||
private IEnumerable<DrawableStoryboardSprite> sprites => this.ChildrenOfType<DrawableStoryboardSprite>();
|
||||
|
||||
private const string lookup_name = "hitcircleoverlay";
|
||||
|
||||
[Test]
|
||||
public void TestSkinSpriteDisallowedByDefault()
|
||||
{
|
||||
const string lookup_name = "hitcircleoverlay";
|
||||
|
||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = false);
|
||||
AddStep("disallow all lookups", () =>
|
||||
{
|
||||
storyboard.UseSkinSprites = false;
|
||||
storyboard.ProvideResources = false;
|
||||
});
|
||||
|
||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||
|
||||
@@ -40,11 +51,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAllowLookupFromSkin()
|
||||
public void TestLookupFromStoryboard()
|
||||
{
|
||||
const string lookup_name = "hitcircleoverlay";
|
||||
|
||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
|
||||
AddStep("allow storyboard lookup", () =>
|
||||
{
|
||||
storyboard.UseSkinSprites = false;
|
||||
storyboard.ProvideResources = true;
|
||||
});
|
||||
|
||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||
|
||||
@@ -52,16 +65,89 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("sprite found texture", () =>
|
||||
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Texture != null)));
|
||||
|
||||
AddAssert("skinnable sprite has correct size", () =>
|
||||
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Size == new Vector2(128))));
|
||||
assertStoryboardSourced();
|
||||
}
|
||||
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void TestVideo(bool scaleTransformProvided)
|
||||
{
|
||||
AddStep("allow storyboard lookup", () =>
|
||||
{
|
||||
storyboard.ProvideResources = true;
|
||||
});
|
||||
|
||||
AddStep("create video", () => SetContents(_ =>
|
||||
{
|
||||
var layer = storyboard.GetLayer("Video");
|
||||
|
||||
var sprite = new StoryboardVideo("Videos/test-video.mp4", Time.Current);
|
||||
|
||||
if (scaleTransformProvided)
|
||||
{
|
||||
sprite.Commands.AddScale(Easing.None, Time.Current, Time.Current + 1000, 1, 2);
|
||||
sprite.Commands.AddScale(Easing.None, Time.Current + 1000, Time.Current + 2000, 2, 1);
|
||||
}
|
||||
|
||||
layer.Elements.Clear();
|
||||
layer.Add(sprite);
|
||||
|
||||
return new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
storyboard.CreateDrawable()
|
||||
}
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSkinLookupPreferredOverStoryboard()
|
||||
{
|
||||
AddStep("allow all lookups", () =>
|
||||
{
|
||||
storyboard.UseSkinSprites = true;
|
||||
storyboard.ProvideResources = true;
|
||||
});
|
||||
|
||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||
|
||||
// Only checking for at least one sprite that succeeded, as not all skins in this test provide the hitcircleoverlay texture.
|
||||
AddAssert("sprite found texture", () =>
|
||||
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Texture != null)));
|
||||
|
||||
assertSkinSourced();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAllowLookupFromSkin()
|
||||
{
|
||||
AddStep("allow skin lookup", () =>
|
||||
{
|
||||
storyboard.UseSkinSprites = true;
|
||||
storyboard.ProvideResources = false;
|
||||
});
|
||||
|
||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||
|
||||
// Only checking for at least one sprite that succeeded, as not all skins in this test provide the hitcircleoverlay texture.
|
||||
AddAssert("sprite found texture", () =>
|
||||
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Texture != null)));
|
||||
|
||||
assertSkinSourced();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFlippedSprite()
|
||||
{
|
||||
const string lookup_name = "hitcircleoverlay";
|
||||
AddStep("allow all lookups", () =>
|
||||
{
|
||||
storyboard.UseSkinSprites = true;
|
||||
storyboard.ProvideResources = true;
|
||||
});
|
||||
|
||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
|
||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||
AddStep("flip sprites", () => sprites.ForEach(s =>
|
||||
{
|
||||
@@ -74,9 +160,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestZeroScale()
|
||||
{
|
||||
const string lookup_name = "hitcircleoverlay";
|
||||
AddStep("allow all lookups", () =>
|
||||
{
|
||||
storyboard.UseSkinSprites = true;
|
||||
storyboard.ProvideResources = true;
|
||||
});
|
||||
|
||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
|
||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||
AddAssert("sprites present", () => sprites.All(s => s.IsPresent));
|
||||
AddStep("scale sprite", () => sprites.ForEach(s => s.VectorScale = new Vector2(0, 1)));
|
||||
@@ -86,9 +175,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestNegativeScale()
|
||||
{
|
||||
const string lookup_name = "hitcircleoverlay";
|
||||
AddStep("allow all lookups", () =>
|
||||
{
|
||||
storyboard.UseSkinSprites = true;
|
||||
storyboard.ProvideResources = true;
|
||||
});
|
||||
|
||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
|
||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||
AddStep("scale sprite", () => sprites.ForEach(s => s.VectorScale = new Vector2(-1)));
|
||||
AddAssert("origin flipped", () => sprites.All(s => s.Origin == Anchor.BottomRight));
|
||||
@@ -97,9 +189,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestNegativeScaleWithFlippedSprite()
|
||||
{
|
||||
const string lookup_name = "hitcircleoverlay";
|
||||
AddStep("allow all lookups", () =>
|
||||
{
|
||||
storyboard.UseSkinSprites = true;
|
||||
storyboard.ProvideResources = true;
|
||||
});
|
||||
|
||||
AddStep("allow skin lookup", () => storyboard.UseSkinSprites = true);
|
||||
AddStep("create sprites", () => SetContents(_ => createSprite(lookup_name, Anchor.TopLeft, Vector2.Zero)));
|
||||
AddStep("scale sprite", () => sprites.ForEach(s => s.VectorScale = new Vector2(-1)));
|
||||
AddAssert("origin flipped", () => sprites.All(s => s.Origin == Anchor.BottomRight));
|
||||
@@ -111,13 +206,96 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("origin back", () => sprites.All(s => s.Origin == Anchor.TopLeft));
|
||||
}
|
||||
|
||||
private DrawableStoryboardSprite createSprite(string lookupName, Anchor origin, Vector2 initialPosition)
|
||||
=> new DrawableStoryboardSprite(
|
||||
new StoryboardSprite(lookupName, origin, initialPosition)
|
||||
).With(s =>
|
||||
private Drawable createSprite(string lookupName, Anchor origin, Vector2 initialPosition)
|
||||
{
|
||||
var layer = storyboard.GetLayer("Background");
|
||||
|
||||
var sprite = new StoryboardSprite(lookupName, origin, initialPosition);
|
||||
var loop = sprite.AddLoopingGroup(Time.Current, 100);
|
||||
loop.AddAlpha(Easing.None, 0, 10000, 1, 1);
|
||||
|
||||
layer.Elements.Clear();
|
||||
layer.Add(sprite);
|
||||
|
||||
return new Container
|
||||
{
|
||||
s.LifetimeStart = double.MinValue;
|
||||
s.LifetimeEnd = double.MaxValue;
|
||||
});
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
storyboard.CreateDrawable()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void assertStoryboardSourced()
|
||||
{
|
||||
AddAssert("sprite came from storyboard", () =>
|
||||
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Size == new Vector2(200))));
|
||||
}
|
||||
|
||||
private void assertSkinSourced()
|
||||
{
|
||||
AddAssert("sprite came from skin", () =>
|
||||
sprites.Any(sprite => sprite.ChildrenOfType<Sprite>().All(s => s.Size == new Vector2(128))));
|
||||
}
|
||||
|
||||
private partial class TestStoryboard : Storyboard
|
||||
{
|
||||
public override DrawableStoryboard CreateDrawable(IReadOnlyList<Mod>? mods = null)
|
||||
{
|
||||
return new TestDrawableStoryboard(this, mods);
|
||||
}
|
||||
|
||||
public bool ProvideResources { get; set; }
|
||||
|
||||
public override string GetStoragePathFromStoryboardPath(string path) => ProvideResources ? path : string.Empty;
|
||||
|
||||
private partial class TestDrawableStoryboard : DrawableStoryboard
|
||||
{
|
||||
private readonly bool provideResources;
|
||||
|
||||
public TestDrawableStoryboard(TestStoryboard storyboard, IReadOnlyList<Mod>? mods)
|
||||
: base(storyboard, mods)
|
||||
{
|
||||
provideResources = storyboard.ProvideResources;
|
||||
}
|
||||
|
||||
protected override IResourceStore<byte[]> CreateResourceLookupStore() => provideResources
|
||||
? new ResourcesTextureStore()
|
||||
: new ResourceStore<byte[]>();
|
||||
|
||||
internal class ResourcesTextureStore : IResourceStore<byte[]>
|
||||
{
|
||||
private readonly DllResourceStore store;
|
||||
|
||||
public ResourcesTextureStore()
|
||||
{
|
||||
store = TestResources.GetStore();
|
||||
}
|
||||
|
||||
public void Dispose() => store.Dispose();
|
||||
|
||||
public byte[] Get(string name) => store.Get(map(name));
|
||||
|
||||
public Task<byte[]> GetAsync(string name, CancellationToken cancellationToken = new CancellationToken()) => store.GetAsync(map(name), cancellationToken);
|
||||
|
||||
public Stream GetStream(string name) => store.GetStream(map(name));
|
||||
|
||||
private string map(string name)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case lookup_name:
|
||||
return "Resources/Textures/test-image.png";
|
||||
|
||||
default:
|
||||
return $"Resources/{name}";
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAvailableResources() => store.GetAvailableResources();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private readonly Bindable<bool> showHealth = new Bindable<bool>();
|
||||
|
||||
private HealthProcessor healthProcessor;
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; }
|
||||
|
||||
@@ -29,7 +31,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
AddStep("create layer", () =>
|
||||
{
|
||||
Child = new HealthProcessorContainer(healthProcessor)
|
||||
Child = new HealthProcessorContainer(this.healthProcessor = healthProcessor)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = layer = new FailingLayer()
|
||||
@@ -50,12 +52,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddSliderStep("current health", 0.0, 1.0, 1.0, val =>
|
||||
{
|
||||
if (layer != null)
|
||||
layer.Current.Value = val;
|
||||
healthProcessor.Health.Value = val;
|
||||
});
|
||||
|
||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
||||
AddStep("set health to 0.10", () => healthProcessor.Health.Value = 0.1);
|
||||
AddUntilStep("layer fade is visible", () => layer.ChildrenOfType<Container>().First().Alpha > 0.1f);
|
||||
AddStep("set health to 1", () => layer.Current.Value = 1f);
|
||||
AddStep("set health to 1", () => healthProcessor.Health.Value = 1f);
|
||||
AddUntilStep("layer fade is invisible", () => !layer.ChildrenOfType<Container>().First().IsPresent);
|
||||
}
|
||||
|
||||
@@ -65,7 +67,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
create(new DrainingHealthProcessor(0));
|
||||
AddUntilStep("layer is visible", () => layer.IsPresent);
|
||||
AddStep("disable layer", () => config.SetValue(OsuSetting.FadePlayfieldWhenHealthLow, false));
|
||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
||||
AddStep("set health to 0.10", () => healthProcessor.Health.Value = 0.1);
|
||||
AddUntilStep("layer is not visible", () => !layer.IsPresent);
|
||||
}
|
||||
|
||||
@@ -74,7 +76,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
create(new AccumulatingHealthProcessor(1));
|
||||
AddUntilStep("layer is not visible", () => !layer.IsPresent);
|
||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
||||
AddStep("set health to 0.10", () => healthProcessor.Health.Value = 0.1);
|
||||
AddUntilStep("layer is not visible", () => !layer.IsPresent);
|
||||
}
|
||||
|
||||
@@ -82,7 +84,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public void TestLayerVisibilityWithDrainingProcessor()
|
||||
{
|
||||
create(new DrainingHealthProcessor(0));
|
||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
||||
AddStep("set health to 0.10", () => healthProcessor.Health.Value = 0.1);
|
||||
AddWaitStep("wait for potential fade", 10);
|
||||
AddAssert("layer is still visible", () => layer.IsPresent);
|
||||
}
|
||||
@@ -92,7 +94,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
create(new DrainingHealthProcessor(0));
|
||||
|
||||
AddStep("set health to 0.10", () => layer.Current.Value = 0.1);
|
||||
AddStep("set health to 0.10", () => healthProcessor.Health.Value = 0.1);
|
||||
|
||||
AddStep("don't show health", () => showHealth.Value = false);
|
||||
AddStep("disable FadePlayfieldWhenHealthLow", () => config.SetValue(OsuSetting.FadePlayfieldWhenHealthLow, false));
|
||||
|
||||
@@ -129,11 +129,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
checkRate(1);
|
||||
}
|
||||
|
||||
private const int max_frames_catchup = 50;
|
||||
|
||||
private void createStabilityContainer(double gameplayStartTime = double.MinValue) => AddStep("create container", () =>
|
||||
mainContainer.Child = new FrameStabilityContainer(gameplayStartTime) { MaxCatchUpFrames = max_frames_catchup }
|
||||
.WithChild(consumer = new ClockConsumingChild()));
|
||||
{
|
||||
mainContainer.Child = new FrameStabilityContainer(gameplayStartTime)
|
||||
{
|
||||
AllowBackwardsSeeks = true,
|
||||
}.WithChild(consumer = new ClockConsumingChild());
|
||||
});
|
||||
|
||||
private void seekManualTo(double time) => AddStep($"seek manual clock to {time}", () => manualClock.CurrentTime = time);
|
||||
|
||||
|
||||
@@ -3,14 +3,17 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.PolygonExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK;
|
||||
@@ -139,6 +142,37 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
=> AddAssert($"leaderboard height is {panelCount} panels high", () => leaderboard.DrawHeight == (GameplayLeaderboardScore.PANEL_HEIGHT + leaderboard.Spacing) * panelCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFriendScore()
|
||||
{
|
||||
APIUser friend = new APIUser { Username = "my friend", Id = 10000 };
|
||||
|
||||
createLeaderboard();
|
||||
addLocalPlayer();
|
||||
|
||||
AddStep("Add friend to API", () =>
|
||||
{
|
||||
var api = (DummyAPIAccess)API;
|
||||
|
||||
api.Friends.Clear();
|
||||
api.Friends.Add(friend);
|
||||
});
|
||||
|
||||
int playerNumber = 1;
|
||||
|
||||
AddRepeatStep("add 3 other players", () => createRandomScore(new APIUser { Username = $"Player {playerNumber++}" }), 3);
|
||||
AddUntilStep("no pink color scores",
|
||||
() => leaderboard.ChildrenOfType<Box>().Select(b => ((Colour4)b.Colour).ToHex()),
|
||||
() => Does.Not.Contain("#FF549A"));
|
||||
|
||||
AddRepeatStep("add 3 friend score", () => createRandomScore(friend), 3);
|
||||
AddUntilStep("at least one friend score is pink",
|
||||
() => leaderboard.GetAllScoresForUsername("my friend")
|
||||
.SelectMany(score => score.ChildrenOfType<Box>())
|
||||
.Select(b => ((Colour4)b.Colour).ToHex()),
|
||||
() => Does.Contain("#FF549A"));
|
||||
}
|
||||
|
||||
private void addLocalPlayer()
|
||||
{
|
||||
AddStep("add local player", () =>
|
||||
@@ -179,6 +213,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
return scoreItem != null && scoreItem.ScorePosition == expectedPosition;
|
||||
}
|
||||
|
||||
public IEnumerable<GameplayLeaderboardScore> GetAllScoresForUsername(string username)
|
||||
=> Flow.Where(i => i.User?.Username == username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
@@ -21,10 +18,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Description("player pause/fail screens")]
|
||||
public partial class TestSceneGameplayMenuOverlay : OsuManualInputManagerTestScene
|
||||
{
|
||||
private FailOverlay failOverlay;
|
||||
private PauseOverlay pauseOverlay;
|
||||
private FailOverlay failOverlay = null!;
|
||||
private PauseOverlay pauseOverlay = null!;
|
||||
|
||||
private GlobalActionContainer globalActionContainer;
|
||||
private GlobalActionContainer globalActionContainer = null!;
|
||||
|
||||
private bool triggeredRetryButton;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase game)
|
||||
@@ -35,12 +34,18 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
triggeredRetryButton = false;
|
||||
|
||||
globalActionContainer.Children = new Drawable[]
|
||||
{
|
||||
pauseOverlay = new PauseOverlay
|
||||
{
|
||||
OnResume = () => Logger.Log(@"Resume"),
|
||||
OnRetry = () => Logger.Log(@"Retry"),
|
||||
OnRetry = () =>
|
||||
{
|
||||
Logger.Log(@"Retry");
|
||||
triggeredRetryButton = true;
|
||||
},
|
||||
OnQuit = () => Logger.Log(@"Quit"),
|
||||
},
|
||||
failOverlay = new FailOverlay
|
||||
@@ -224,17 +229,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
showOverlay();
|
||||
|
||||
bool triggered = false;
|
||||
AddStep("Click retry button", () =>
|
||||
{
|
||||
var lastAction = pauseOverlay.OnRetry;
|
||||
pauseOverlay.OnRetry = () => triggered = true;
|
||||
AddStep("Click retry button", () => getButton(1).TriggerClick());
|
||||
|
||||
getButton(1).TriggerClick();
|
||||
pauseOverlay.OnRetry = lastAction;
|
||||
});
|
||||
|
||||
AddAssert("Action was triggered", () => triggered);
|
||||
AddAssert("Retry was triggered", () => triggeredRetryButton);
|
||||
AddAssert("Overlay is closed", () => pauseOverlay.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
@@ -252,25 +249,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
InputManager.Key(Key.Down);
|
||||
});
|
||||
|
||||
bool triggered = false;
|
||||
Action lastAction = null;
|
||||
AddStep("Press enter", () =>
|
||||
{
|
||||
lastAction = pauseOverlay.OnRetry;
|
||||
pauseOverlay.OnRetry = () => triggered = true;
|
||||
InputManager.Key(Key.Enter);
|
||||
});
|
||||
AddStep("Press enter", () => InputManager.Key(Key.Enter));
|
||||
|
||||
AddAssert("Action was triggered", () =>
|
||||
{
|
||||
if (lastAction != null)
|
||||
{
|
||||
pauseOverlay.OnRetry = lastAction;
|
||||
lastAction = null;
|
||||
}
|
||||
|
||||
return triggered;
|
||||
});
|
||||
AddAssert("Retry was triggered", () => triggeredRetryButton);
|
||||
AddAssert("Overlay is closed", () => pauseOverlay.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public partial class TestSceneGameplaySamplePlayback : PlayerTestScene
|
||||
{
|
||||
protected override bool AllowBackwardsSeeks => true;
|
||||
|
||||
private bool seek;
|
||||
|
||||
[Test]
|
||||
public void TestAllSamplesStopDuringSeek()
|
||||
{
|
||||
@@ -40,7 +44,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
if (!samples.Any(s => s.Playing))
|
||||
return false;
|
||||
|
||||
Player.ChildrenOfType<GameplayClockContainer>().First().Seek(40000);
|
||||
seek = true;
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -53,10 +57,27 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
AddAssert("sample playback still disabled", () => sampleDisabler.SamplePlaybackDisabled.Value);
|
||||
|
||||
AddStep("stop seeking", () => seek = false);
|
||||
|
||||
AddUntilStep("seek finished, sample playback enabled", () => !sampleDisabler.SamplePlaybackDisabled.Value);
|
||||
AddUntilStep("any sample is playing", () => Player.ChildrenOfType<PausableSkinnableSound>().Any(s => s.IsPlaying));
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (seek)
|
||||
{
|
||||
// Frame stable playback is too fast to catch up these days.
|
||||
//
|
||||
// We want to keep seeking while asserting various test conditions, so
|
||||
// continue to seek until we unset the flag.
|
||||
var gameplayClockContainer = Player.ChildrenOfType<GameplayClockContainer>().First();
|
||||
gameplayClockContainer.Seek(gameplayClockContainer.CurrentTime > 30000 ? 0 : 60000);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<PausableSkinnableSound> allSounds => Player.ChildrenOfType<PausableSkinnableSound>();
|
||||
private IEnumerable<PausableSkinnableSound> allLoopingSounds => allSounds.Where(sound => sound.Looping);
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public partial class TestSceneGameplaySampleTriggerSource : PlayerTestScene
|
||||
{
|
||||
protected override bool AllowBackwardsSeeks => true;
|
||||
|
||||
private TestGameplaySampleTriggerSource sampleTriggerSource = null!;
|
||||
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||
|
||||
@@ -88,7 +90,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
HitWindows = new HitWindows(),
|
||||
StartTime = t += spacing,
|
||||
Path = new SliderPath(PathType.Linear, new[] { Vector2.Zero, Vector2.UnitY * 200 }),
|
||||
Path = new SliderPath(PathType.LINEAR, new[] { Vector2.Zero, Vector2.UnitY * 200 }),
|
||||
Samples = new[] { new HitSampleInfo(HitSampleInfo.HIT_WHISTLE, HitSampleInfo.BANK_SOFT) },
|
||||
},
|
||||
});
|
||||
|
||||
@@ -6,11 +6,11 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||
|
||||
[Cached(typeof(IGameplayClock))]
|
||||
private readonly IGameplayClock gameplayClock = new GameplayClockContainer(new FramedClock());
|
||||
private readonly IGameplayClock gameplayClock = new GameplayClockContainer(new TrackVirtual(60000), false, false);
|
||||
|
||||
// best way to check without exposing.
|
||||
private Drawable hideTarget => hudOverlay.ChildrenOfType<SkinComponentsContainer>().First();
|
||||
|
||||
@@ -288,6 +288,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public override Container FrameStableComponents { get; }
|
||||
public override IFrameStableClock FrameStableClock { get; }
|
||||
internal override bool FrameStablePlayback { get; set; }
|
||||
public override bool AllowBackwardsSeeks { get; set; }
|
||||
public override IReadOnlyList<Mod> Mods { get; }
|
||||
|
||||
public override double GameplayStartTime { get; }
|
||||
|
||||
@@ -11,8 +11,8 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play.HUD.JudgementCounter;
|
||||
@@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
};
|
||||
});
|
||||
|
||||
protected override Ruleset CreateRuleset() => new ManiaRuleset();
|
||||
protected override Ruleset CreateRuleset() => new OsuRuleset();
|
||||
|
||||
private void applyOneJudgement(HitResult result)
|
||||
{
|
||||
@@ -147,6 +147,16 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("Assert max judgement hidden", () => counterDisplay.CounterFlow.ChildrenOfType<JudgementCounter>().First().Alpha == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoDuplicates()
|
||||
{
|
||||
AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay());
|
||||
AddStep("Show all judgements", () => counterDisplay.Mode.Value = JudgementCounterDisplay.DisplayMode.All);
|
||||
AddAssert("Check no duplicates",
|
||||
() => counterDisplay.CounterFlow.ChildrenOfType<JudgementCounter>().Count(),
|
||||
() => Is.EqualTo(counterDisplay.CounterFlow.ChildrenOfType<JudgementCounter>().Select(c => c.ResultName.Text).Distinct().Count()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCycleDisplayModes()
|
||||
{
|
||||
@@ -163,7 +173,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private int hiddenCount()
|
||||
{
|
||||
var num = counterDisplay.CounterFlow.Children.First(child => child.Result.Type == HitResult.LargeTickHit);
|
||||
var num = counterDisplay.CounterFlow.Children.First(child => child.Result.Types.Contains(HitResult.LargeTickHit));
|
||||
return num.Result.ResultCount.Value;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,19 +31,66 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(72.7f),
|
||||
Children = new KeyCounterDisplay[]
|
||||
Spacing = new Vector2(20),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DefaultKeyCounterDisplay
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
},
|
||||
new DefaultKeyCounterDisplay
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Scale = new Vector2(1, -1)
|
||||
},
|
||||
new ArgonKeyCounterDisplay
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
},
|
||||
new ArgonKeyCounterDisplay
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
}
|
||||
Scale = new Vector2(1, -1)
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Spacing = new Vector2(20),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DefaultKeyCounterDisplay
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Rotation = -90,
|
||||
},
|
||||
new DefaultKeyCounterDisplay
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Rotation = 90,
|
||||
},
|
||||
new ArgonKeyCounterDisplay
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Rotation = -90,
|
||||
},
|
||||
new ArgonKeyCounterDisplay
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Rotation = 90,
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -77,8 +124,15 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddStep("Disable counting", () => controller.IsCounting.Value = false);
|
||||
addPressKeyStep();
|
||||
AddAssert($"Check {testKey} count has not changed", () => testTrigger.ActivationCount.Value == 2);
|
||||
AddStep("Enable counting", () => controller.IsCounting.Value = true);
|
||||
addPressKeyStep(100);
|
||||
addPressKeyStep(1000);
|
||||
|
||||
void addPressKeyStep() => AddStep($"Press {testKey} key", () => InputManager.Key(testKey));
|
||||
void addPressKeyStep(int repeat = 1) => AddStep($"Press {testKey} key {repeat} times", () =>
|
||||
{
|
||||
for (int i = 0; i < repeat; i++)
|
||||
InputManager.Key(testKey);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
|
||||
|
||||
sprite.TimelineGroup.Alpha.Add(Easing.None, firstStoryboardEvent, firstStoryboardEvent + 500, 0, 1);
|
||||
sprite.Commands.AddAlpha(Easing.None, firstStoryboardEvent, firstStoryboardEvent + 500, 0, 1);
|
||||
|
||||
storyboard.GetLayer("Background").Add(sprite);
|
||||
|
||||
@@ -73,17 +73,17 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
|
||||
|
||||
// these should be ignored as we have an alpha visibility blocker proceeding this command.
|
||||
sprite.TimelineGroup.Scale.Add(Easing.None, loop_start_time, -18000, 0, 1);
|
||||
var loopGroup = sprite.AddLoop(loop_start_time, 50);
|
||||
loopGroup.Scale.Add(Easing.None, loop_start_time, -18000, 0, 1);
|
||||
sprite.Commands.AddScale(Easing.None, loop_start_time, -18000, 0, 1);
|
||||
var loopGroup = sprite.AddLoopingGroup(loop_start_time, 50);
|
||||
loopGroup.AddScale(Easing.None, loop_start_time, -18000, 0, 1);
|
||||
|
||||
var target = addEventToLoop ? loopGroup : sprite.TimelineGroup;
|
||||
var target = addEventToLoop ? loopGroup : sprite.Commands;
|
||||
double loopRelativeOffset = addEventToLoop ? -loop_start_time : 0;
|
||||
target.Alpha.Add(Easing.None, loopRelativeOffset + firstStoryboardEvent, loopRelativeOffset + firstStoryboardEvent + 500, 0, 1);
|
||||
target.AddAlpha(Easing.None, loopRelativeOffset + firstStoryboardEvent, loopRelativeOffset + firstStoryboardEvent + 500, 0, 1);
|
||||
|
||||
// these should be ignored due to being in the future.
|
||||
sprite.TimelineGroup.Alpha.Add(Easing.None, 18000, 20000, 0, 1);
|
||||
loopGroup.Alpha.Add(Easing.None, 38000, 40000, 0, 1);
|
||||
sprite.Commands.AddAlpha(Easing.None, 18000, 20000, 0, 1);
|
||||
loopGroup.AddAlpha(Easing.None, 38000, 40000, 0, 1);
|
||||
|
||||
storyboard.GetLayer("Background").Add(sprite);
|
||||
|
||||
|
||||
@@ -1,26 +1,109 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Notifications.WebSocket;
|
||||
using osu.Game.Online.Notifications.WebSocket.Events;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Users;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
[TestFixture]
|
||||
public partial class TestSceneMedalOverlay : OsuTestScene
|
||||
public partial class TestSceneMedalOverlay : OsuManualInputManagerTestScene
|
||||
{
|
||||
public TestSceneMedalOverlay()
|
||||
private readonly Bindable<OverlayActivation> overlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
|
||||
|
||||
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
||||
private MedalOverlay overlay = null!;
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep(@"display", () =>
|
||||
var overlayManagerMock = new Mock<IOverlayManager>();
|
||||
overlayManagerMock.Setup(mock => mock.OverlayActivationMode).Returns(overlayActivationMode);
|
||||
|
||||
AddStep("create overlay", () => Child = new DependencyProvidingContainer
|
||||
{
|
||||
LoadComponentAsync(new MedalOverlay(new Medal
|
||||
{
|
||||
Name = @"Animations",
|
||||
InternalName = @"all-intro-doubletime",
|
||||
Description = @"More complex than you think.",
|
||||
}), Add);
|
||||
Child = overlay = new MedalOverlay(),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CachedDependencies =
|
||||
[
|
||||
(typeof(IOverlayManager), overlayManagerMock.Object)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBasicAward()
|
||||
{
|
||||
awardMedal(new UserAchievementUnlock
|
||||
{
|
||||
Title = "Time And A Half",
|
||||
Description = "Having a right ol' time. One and a half of them, almost.",
|
||||
Slug = @"all-intro-doubletime"
|
||||
});
|
||||
AddUntilStep("overlay shown", () => overlay.State.Value, () => Is.EqualTo(Visibility.Visible));
|
||||
AddUntilStep("wait for load", () => this.ChildrenOfType<MedalAnimation>().Any());
|
||||
AddRepeatStep("dismiss", () => InputManager.Key(Key.Escape), 2);
|
||||
AddUntilStep("overlay hidden", () => overlay.State.Value, () => Is.EqualTo(Visibility.Hidden));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleMedalsInQuickSuccession()
|
||||
{
|
||||
awardMedal(new UserAchievementUnlock
|
||||
{
|
||||
Title = "Time And A Half",
|
||||
Description = "Having a right ol' time. One and a half of them, almost.",
|
||||
Slug = @"all-intro-doubletime"
|
||||
});
|
||||
awardMedal(new UserAchievementUnlock
|
||||
{
|
||||
Title = "S-Ranker",
|
||||
Description = "Accuracy is really underrated.",
|
||||
Slug = @"all-secret-rank-s"
|
||||
});
|
||||
awardMedal(new UserAchievementUnlock
|
||||
{
|
||||
Title = "500 Combo",
|
||||
Description = "500 big ones! You're moving up in the world!",
|
||||
Slug = @"osu-combo-500"
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDelayMedalDisplayUntilActivationModeAllowsIt()
|
||||
{
|
||||
AddStep("disable overlay activation", () => overlayActivationMode.Value = OverlayActivation.Disabled);
|
||||
awardMedal(new UserAchievementUnlock
|
||||
{
|
||||
Title = "Time And A Half",
|
||||
Description = "Having a right ol' time. One and a half of them, almost.",
|
||||
Slug = @"all-intro-doubletime"
|
||||
});
|
||||
AddUntilStep("overlay hidden", () => overlay.State.Value, () => Is.EqualTo(Visibility.Hidden));
|
||||
|
||||
AddStep("re-enable overlay activation", () => overlayActivationMode.Value = OverlayActivation.All);
|
||||
AddUntilStep("overlay shown", () => overlay.State.Value, () => Is.EqualTo(Visibility.Visible));
|
||||
}
|
||||
|
||||
private void awardMedal(UserAchievementUnlock unlock) => AddStep("award medal", () => dummyAPI.NotificationsClient.Receive(new SocketMessage
|
||||
{
|
||||
Event = @"new",
|
||||
Data = JObject.FromObject(new NewPrivateNotificationEvent
|
||||
{
|
||||
Name = @"user_achievement_unlock",
|
||||
Details = JObject.FromObject(unlock)
|
||||
})
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
@@ -31,6 +32,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private bool gameplayClockAlwaysGoingForward = true;
|
||||
private double lastForwardCheckTime;
|
||||
|
||||
public TestScenePause()
|
||||
{
|
||||
base.Content.Add(content = new GlobalCursorDisplay { RelativeSizeAxes = Axes.Both });
|
||||
@@ -67,12 +71,20 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
confirmPausedWithNoOverlay();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestForwardPlaybackGuarantee()
|
||||
{
|
||||
hookForwardPlaybackCheck();
|
||||
|
||||
AddUntilStep("wait for forward playback", () => Player.GameplayClockContainer.CurrentTime > 1000);
|
||||
AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000));
|
||||
|
||||
checkForwardPlayback();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPauseWithLargeOffset()
|
||||
{
|
||||
double lastTime;
|
||||
bool alwaysGoingForward = true;
|
||||
|
||||
AddStep("force large offset", () =>
|
||||
{
|
||||
var offset = (BindableDouble)LocalConfig.GetBindable<double>(OsuSetting.AudioOffset);
|
||||
@@ -82,24 +94,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
offset.Value = -5000;
|
||||
});
|
||||
|
||||
AddStep("add time forward check hook", () =>
|
||||
{
|
||||
lastTime = double.MinValue;
|
||||
alwaysGoingForward = true;
|
||||
|
||||
Player.OnUpdate += _ =>
|
||||
{
|
||||
double currentTime = Player.GameplayClockContainer.CurrentTime;
|
||||
bool goingForward = currentTime >= lastTime - 500;
|
||||
|
||||
alwaysGoingForward &= goingForward;
|
||||
|
||||
if (!goingForward)
|
||||
Logger.Log($"Backwards time occurred ({currentTime:N1} -> {lastTime:N1})");
|
||||
|
||||
lastTime = currentTime;
|
||||
};
|
||||
});
|
||||
hookForwardPlaybackCheck();
|
||||
|
||||
AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)));
|
||||
|
||||
@@ -107,11 +102,37 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
resumeAndConfirm();
|
||||
|
||||
AddAssert("time didn't go too far backwards", () => alwaysGoingForward);
|
||||
checkForwardPlayback();
|
||||
|
||||
AddStep("reset offset", () => LocalConfig.SetValue(OsuSetting.AudioOffset, 0.0));
|
||||
}
|
||||
|
||||
private void checkForwardPlayback() => AddAssert("time didn't go too far backwards", () => gameplayClockAlwaysGoingForward);
|
||||
|
||||
private void hookForwardPlaybackCheck()
|
||||
{
|
||||
AddStep("add time forward check hook", () =>
|
||||
{
|
||||
lastForwardCheckTime = double.MinValue;
|
||||
gameplayClockAlwaysGoingForward = true;
|
||||
|
||||
Player.OnUpdate += _ =>
|
||||
{
|
||||
var frameStableClock = Player.ChildrenOfType<FrameStabilityContainer>().Single().Clock;
|
||||
|
||||
double currentTime = frameStableClock.CurrentTime;
|
||||
|
||||
bool goingForward = currentTime >= lastForwardCheckTime;
|
||||
lastForwardCheckTime = currentTime;
|
||||
|
||||
gameplayClockAlwaysGoingForward &= goingForward;
|
||||
|
||||
if (!goingForward)
|
||||
Logger.Log($"Went too far backwards (last stop: {lastForwardCheckTime:N1} current: {currentTime:N1})");
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPauseResume()
|
||||
{
|
||||
@@ -121,7 +142,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
resumeAndConfirm();
|
||||
|
||||
AddAssert("Resumed without seeking forward", () => Player.LastResumeTime, () => Is.LessThanOrEqualTo(Player.LastPauseTime));
|
||||
AddAssert("continued playing forward", () => Player.LastResumeTime, () => Is.GreaterThanOrEqualTo(Player.LastPauseTime));
|
||||
|
||||
AddUntilStep("player playing", () => Player.LocalUserPlaying.Value);
|
||||
}
|
||||
|
||||
@@ -3,102 +3,89 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK;
|
||||
using osu.Game.Skinning.Triangles;
|
||||
using osu.Game.Tests.Gameplay;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public partial class TestScenePerformancePointsCounter : OsuTestScene
|
||||
public partial class TestScenePerformancePointsCounter : SkinnableHUDComponentTestScene
|
||||
{
|
||||
private DependencyProvidingContainer dependencyContainer;
|
||||
[Cached(typeof(ScoreProcessor))]
|
||||
private readonly ScoreProcessor scoreProcessor = new OsuScoreProcessor();
|
||||
|
||||
private GameplayState gameplayState;
|
||||
private ScoreProcessor scoreProcessor;
|
||||
[Cached]
|
||||
private readonly GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||
|
||||
private int iteration;
|
||||
private Bindable<JudgementResult> lastJudgementResult = new Bindable<JudgementResult>();
|
||||
private PerformancePointsCounter counter;
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps() => AddStep("create components", () =>
|
||||
protected override Drawable CreateDefaultImplementation() => new TrianglesPerformancePointsCounter();
|
||||
protected override Drawable CreateArgonImplementation() => new ArgonPerformancePointsCounter();
|
||||
protected override Drawable CreateLegacyImplementation() => Empty();
|
||||
|
||||
private Bindable<JudgementResult> lastJudgementResult => (Bindable<JudgementResult>)gameplayState.LastJudgementResult;
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
var ruleset = CreateRuleset();
|
||||
|
||||
Debug.Assert(ruleset != null);
|
||||
|
||||
var beatmap = CreateWorkingBeatmap(ruleset.RulesetInfo)
|
||||
.GetPlayableBeatmap(ruleset.RulesetInfo);
|
||||
|
||||
lastJudgementResult = new Bindable<JudgementResult>();
|
||||
|
||||
gameplayState = new GameplayState(beatmap, ruleset);
|
||||
gameplayState.LastJudgementResult.BindTo(lastJudgementResult);
|
||||
|
||||
scoreProcessor = new ScoreProcessor(ruleset);
|
||||
|
||||
Child = dependencyContainer = new DependencyProvidingContainer
|
||||
AddStep("reset", () =>
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CachedDependencies = new (Type, object)[]
|
||||
{
|
||||
(typeof(GameplayState), gameplayState),
|
||||
(typeof(ScoreProcessor), scoreProcessor)
|
||||
}
|
||||
};
|
||||
var ruleset = new OsuRuleset();
|
||||
var beatmap = CreateWorkingBeatmap(ruleset.RulesetInfo)
|
||||
.GetPlayableBeatmap(ruleset.RulesetInfo);
|
||||
|
||||
iteration = 0;
|
||||
});
|
||||
iteration = 0;
|
||||
scoreProcessor.ApplyBeatmap(beatmap);
|
||||
lastJudgementResult.SetDefault();
|
||||
});
|
||||
|
||||
protected override Ruleset CreateRuleset() => new OsuRuleset();
|
||||
base.SetUpSteps();
|
||||
}
|
||||
|
||||
private void createCounter() => AddStep("Create counter", () =>
|
||||
[Test]
|
||||
public void TestDisplay()
|
||||
{
|
||||
dependencyContainer.Child = counter = new PerformancePointsCounter
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(5),
|
||||
};
|
||||
});
|
||||
AddSliderStep("pp", 0, 2000, 0, v => this.ChildrenOfType<PerformancePointsCounter>().ForEach(c => c.Current.Value = v));
|
||||
AddToggleStep("toggle validity", v => this.ChildrenOfType<PerformancePointsCounter>().ForEach(c => c.IsValid = v));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBasicCounting()
|
||||
{
|
||||
int previousValue = 0;
|
||||
createCounter();
|
||||
|
||||
AddAssert("counter displaying zero", () => counter.Current.Value == 0);
|
||||
AddAssert("counter displaying zero", () => this.ChildrenOfType<PerformancePointsCounter>().All(c => c.Current.Value == 0));
|
||||
|
||||
AddRepeatStep("Add judgement", applyOneJudgement, 10);
|
||||
|
||||
AddUntilStep("counter non-zero", () => counter.Current.Value > 0);
|
||||
AddUntilStep("counter opaque", () => counter.Child.Alpha == 1);
|
||||
AddUntilStep("counter non-zero", () => this.ChildrenOfType<PerformancePointsCounter>().All(c => c.Current.Value > 0));
|
||||
AddUntilStep("counter valid", () => this.ChildrenOfType<PerformancePointsCounter>().All(c => c.IsValid));
|
||||
|
||||
AddStep("Revert judgement", () =>
|
||||
{
|
||||
previousValue = counter.Current.Value;
|
||||
previousValue = this.ChildrenOfType<PerformancePointsCounter>().First().Current.Value;
|
||||
|
||||
scoreProcessor.RevertResult(new JudgementResult(new HitObject(), new OsuJudgement()));
|
||||
});
|
||||
|
||||
AddUntilStep("counter decreased", () => counter.Current.Value < previousValue);
|
||||
AddUntilStep("counter decreased", () => this.ChildrenOfType<PerformancePointsCounter>().All(c => c.Current.Value < previousValue));
|
||||
|
||||
AddStep("Add judgement", applyOneJudgement);
|
||||
|
||||
AddUntilStep("counter non-zero", () => counter.Current.Value > 0);
|
||||
AddUntilStep("counter non-zero", () => this.ChildrenOfType<PerformancePointsCounter>().All(c => c.Current.Value > 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -106,10 +93,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
AddRepeatStep("Add judgement", applyOneJudgement, 10);
|
||||
|
||||
createCounter();
|
||||
AddStep("recreate counter", SetUpComponents);
|
||||
|
||||
AddUntilStep("counter non-zero", () => counter.Current.Value > 0);
|
||||
AddUntilStep("counter opaque", () => counter.Child.Alpha == 1);
|
||||
AddUntilStep("counter non-zero", () => this.ChildrenOfType<PerformancePointsCounter>().All(c => c.Current.Value > 0));
|
||||
AddUntilStep("counter valid", () => this.ChildrenOfType<PerformancePointsCounter>().All(c => c.IsValid));
|
||||
}
|
||||
|
||||
private void applyOneJudgement()
|
||||
|
||||
@@ -13,10 +13,10 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
@@ -25,9 +25,11 @@ using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
@@ -37,7 +39,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
private TestPlayerLoader loader;
|
||||
private TestPlayer player;
|
||||
|
||||
private bool epilepsyWarning;
|
||||
private bool? epilepsyWarning;
|
||||
private BeatmapOnlineStatus? onlineStatus;
|
||||
|
||||
[Resolved]
|
||||
private AudioManager audioManager { get; set; }
|
||||
@@ -54,6 +57,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Cached]
|
||||
private readonly VolumeOverlay volumeOverlay;
|
||||
|
||||
[Cached]
|
||||
private readonly OsuLogo logo;
|
||||
|
||||
[Cached(typeof(BatteryInfo))]
|
||||
private readonly LocalBatteryInfo batteryInfo = new LocalBatteryInfo();
|
||||
|
||||
@@ -77,12 +83,24 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
},
|
||||
changelogOverlay = new ChangelogOverlay()
|
||||
changelogOverlay = new ChangelogOverlay(),
|
||||
logo = new OsuLogo
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Scale = new Vector2(0.5f),
|
||||
Position = new Vector2(128f),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() => player = null);
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
player = null;
|
||||
epilepsyWarning = null;
|
||||
onlineStatus = null;
|
||||
});
|
||||
|
||||
[SetUpSteps]
|
||||
public override void SetUpSteps()
|
||||
@@ -119,8 +137,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
// Add intro time to test quick retry skipping (TestQuickRetry).
|
||||
workingBeatmap.BeatmapInfo.AudioLeadIn = 60000;
|
||||
|
||||
// Turn on epilepsy warning to test warning display (TestEpilepsyWarning).
|
||||
workingBeatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning;
|
||||
// Set up data for testing disclaimer display.
|
||||
workingBeatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning ?? false;
|
||||
workingBeatmap.BeatmapInfo.Status = onlineStatus ?? BeatmapOnlineStatus.Ranked;
|
||||
|
||||
Beatmap.Value = workingBeatmap;
|
||||
|
||||
@@ -205,6 +224,36 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddUntilStep("loads after idle", () => !loader.IsCurrentScreen());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLoadNotBlockedOnOsuLogo()
|
||||
{
|
||||
AddStep("load dummy beatmap", () => resetPlayer(false));
|
||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||
|
||||
AddUntilStep("wait for load ready", () =>
|
||||
{
|
||||
moveMouse();
|
||||
return player?.LoadState == LoadState.Ready;
|
||||
});
|
||||
|
||||
// move mouse in logo while waiting for load to still proceed (it shouldn't be blocked when hovering logo).
|
||||
AddUntilStep("move mouse in logo", () =>
|
||||
{
|
||||
moveMouse();
|
||||
return !loader.IsCurrentScreen();
|
||||
});
|
||||
|
||||
void moveMouse()
|
||||
{
|
||||
notificationOverlay.State.Value = Visibility.Hidden;
|
||||
|
||||
InputManager.MoveMouseTo(
|
||||
logo.ScreenSpaceDrawQuad.TopLeft
|
||||
+ (logo.ScreenSpaceDrawQuad.BottomRight - logo.ScreenSpaceDrawQuad.TopLeft)
|
||||
* RNG.NextSingle(0.3f, 0.7f));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLoadContinuation()
|
||||
{
|
||||
@@ -265,15 +314,23 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMutedNotificationMasterVolume()
|
||||
public void TestMutedNotificationLowMusicVolume()
|
||||
{
|
||||
addVolumeSteps("master volume", () => audioManager.Volume.Value = 0, () => audioManager.Volume.Value == 0.5);
|
||||
addVolumeSteps("master and music volumes", () =>
|
||||
{
|
||||
audioManager.Volume.Value = 0.6;
|
||||
audioManager.VolumeTrack.Value = 0.01;
|
||||
}, () => Precision.AlmostEquals(audioManager.Volume.Value, 0.6) && Precision.AlmostEquals(audioManager.VolumeTrack.Value, 0.5));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMutedNotificationTrackVolume()
|
||||
public void TestMutedNotificationLowMasterVolume()
|
||||
{
|
||||
addVolumeSteps("music volume", () => audioManager.VolumeTrack.Value = 0, () => audioManager.VolumeTrack.Value == 0.5);
|
||||
addVolumeSteps("master and music volumes", () =>
|
||||
{
|
||||
audioManager.Volume.Value = 0.01;
|
||||
audioManager.VolumeTrack.Value = 0.6;
|
||||
}, () => Precision.AlmostEquals(audioManager.Volume.Value, 0.5) && Precision.AlmostEquals(audioManager.VolumeTrack.Value, 0.6));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -282,9 +339,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
addVolumeSteps("mute button", () =>
|
||||
{
|
||||
// Importantly, in the case the volume is muted but the user has a volume level set, it should be retained.
|
||||
audioManager.VolumeTrack.Value = 0.5f;
|
||||
audioManager.Volume.Value = 0.5;
|
||||
audioManager.VolumeTrack.Value = 0.5;
|
||||
volumeOverlay.IsMuted.Value = true;
|
||||
}, () => !volumeOverlay.IsMuted.Value && audioManager.VolumeTrack.Value == 0.5f);
|
||||
}, () => !volumeOverlay.IsMuted.Value && audioManager.Volume.Value == 0.5 && audioManager.VolumeTrack.Value == 0.5);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
@@ -326,13 +384,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||
|
||||
AddAssert($"epilepsy warning {(warning ? "present" : "absent")}", () => (getWarning() != null) == warning);
|
||||
|
||||
if (warning)
|
||||
{
|
||||
AddUntilStep("sound volume decreased", () => Beatmap.Value.Track.AggregateVolume.Value == 0.25);
|
||||
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
|
||||
}
|
||||
AddAssert($"epilepsy warning {(warning ? "present" : "absent")}", () => this.ChildrenOfType<PlayerLoaderDisclaimer>().Count(), () => Is.EqualTo(warning ? 1 : 0));
|
||||
|
||||
restoreVolumes();
|
||||
}
|
||||
@@ -349,30 +401,45 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||
|
||||
AddUntilStep("epilepsy warning absent", () => getWarning() == null);
|
||||
AddUntilStep("epilepsy warning absent", () => this.ChildrenOfType<PlayerLoaderDisclaimer>().Single().Alpha, () => Is.Zero);
|
||||
|
||||
restoreVolumes();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEpilepsyWarningEarlyExit()
|
||||
[TestCase(BeatmapOnlineStatus.Loved, 1)]
|
||||
[TestCase(BeatmapOnlineStatus.Qualified, 1)]
|
||||
[TestCase(BeatmapOnlineStatus.Graveyard, 0)]
|
||||
public void TestStatusWarning(BeatmapOnlineStatus status, int expectedDisclaimerCount)
|
||||
{
|
||||
saveVolumes();
|
||||
setFullVolume();
|
||||
|
||||
AddStep("enable storyboards", () => config.SetValue(OsuSetting.ShowStoryboard, true));
|
||||
AddStep("set epilepsy warning", () => epilepsyWarning = true);
|
||||
AddStep("disable epilepsy warning", () => epilepsyWarning = false);
|
||||
AddStep("set beatmap status", () => onlineStatus = status);
|
||||
AddStep("load dummy beatmap", () => resetPlayer(false));
|
||||
|
||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||
|
||||
AddUntilStep("wait for epilepsy warning", () => getWarning().Alpha > 0);
|
||||
AddUntilStep("warning is shown", () => getWarning().State.Value == Visibility.Visible);
|
||||
AddAssert($"disclaimer count is {expectedDisclaimerCount}", () => this.ChildrenOfType<PlayerLoaderDisclaimer>().Count(), () => Is.EqualTo(expectedDisclaimerCount));
|
||||
|
||||
AddStep("exit early", () => loader.Exit());
|
||||
restoreVolumes();
|
||||
}
|
||||
|
||||
AddUntilStep("warning is hidden", () => getWarning().State.Value == Visibility.Hidden);
|
||||
AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1);
|
||||
[Test]
|
||||
public void TestCombinedWarnings()
|
||||
{
|
||||
saveVolumes();
|
||||
setFullVolume();
|
||||
|
||||
AddStep("enable storyboards", () => config.SetValue(OsuSetting.ShowStoryboard, true));
|
||||
AddStep("disable epilepsy warning", () => epilepsyWarning = true);
|
||||
AddStep("set beatmap status", () => onlineStatus = BeatmapOnlineStatus.Loved);
|
||||
AddStep("load dummy beatmap", () => resetPlayer(false));
|
||||
|
||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||
|
||||
AddAssert("disclaimer count is 2", () => this.ChildrenOfType<PlayerLoaderDisclaimer>().Count(), () => Is.EqualTo(2));
|
||||
|
||||
restoreVolumes();
|
||||
}
|
||||
@@ -471,8 +538,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddStep("click notification", () => notification.TriggerClick());
|
||||
}
|
||||
|
||||
private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault(w => w.IsAlive);
|
||||
|
||||
private partial class TestPlayerLoader : PlayerLoader
|
||||
{
|
||||
public new VisualSettings VisualSettings => base.VisualSettings;
|
||||
@@ -487,13 +552,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
}
|
||||
}
|
||||
|
||||
private class TestMod : Mod, IApplicableToScoreProcessor
|
||||
private class TestMod : OsuModDoubleTime, IApplicableToScoreProcessor
|
||||
{
|
||||
public override string Name => string.Empty;
|
||||
public override string Acronym => string.Empty;
|
||||
public override double ScoreMultiplier => 1;
|
||||
public override LocalisableString Description => string.Empty;
|
||||
|
||||
public bool Applied { get; private set; }
|
||||
|
||||
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
@@ -14,6 +15,9 @@ using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@@ -25,6 +29,7 @@ using osu.Game.Screens;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Users;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
@@ -36,6 +41,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private BeatmapSetInfo? importedSet;
|
||||
|
||||
[Resolved]
|
||||
private OsuGameBase osu { get; set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, AudioManager audio)
|
||||
{
|
||||
@@ -97,6 +105,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
DateTimeOffset? getLastPlayed() => Realm.Run(r => r.Find<BeatmapInfo>(Beatmap.Value.BeatmapInfo.ID)?.LastPlayed);
|
||||
|
||||
AddStep("reset last played", () => Realm.Write(r => r.Find<BeatmapInfo>(Beatmap.Value.BeatmapInfo.ID)!.LastPlayed = null));
|
||||
AddAssert("last played is null", () => getLastPlayed() == null);
|
||||
|
||||
CreateTest();
|
||||
@@ -129,8 +138,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddUntilStep("results displayed", () => Player.GetChildScreen() is ResultsScreen);
|
||||
|
||||
// Player creates new instance of mods after gameplay to ensure any runtime references to drawables etc. are not retained.
|
||||
AddAssert("results screen score has copied mods", () => (Player.GetChildScreen() as ResultsScreen)?.Score.Mods.First(), () => Is.Not.SameAs(playerMods.First()));
|
||||
AddAssert("results screen score has matching", () => (Player.GetChildScreen() as ResultsScreen)?.Score.Mods.First(), () => Is.EqualTo(playerMods.First()));
|
||||
AddAssert("results screen score has copied mods", () => (Player.GetChildScreen() as ResultsScreen)?.Score?.Mods.First(), () => Is.Not.SameAs(playerMods.First()));
|
||||
AddAssert("results screen score has matching", () => (Player.GetChildScreen() as ResultsScreen)?.Score?.Mods.First(), () => Is.EqualTo(playerMods.First()));
|
||||
|
||||
AddUntilStep("score in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null));
|
||||
AddUntilStep("databased score has correct mods", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID))!.Mods.First(), () => Is.EqualTo(playerMods.First()));
|
||||
@@ -147,6 +156,45 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
AddUntilStep("results displayed", () => Player.GetChildScreen() is ResultsScreen);
|
||||
AddUntilStep("score in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null));
|
||||
AddUntilStep("score has correct version", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID)!.ClientVersion), () => Is.EqualTo(osu.Version));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGuestScoreIsStoredAsGuest()
|
||||
{
|
||||
AddStep("set up API", () => ((DummyAPIAccess)API).HandleRequest = req =>
|
||||
{
|
||||
switch (req)
|
||||
{
|
||||
case GetUserRequest userRequest:
|
||||
userRequest.TriggerSuccess(new APIUser
|
||||
{
|
||||
Username = "Guest",
|
||||
CountryCode = CountryCode.JP,
|
||||
Id = 1234
|
||||
});
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("log out", () => API.Logout());
|
||||
CreateTest();
|
||||
|
||||
AddUntilStep("wait for track to start running", () => Beatmap.Value.Track.IsRunning);
|
||||
AddStep("log back in", () =>
|
||||
{
|
||||
API.Login("username", "password");
|
||||
((DummyAPIAccess)API).AuthenticateSecondFactor("abcdefgh");
|
||||
});
|
||||
|
||||
AddStep("seek to completion", () => Player.GameplayClockContainer.Seek(Player.DrawableRuleset.Objects.Last().GetEndTime()));
|
||||
|
||||
AddUntilStep("results displayed", () => Player.GetChildScreen() is ResultsScreen);
|
||||
AddUntilStep("score in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null));
|
||||
AddAssert("score is not associated with online user", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID))!.UserID == APIUser.SYSTEM_USER_ID);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -173,11 +221,19 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
string? filePath = null;
|
||||
|
||||
// Files starting with _ are temporary, created by CreateFileSafely call.
|
||||
AddUntilStep("wait for export file", () => filePath = LocalStorage.GetFiles("exports").SingleOrDefault(f => !f.StartsWith("_", StringComparison.Ordinal)), () => Is.Not.Null);
|
||||
AddAssert("filesize is non-zero", () =>
|
||||
AddUntilStep("wait for export file", () => filePath = LocalStorage.GetFiles("exports").SingleOrDefault(f => !Path.GetFileName(f).StartsWith("_", StringComparison.Ordinal)), () => Is.Not.Null);
|
||||
AddUntilStep("filesize is non-zero", () =>
|
||||
{
|
||||
using (var stream = LocalStorage.GetStream(filePath))
|
||||
return stream.Length;
|
||||
try
|
||||
{
|
||||
using (var stream = LocalStorage.GetStream(filePath))
|
||||
return stream.Length;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
// file move may still be in progress.
|
||||
return 0;
|
||||
}
|
||||
}, () => Is.Not.Zero);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Skinning;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
/// <summary>
|
||||
/// Upscales all gameplay sprites by a huge amount, to aid in manually checking skin texture size limits
|
||||
/// on individual elements.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The HUD is hidden as it does't really affect game balance if HUD elements are larger than they should be.
|
||||
/// </remarks>
|
||||
[Ignore("This test is for visual testing, and has no value in being run in standard CI runs.")]
|
||||
public partial class TestScenePlayerMaxDimensions : TestSceneAllRulesetPlayers
|
||||
{
|
||||
// scale textures to 4 times their size.
|
||||
private const int scale_factor = 4;
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
|
||||
// for now this only applies to legacy skins, as modern skins don't have texture-based gameplay elements yet.
|
||||
dependencies.CacheAs<ISkinSource>(new UpscaledLegacySkin(dependencies.Get<SkinManager>()));
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
protected override void AddCheckSteps()
|
||||
{
|
||||
}
|
||||
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
var player = base.CreatePlayer(ruleset);
|
||||
player.OnLoadComplete += _ =>
|
||||
{
|
||||
// this test scene focuses on gameplay elements, so let's hide the hud.
|
||||
var hudOverlay = player.ChildrenOfType<HUDOverlay>().Single();
|
||||
hudOverlay.ShowHud.Value = false;
|
||||
hudOverlay.ShowHud.Disabled = true;
|
||||
};
|
||||
return player;
|
||||
}
|
||||
|
||||
private class UpscaledLegacySkin : DefaultLegacySkin, ISkinSource
|
||||
{
|
||||
public UpscaledLegacySkin(IStorageResourceProvider resources)
|
||||
: base(resources)
|
||||
{
|
||||
}
|
||||
|
||||
public event Action? SourceChanged
|
||||
{
|
||||
add { }
|
||||
remove { }
|
||||
}
|
||||
|
||||
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => this;
|
||||
public IEnumerable<ISkin> AllSources => new[] { this };
|
||||
|
||||
protected override IResourceStore<TextureUpload> CreateTextureLoaderStore(IStorageResourceProvider resources, IResourceStore<byte[]> storage)
|
||||
=> new UpscaledTextureLoaderStore(base.CreateTextureLoaderStore(resources, storage));
|
||||
|
||||
private class UpscaledTextureLoaderStore : IResourceStore<TextureUpload>
|
||||
{
|
||||
private readonly IResourceStore<TextureUpload>? textureStore;
|
||||
|
||||
public UpscaledTextureLoaderStore(IResourceStore<TextureUpload>? textureStore)
|
||||
{
|
||||
this.textureStore = textureStore;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
textureStore?.Dispose();
|
||||
}
|
||||
|
||||
public TextureUpload Get(string name)
|
||||
{
|
||||
var textureUpload = textureStore?.Get(name);
|
||||
|
||||
// NRT not enabled on framework side classes (IResourceStore / TextureLoaderStore), welp.
|
||||
if (textureUpload == null)
|
||||
return null!;
|
||||
|
||||
return upscale(textureUpload);
|
||||
}
|
||||
|
||||
public async Task<TextureUpload> GetAsync(string name, CancellationToken cancellationToken = new CancellationToken())
|
||||
{
|
||||
// NRT not enabled on framework side classes (IResourceStore / TextureLoaderStore), welp.
|
||||
if (textureStore == null)
|
||||
return null!;
|
||||
|
||||
var textureUpload = await textureStore.GetAsync(name, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (textureUpload == null)
|
||||
return null!;
|
||||
|
||||
return await Task.Run(() => upscale(textureUpload), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private TextureUpload upscale(TextureUpload textureUpload)
|
||||
{
|
||||
var image = Image.LoadPixelData(textureUpload.Data, textureUpload.Width, textureUpload.Height);
|
||||
|
||||
// The original texture upload will no longer be returned or used.
|
||||
textureUpload.Dispose();
|
||||
|
||||
image.Mutate(i => i.Resize(new Size(textureUpload.Width, textureUpload.Height) * scale_factor));
|
||||
return new TextureUpload(image);
|
||||
}
|
||||
|
||||
public Stream? GetStream(string name) => textureStore?.GetStream(name);
|
||||
|
||||
public IEnumerable<string> GetAvailableResources() => textureStore?.GetAvailableResources() ?? Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,15 @@ using osu.Game.Online.Rooms;
|
||||
using osu.Game.Online.Solo;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Rulesets.Taiko.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
@@ -34,12 +37,19 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private Func<RulesetInfo, IBeatmap> createCustomBeatmap;
|
||||
private Func<Ruleset> createCustomRuleset;
|
||||
private Func<Mod[]> createCustomMods;
|
||||
|
||||
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
||||
|
||||
protected override bool HasCustomSteps => true;
|
||||
|
||||
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new FakeImportingPlayer(false);
|
||||
protected override TestPlayer CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
if (createCustomMods != null)
|
||||
SelectedMods.Value = SelectedMods.Value.Concat(createCustomMods()).ToList();
|
||||
|
||||
return new FakeImportingPlayer(false);
|
||||
}
|
||||
|
||||
protected new FakeImportingPlayer Player => (FakeImportingPlayer)base.Player;
|
||||
|
||||
@@ -179,7 +189,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
addFakeHit();
|
||||
|
||||
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
|
||||
AddStep("exit", () => Player.Exit());
|
||||
|
||||
AddUntilStep("wait for submission", () => Player.SubmittedScore != null);
|
||||
AddAssert("ensure failing submission", () => Player.SubmittedScore.ScoreInfo.Passed == false);
|
||||
@@ -278,13 +287,28 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("ensure no submission", () => Player.SubmittedScore == null);
|
||||
}
|
||||
|
||||
private void createPlayerTest(bool allowFail = false, Func<RulesetInfo, IBeatmap> createBeatmap = null, Func<Ruleset> createRuleset = null)
|
||||
[Test]
|
||||
public void TestNoSubmissionWithModsOfDifferentRuleset()
|
||||
{
|
||||
prepareTestAPI(true);
|
||||
|
||||
createPlayerTest(createRuleset: () => new OsuRuleset(), createMods: () => new Mod[] { new TaikoModHidden() });
|
||||
|
||||
AddUntilStep("wait for token request", () => Player.TokenCreationRequested);
|
||||
AddAssert("gameplay not loaded", () => Player.DrawableRuleset == null);
|
||||
|
||||
AddStep("exit", () => Player.Exit());
|
||||
AddAssert("ensure no submission", () => Player.SubmittedScore == null);
|
||||
}
|
||||
|
||||
private void createPlayerTest(bool allowFail = false, Func<RulesetInfo, IBeatmap> createBeatmap = null, Func<Ruleset> createRuleset = null, Func<Mod[]> createMods = null)
|
||||
{
|
||||
CreateTest(() => AddStep("set up requirements", () =>
|
||||
{
|
||||
this.allowFail = allowFail;
|
||||
createCustomBeatmap = createBeatmap;
|
||||
createCustomRuleset = createRuleset;
|
||||
createCustomMods = createMods;
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -360,6 +384,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AllowImportCompletion = new SemaphoreSlim(1);
|
||||
}
|
||||
|
||||
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart)
|
||||
{
|
||||
ShouldValidatePlaybackRate = false,
|
||||
};
|
||||
|
||||
protected override async Task ImportScore(Score score)
|
||||
{
|
||||
ScoreImportStarted = true;
|
||||
|
||||
@@ -269,6 +269,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
drawableRuleset = (TestDrawablePoolingRuleset)ruleset.CreateDrawableRulesetWith(CreateWorkingBeatmap(beatmap).GetPlayableBeatmap(ruleset.RulesetInfo));
|
||||
drawableRuleset.FrameStablePlayback = true;
|
||||
drawableRuleset.AllowBackwardsSeeks = true;
|
||||
drawableRuleset.PoolSize = poolSize;
|
||||
|
||||
Child = new Container
|
||||
@@ -431,7 +432,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (timeOffset > HitObject.Duration)
|
||||
ApplyResult(r => r.Type = r.Judgement.MaxResult);
|
||||
ApplyMaxResult();
|
||||
}
|
||||
|
||||
protected override void UpdateHitStateTransforms(ArmedState state)
|
||||
@@ -468,7 +469,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public override void OnKilled()
|
||||
{
|
||||
base.OnKilled();
|
||||
ApplyResult(r => r.Type = r.Judgement.MinResult);
|
||||
ApplyMinResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,7 +548,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
base.CheckForResult(userTriggered, timeOffset);
|
||||
if (timeOffset >= 0)
|
||||
ApplyResult(r => r.Type = r.Judgement.MaxResult);
|
||||
ApplyMaxResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,7 +597,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
base.CheckForResult(userTriggered, timeOffset);
|
||||
if (timeOffset >= 0)
|
||||
ApplyResult(r => r.Type = r.Judgement.MaxResult);
|
||||
ApplyMaxResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
OnlineID = hasOnlineId ? online_score_id : 0,
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
BeatmapInfo = beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First(),
|
||||
Hash = replayAvailable ? "online" : string.Empty,
|
||||
HasOnlineReplay = replayAvailable,
|
||||
User = new APIUser
|
||||
{
|
||||
Id = 39828,
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
playbackManager?.ReplayInputHandler.SetFrameFromTime(Time.Current - 100);
|
||||
playbackManager?.ReplayInputHandler?.SetFrameFromTime(Time.Current - 100);
|
||||
}
|
||||
|
||||
[TearDownSteps]
|
||||
@@ -220,7 +220,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public partial class TestInputConsumer : CompositeDrawable, IKeyBindingHandler<TestAction>
|
||||
{
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent.ReceivePositionalInputAt(screenSpacePos);
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent!.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
private readonly Box box;
|
||||
|
||||
|
||||
@@ -1,499 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring.Legacy;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public partial class TestSceneScoring : OsuTestScene
|
||||
{
|
||||
private GraphContainer graphs = null!;
|
||||
private SettingsSlider<int> sliderMaxCombo = null!;
|
||||
|
||||
private FillFlowContainer legend = null!;
|
||||
|
||||
[Test]
|
||||
public void TestBasic()
|
||||
{
|
||||
AddStep("setup tests", () =>
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(),
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
graphs = new GraphContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
legend = new FillFlowContainer
|
||||
{
|
||||
Padding = new MarginPadding(20),
|
||||
Direction = FillDirection.Full,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
},
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
Padding = new MarginPadding(20),
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Full,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
sliderMaxCombo = new SettingsSlider<int>
|
||||
{
|
||||
Width = 0.5f,
|
||||
TransferValueOnCommit = true,
|
||||
Current = new BindableInt(1024)
|
||||
{
|
||||
MinValue = 96,
|
||||
MaxValue = 8192,
|
||||
},
|
||||
LabelText = "max combo",
|
||||
},
|
||||
new OsuTextFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.5f,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Text = $"Left click to add miss\nRight click to add OK/{base_ok}"
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
sliderMaxCombo.Current.BindValueChanged(_ => rerun());
|
||||
|
||||
graphs.MissLocations.BindCollectionChanged((_, __) => rerun());
|
||||
graphs.NonPerfectLocations.BindCollectionChanged((_, __) => rerun());
|
||||
|
||||
graphs.MaxCombo.BindTo(sliderMaxCombo.Current);
|
||||
|
||||
rerun();
|
||||
});
|
||||
}
|
||||
|
||||
private const int base_great = 300;
|
||||
private const int base_ok = 100;
|
||||
|
||||
private void rerun()
|
||||
{
|
||||
graphs.Clear();
|
||||
legend.Clear();
|
||||
|
||||
runForProcessor("lazer-standardised", Color4.YellowGreen, new OsuScoreProcessor(), ScoringMode.Standardised);
|
||||
runForProcessor("lazer-classic", Color4.MediumPurple, new OsuScoreProcessor(), ScoringMode.Classic);
|
||||
|
||||
runScoreV1();
|
||||
runScoreV2();
|
||||
}
|
||||
|
||||
private void runScoreV1()
|
||||
{
|
||||
int totalScore = 0;
|
||||
int currentCombo = 0;
|
||||
|
||||
void applyHitV1(int baseScore)
|
||||
{
|
||||
if (baseScore == 0)
|
||||
{
|
||||
currentCombo = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const float score_multiplier = 1;
|
||||
|
||||
totalScore += baseScore;
|
||||
|
||||
// combo multiplier
|
||||
// ReSharper disable once PossibleLossOfFraction
|
||||
totalScore += (int)(Math.Max(0, currentCombo - 1) * (baseScore / 25 * score_multiplier));
|
||||
|
||||
currentCombo++;
|
||||
}
|
||||
|
||||
runForAlgorithm("ScoreV1 (classic)", Color4.Purple,
|
||||
() => applyHitV1(base_great),
|
||||
() => applyHitV1(base_ok),
|
||||
() => applyHitV1(0),
|
||||
() =>
|
||||
{
|
||||
// Arbitrary value chosen towards the upper range.
|
||||
const double score_multiplier = 4;
|
||||
|
||||
return (int)(totalScore * score_multiplier);
|
||||
});
|
||||
}
|
||||
|
||||
private void runScoreV2()
|
||||
{
|
||||
int maxCombo = sliderMaxCombo.Current.Value;
|
||||
|
||||
int currentCombo = 0;
|
||||
double comboPortion = 0;
|
||||
double currentBaseScore = 0;
|
||||
double maxBaseScore = 0;
|
||||
int currentHits = 0;
|
||||
|
||||
for (int i = 0; i < maxCombo; i++)
|
||||
applyHitV2(base_great);
|
||||
|
||||
double comboPortionMax = comboPortion;
|
||||
|
||||
currentCombo = 0;
|
||||
comboPortion = 0;
|
||||
currentBaseScore = 0;
|
||||
maxBaseScore = 0;
|
||||
currentHits = 0;
|
||||
|
||||
void applyHitV2(int baseScore)
|
||||
{
|
||||
maxBaseScore += base_great;
|
||||
currentBaseScore += baseScore;
|
||||
comboPortion += baseScore * (1 + ++currentCombo / 10.0);
|
||||
|
||||
currentHits++;
|
||||
}
|
||||
|
||||
runForAlgorithm("ScoreV2", Color4.OrangeRed,
|
||||
() => applyHitV2(base_great),
|
||||
() => applyHitV2(base_ok),
|
||||
() =>
|
||||
{
|
||||
currentHits++;
|
||||
maxBaseScore += base_great;
|
||||
currentCombo = 0;
|
||||
}, () =>
|
||||
{
|
||||
double accuracy = currentBaseScore / maxBaseScore;
|
||||
|
||||
return (int)Math.Round
|
||||
(
|
||||
700000 * comboPortion / comboPortionMax +
|
||||
300000 * Math.Pow(accuracy, 10) * ((double)currentHits / maxCombo)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private void runForProcessor(string name, Color4 colour, ScoreProcessor processor, ScoringMode mode)
|
||||
{
|
||||
int maxCombo = sliderMaxCombo.Current.Value;
|
||||
|
||||
var beatmap = new OsuBeatmap();
|
||||
for (int i = 0; i < maxCombo; i++)
|
||||
beatmap.HitObjects.Add(new HitCircle());
|
||||
|
||||
processor.ApplyBeatmap(beatmap);
|
||||
|
||||
runForAlgorithm(name, colour,
|
||||
() => processor.ApplyResult(new OsuJudgementResult(new HitCircle(), new OsuJudgement()) { Type = HitResult.Great }),
|
||||
() => processor.ApplyResult(new OsuJudgementResult(new HitCircle(), new OsuJudgement()) { Type = HitResult.Ok }),
|
||||
() => processor.ApplyResult(new OsuJudgementResult(new HitCircle(), new OsuJudgement()) { Type = HitResult.Miss }),
|
||||
() => processor.GetDisplayScore(mode));
|
||||
}
|
||||
|
||||
private void runForAlgorithm(string name, Color4 colour, Action applyHit, Action applyNonPerfect, Action applyMiss, Func<long> getTotalScore)
|
||||
{
|
||||
int maxCombo = sliderMaxCombo.Current.Value;
|
||||
|
||||
List<float> results = new List<float>();
|
||||
|
||||
for (int i = 0; i < maxCombo; i++)
|
||||
{
|
||||
if (graphs.MissLocations.Contains(i))
|
||||
applyMiss();
|
||||
else if (graphs.NonPerfectLocations.Contains(i))
|
||||
applyNonPerfect();
|
||||
else
|
||||
applyHit();
|
||||
|
||||
results.Add(getTotalScore());
|
||||
}
|
||||
|
||||
graphs.Add(new LineGraph
|
||||
{
|
||||
Name = name,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
LineColour = colour,
|
||||
Values = results
|
||||
});
|
||||
|
||||
legend.Add(new OsuSpriteText
|
||||
{
|
||||
Colour = colour,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.5f,
|
||||
Text = $"{FontAwesome.Solid.Circle.Icon} {name}"
|
||||
});
|
||||
|
||||
legend.Add(new OsuSpriteText
|
||||
{
|
||||
Colour = colour,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.5f,
|
||||
Text = $"final score {getTotalScore():#,0}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public partial class GraphContainer : Container, IHasCustomTooltip<IEnumerable<LineGraph>>
|
||||
{
|
||||
public readonly BindableList<double> MissLocations = new BindableList<double>();
|
||||
public readonly BindableList<double> NonPerfectLocations = new BindableList<double>();
|
||||
|
||||
public Bindable<int> MaxCombo = new Bindable<int>();
|
||||
|
||||
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
private readonly Box hoverLine;
|
||||
|
||||
private readonly Container missLines;
|
||||
private readonly Container verticalGridLines;
|
||||
|
||||
public int CurrentHoverCombo { get; private set; }
|
||||
|
||||
public GraphContainer()
|
||||
{
|
||||
InternalChild = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = OsuColour.Gray(0.1f),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
verticalGridLines = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
hoverLine = new Box
|
||||
{
|
||||
Colour = Color4.Yellow,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Origin = Anchor.TopCentre,
|
||||
Alpha = 0,
|
||||
Width = 1,
|
||||
},
|
||||
missLines = new Container
|
||||
{
|
||||
Alpha = 0.6f,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
Content,
|
||||
}
|
||||
};
|
||||
|
||||
MissLocations.BindCollectionChanged((_, _) => updateMissLocations());
|
||||
NonPerfectLocations.BindCollectionChanged((_, _) => updateMissLocations());
|
||||
|
||||
MaxCombo.BindValueChanged(_ =>
|
||||
{
|
||||
updateMissLocations();
|
||||
updateVerticalGridLines();
|
||||
}, true);
|
||||
}
|
||||
|
||||
private void updateVerticalGridLines()
|
||||
{
|
||||
verticalGridLines.Clear();
|
||||
|
||||
for (int i = 0; i < MaxCombo.Value; i++)
|
||||
{
|
||||
if (i % 100 == 0)
|
||||
{
|
||||
verticalGridLines.AddRange(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = OsuColour.Gray(0.2f),
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 1,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = (float)i / MaxCombo.Value,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = (float)i / MaxCombo.Value,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Text = $"{i:#,0}",
|
||||
Rotation = -30,
|
||||
Y = -20,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMissLocations()
|
||||
{
|
||||
missLines.Clear();
|
||||
|
||||
foreach (int miss in MissLocations)
|
||||
{
|
||||
missLines.Add(new Box
|
||||
{
|
||||
Colour = Color4.Red,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 1,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = (float)miss / MaxCombo.Value,
|
||||
});
|
||||
}
|
||||
|
||||
foreach (int miss in NonPerfectLocations)
|
||||
{
|
||||
missLines.Add(new Box
|
||||
{
|
||||
Colour = Color4.Orange,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 1,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
RelativePositionAxes = Axes.X,
|
||||
X = (float)miss / MaxCombo.Value,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
hoverLine.Show();
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
hoverLine.Hide();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
CurrentHoverCombo = (int)(e.MousePosition.X / DrawWidth * MaxCombo.Value);
|
||||
|
||||
hoverLine.X = e.MousePosition.X;
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
if (e.Button == MouseButton.Left)
|
||||
MissLocations.Add(CurrentHoverCombo);
|
||||
else
|
||||
NonPerfectLocations.Add(CurrentHoverCombo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private GraphTooltip? tooltip;
|
||||
|
||||
public ITooltip<IEnumerable<LineGraph>> GetCustomTooltip() => tooltip ??= new GraphTooltip(this);
|
||||
|
||||
public IEnumerable<LineGraph> TooltipContent => Content.OfType<LineGraph>();
|
||||
|
||||
public partial class GraphTooltip : CompositeDrawable, ITooltip<IEnumerable<LineGraph>>
|
||||
{
|
||||
private readonly GraphContainer graphContainer;
|
||||
|
||||
private readonly OsuTextFlowContainer textFlow;
|
||||
|
||||
public GraphTooltip(GraphContainer graphContainer)
|
||||
{
|
||||
this.graphContainer = graphContainer;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = 10;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = OsuColour.Gray(0.15f),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
textFlow = new OsuTextFlowContainer
|
||||
{
|
||||
Colour = Color4.White,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(10),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private int? lastContentCombo;
|
||||
|
||||
public void SetContent(IEnumerable<LineGraph> content)
|
||||
{
|
||||
int relevantCombo = graphContainer.CurrentHoverCombo;
|
||||
|
||||
if (lastContentCombo == relevantCombo)
|
||||
return;
|
||||
|
||||
lastContentCombo = relevantCombo;
|
||||
textFlow.Clear();
|
||||
|
||||
textFlow.AddParagraph($"At combo {relevantCombo}:");
|
||||
|
||||
foreach (var graph in content)
|
||||
{
|
||||
float valueAtHover = graph.Values.ElementAt(relevantCombo);
|
||||
float ofTotal = valueAtHover / graph.Values.Last();
|
||||
|
||||
textFlow.AddParagraph($"{graph.Name}: {valueAtHover:#,0} ({ofTotal * 100:N0}% of final)\n", st => st.Colour = graph.LineColour);
|
||||
}
|
||||
}
|
||||
|
||||
public void Move(Vector2 pos) => this.MoveTo(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
@@ -96,7 +97,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
AddStep("Begin drag top left", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.TopLeft - new Vector2(box1.ScreenSpaceDrawQuad.Width / 4));
|
||||
InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.TopLeft - new Vector2(box1.ScreenSpaceDrawQuad.Width / 4, box1.ScreenSpaceDrawQuad.Height / 8));
|
||||
InputManager.PressButton(MouseButton.Left);
|
||||
});
|
||||
|
||||
@@ -146,8 +147,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
AddStep("Add big black box", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(skinEditor.ChildrenOfType<BigBlackBox>().First());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
skinEditor.ChildrenOfType<SkinComponentToolbox.ToolboxComponentButton>().First(b => b.ChildrenOfType<BigBlackBox>().FirstOrDefault() != null).TriggerClick();
|
||||
});
|
||||
|
||||
AddStep("store box", () =>
|
||||
@@ -243,7 +243,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
void revertAndCheckUnchanged()
|
||||
{
|
||||
AddStep("Revert changes", () => changeHandler.RestoreState(int.MinValue));
|
||||
AddAssert("Current state is same as default", () => defaultState.SequenceEqual(changeHandler.GetCurrentState()));
|
||||
AddAssert("Current state is same as default",
|
||||
() => Encoding.UTF8.GetString(defaultState),
|
||||
() => Is.EqualTo(Encoding.UTF8.GetString(changeHandler.GetCurrentState())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,6 +335,40 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("value is less than default", () => hitErrorMeter.JudgementLineThickness.Value < hitErrorMeter.JudgementLineThickness.Default);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCopyPaste()
|
||||
{
|
||||
AddStep("paste", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LControl);
|
||||
InputManager.Key(Key.V);
|
||||
InputManager.ReleaseKey(Key.LControl);
|
||||
});
|
||||
// no assertions. just make sure nothing crashes.
|
||||
|
||||
AddStep("select bar hit error blueprint", () =>
|
||||
{
|
||||
var blueprint = skinEditor.ChildrenOfType<SkinBlueprint>().First(b => b.Item is BarHitErrorMeter);
|
||||
skinEditor.SelectedComponents.Clear();
|
||||
skinEditor.SelectedComponents.Add(blueprint.Item);
|
||||
});
|
||||
AddStep("copy", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LControl);
|
||||
InputManager.Key(Key.C);
|
||||
InputManager.ReleaseKey(Key.LControl);
|
||||
});
|
||||
AddStep("paste", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.LControl);
|
||||
InputManager.Key(Key.V);
|
||||
InputManager.ReleaseKey(Key.LControl);
|
||||
});
|
||||
AddAssert("three hit error meters present",
|
||||
() => skinEditor.ChildrenOfType<SkinBlueprint>().Count(b => b.Item is BarHitErrorMeter),
|
||||
() => Is.EqualTo(3));
|
||||
}
|
||||
|
||||
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||
|
||||
private partial class TestSkinEditorChangeHandler : SkinEditorChangeHandler
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Overlays.SkinEditor;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
@@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||
|
||||
[Cached(typeof(IGameplayClock))]
|
||||
private readonly IGameplayClock gameplayClock = new GameplayClockContainer(new FramedClock());
|
||||
private readonly IGameplayClock gameplayClock = new GameplayClockContainer(new TrackVirtual(60000), false, false);
|
||||
|
||||
[Cached]
|
||||
public readonly EditorClipboard Clipboard = new EditorClipboard();
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
@@ -17,13 +16,15 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Cached]
|
||||
private ScoreProcessor scoreProcessor = new ScoreProcessor(new OsuRuleset());
|
||||
|
||||
protected override Drawable CreateArgonImplementation() => new ArgonAccuracyCounter();
|
||||
protected override Drawable CreateDefaultImplementation() => new DefaultAccuracyCounter();
|
||||
protected override Drawable CreateLegacyImplementation() => new LegacyAccuracyCounter();
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
AddStep("Set initial accuracy", () => scoreProcessor.Accuracy.Value = 1);
|
||||
|
||||
base.SetUpSteps();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Cached]
|
||||
private ScoreProcessor scoreProcessor = new ScoreProcessor(new OsuRuleset());
|
||||
|
||||
protected override Drawable CreateArgonImplementation() => new ArgonComboCounter();
|
||||
protected override Drawable CreateDefaultImplementation() => new DefaultComboCounter();
|
||||
protected override Drawable CreateLegacyImplementation() => new LegacyComboCounter();
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
@@ -39,7 +39,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
private GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset());
|
||||
|
||||
[Cached(typeof(IGameplayClock))]
|
||||
private readonly IGameplayClock gameplayClock = new GameplayClockContainer(new FramedClock());
|
||||
private readonly IGameplayClock gameplayClock = new GameplayClockContainer(new TrackVirtual(60000), false, false);
|
||||
|
||||
private IEnumerable<HUDOverlay> hudOverlays => CreatedDrawables.OfType<HUDOverlay>();
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
@@ -19,24 +20,39 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Cached(typeof(HealthProcessor))]
|
||||
private HealthProcessor healthProcessor = new DrainingHealthProcessor(0);
|
||||
|
||||
protected override Drawable CreateDefaultImplementation() => new DefaultHealthDisplay();
|
||||
protected override Drawable CreateLegacyImplementation() => new LegacyHealthDisplay();
|
||||
protected override Drawable CreateArgonImplementation() => new ArgonHealthDisplay { Scale = new Vector2(0.6f), Width = 600, UseRelativeSize = { Value = false } };
|
||||
protected override Drawable CreateDefaultImplementation() => new DefaultHealthDisplay { Scale = new Vector2(0.6f) };
|
||||
protected override Drawable CreateLegacyImplementation() => new LegacyHealthDisplay { Scale = new Vector2(0.6f) };
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
AddStep(@"Reset all", delegate
|
||||
{
|
||||
healthProcessor.Health.Value = 1;
|
||||
healthProcessor.Failed += () => false; // health won't be updated if the processor gets into a "fail" state.
|
||||
});
|
||||
|
||||
base.SetUpSteps();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
healthProcessor.Health.Value -= 0.0001f * Time.Elapsed;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHealthDisplayIncrementing()
|
||||
{
|
||||
AddRepeatStep(@"decrease hp", delegate
|
||||
AddRepeatStep("apply miss judgement", delegate
|
||||
{
|
||||
healthProcessor.Health.Value -= 0.08f;
|
||||
healthProcessor.ApplyResult(new JudgementResult(new HitObject(), new Judgement()) { Type = HitResult.Miss });
|
||||
}, 5);
|
||||
|
||||
AddRepeatStep(@"decrease hp slightly", delegate
|
||||
{
|
||||
healthProcessor.Health.Value -= 0.01f;
|
||||
}, 10);
|
||||
|
||||
AddRepeatStep(@"increase hp without flash", delegate
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Cached(typeof(ScoreProcessor))]
|
||||
private ScoreProcessor scoreProcessor = TestGameplayState.Create(new OsuRuleset()).ScoreProcessor;
|
||||
|
||||
protected override Drawable CreateArgonImplementation() => new ArgonScoreCounter();
|
||||
protected override Drawable CreateDefaultImplementation() => new DefaultScoreCounter();
|
||||
protected override Drawable CreateLegacyImplementation() => new LegacyScoreCounter();
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
private TestSkinSourceContainer skinSource = null!;
|
||||
private PausableSkinnableSound skinnableSound = null!;
|
||||
|
||||
private const string sample_lookup = "Gameplay/normal-sliderslide";
|
||||
private const string sample_lookup = "Gameplay/Argon/normal-sliderslide";
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
|
||||
@@ -52,59 +52,68 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
}
|
||||
|
||||
[TestCase(PathType.Linear)]
|
||||
[TestCase(PathType.Bezier)]
|
||||
[TestCase(PathType.Catmull)]
|
||||
[TestCase(PathType.PerfectCurve)]
|
||||
public void TestSingleSegment(PathType type)
|
||||
=> AddStep("create path", () => path.ControlPoints.AddRange(createSegment(type, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
[TestCase(SplineType.Linear, null)]
|
||||
[TestCase(SplineType.BSpline, null)]
|
||||
[TestCase(SplineType.BSpline, 3)]
|
||||
[TestCase(SplineType.Catmull, null)]
|
||||
[TestCase(SplineType.PerfectCurve, null)]
|
||||
public void TestSingleSegment(SplineType splineType, int? degree)
|
||||
=> AddStep("create path", () => path.ControlPoints.AddRange(createSegment(
|
||||
new PathType { Type = splineType, Degree = degree },
|
||||
Vector2.Zero,
|
||||
new Vector2(0, 100),
|
||||
new Vector2(100),
|
||||
new Vector2(0, 200),
|
||||
new Vector2(200)
|
||||
)));
|
||||
|
||||
[TestCase(PathType.Linear)]
|
||||
[TestCase(PathType.Bezier)]
|
||||
[TestCase(PathType.Catmull)]
|
||||
[TestCase(PathType.PerfectCurve)]
|
||||
public void TestMultipleSegment(PathType type)
|
||||
[TestCase(SplineType.Linear, null)]
|
||||
[TestCase(SplineType.BSpline, null)]
|
||||
[TestCase(SplineType.BSpline, 3)]
|
||||
[TestCase(SplineType.Catmull, null)]
|
||||
[TestCase(SplineType.PerfectCurve, null)]
|
||||
public void TestMultipleSegment(SplineType splineType, int? degree)
|
||||
{
|
||||
AddStep("create path", () =>
|
||||
{
|
||||
path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero));
|
||||
path.ControlPoints.AddRange(createSegment(type, new Vector2(0, 100), new Vector2(100), Vector2.Zero));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero));
|
||||
path.ControlPoints.AddRange(createSegment(new PathType { Type = splineType, Degree = degree }, new Vector2(0, 100), new Vector2(100), Vector2.Zero));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddControlPoint()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100))));
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(0, 100))));
|
||||
AddStep("add point", () => path.ControlPoints.Add(new PathControlPoint { Position = new Vector2(100) }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInsertControlPoint()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(100))));
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(100))));
|
||||
AddStep("insert point", () => path.ControlPoints.Insert(1, new PathControlPoint { Position = new Vector2(0, 100) }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemoveControlPoint()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("remove second point", () => path.ControlPoints.RemoveAt(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChangePathType()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("change type to bezier", () => path.ControlPoints[0].Type = PathType.Bezier);
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("change type to bezier", () => path.ControlPoints[0].Type = PathType.BEZIER);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddSegmentByChangingType()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0))));
|
||||
AddStep("change second point type to bezier", () => path.ControlPoints[1].Type = PathType.Bezier);
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0))));
|
||||
AddStep("change second point type to bezier", () => path.ControlPoints[1].Type = PathType.BEZIER);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -112,8 +121,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
AddStep("create path", () =>
|
||||
{
|
||||
path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0)));
|
||||
path.ControlPoints[1].Type = PathType.Bezier;
|
||||
path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0)));
|
||||
path.ControlPoints[1].Type = PathType.BEZIER;
|
||||
});
|
||||
|
||||
AddStep("change second point type to null", () => path.ControlPoints[1].Type = null);
|
||||
@@ -124,8 +133,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
AddStep("create path", () =>
|
||||
{
|
||||
path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0)));
|
||||
path.ControlPoints[1].Type = PathType.Bezier;
|
||||
path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0)));
|
||||
path.ControlPoints[1].Type = PathType.BEZIER;
|
||||
});
|
||||
|
||||
AddStep("remove second point", () => path.ControlPoints.RemoveAt(1));
|
||||
@@ -140,11 +149,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
switch (points)
|
||||
{
|
||||
case 2:
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PerfectCurve, Vector2.Zero, new Vector2(0, 100)));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PERFECT_CURVE, Vector2.Zero, new Vector2(0, 100)));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PerfectCurve, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0)));
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PERFECT_CURVE, Vector2.Zero, new Vector2(0, 100), new Vector2(100), new Vector2(100, 0)));
|
||||
break;
|
||||
}
|
||||
});
|
||||
@@ -153,38 +162,69 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestLengthenLastSegment()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("lengthen last segment", () => path.ExpectedDistance.Value = 300);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShortenLastSegment()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("shorten last segment", () => path.ExpectedDistance.Value = 150);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShortenFirstSegment()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("shorten first segment", () => path.ExpectedDistance.Value = 50);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShortenToZeroLength()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("shorten to 0 length", () => path.ExpectedDistance.Value = 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShortenToNegativeLength()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.LINEAR, Vector2.Zero, new Vector2(0, 100), new Vector2(100))));
|
||||
AddStep("shorten to -10 length", () => path.ExpectedDistance.Value = -10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetSegmentEnds()
|
||||
{
|
||||
var positions = new[]
|
||||
{
|
||||
Vector2.Zero,
|
||||
new Vector2(100, 0),
|
||||
new Vector2(100),
|
||||
new Vector2(200, 100),
|
||||
};
|
||||
double[] distances = { 100d, 200d, 300d };
|
||||
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(positions.Select(p => new PathControlPoint(p, PathType.LINEAR))));
|
||||
AddAssert("segment ends are correct", () => path.GetSegmentEnds(), () => Is.EqualTo(distances.Select(d => d / 300)));
|
||||
AddAssert("segment end positions recovered", () => path.GetSegmentEnds().Select(p => path.PositionAt(p)), () => Is.EqualTo(positions.Skip(1)));
|
||||
|
||||
AddStep("lengthen last segment", () => path.ExpectedDistance.Value = 400);
|
||||
AddAssert("segment ends are correct", () => path.GetSegmentEnds(), () => Is.EqualTo(distances.Select(d => d / 400)));
|
||||
AddAssert("segment end positions recovered", () => path.GetSegmentEnds().Select(p => path.PositionAt(p)), () => Is.EqualTo(positions.Skip(1)));
|
||||
|
||||
AddStep("shorten last segment", () => path.ExpectedDistance.Value = 150);
|
||||
AddAssert("segment ends are correct", () => path.GetSegmentEnds(), () => Is.EqualTo(distances.Select(d => d / 150)));
|
||||
// see remarks in `GetSegmentEnds()` xmldoc (`SliderPath.PositionAt()` clamps progress to [0,1]).
|
||||
AddAssert("segment end positions not recovered", () => path.GetSegmentEnds().Select(p => path.PositionAt(p)), () => Is.EqualTo(new[]
|
||||
{
|
||||
positions[1],
|
||||
new Vector2(100, 50),
|
||||
new Vector2(100, 50),
|
||||
}));
|
||||
}
|
||||
|
||||
private List<PathControlPoint> createSegment(PathType type, params Vector2[] controlPoints)
|
||||
{
|
||||
var points = controlPoints.Select(p => new PathControlPoint { Position = p }).ToList();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
@@ -47,7 +48,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
Child = frameStabilityContainer = new FrameStabilityContainer
|
||||
{
|
||||
MaxCatchUpFrames = 1
|
||||
Child = new FakeLoad()
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -56,6 +57,15 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
Dependencies.CacheAs<IFrameStableClock>(frameStabilityContainer);
|
||||
}
|
||||
|
||||
private partial class FakeLoad : Drawable
|
||||
{
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetupSteps()
|
||||
{
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
@@ -12,6 +10,7 @@ using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Spectator;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
@@ -39,13 +38,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
[Resolved]
|
||||
private OsuGameBase game { get; set; }
|
||||
private OsuGameBase game { get; set; } = null!;
|
||||
|
||||
private TestSpectatorClient spectatorClient => dependenciesScreen.SpectatorClient;
|
||||
private DependenciesScreen dependenciesScreen;
|
||||
private SoloSpectator spectatorScreen;
|
||||
private DependenciesScreen dependenciesScreen = null!;
|
||||
private SoloSpectatorScreen spectatorScreen = null!;
|
||||
|
||||
private BeatmapSetInfo importedBeatmap;
|
||||
private BeatmapSetInfo importedBeatmap = null!;
|
||||
private int importedBeatmapId;
|
||||
|
||||
[SetUpSteps]
|
||||
@@ -81,7 +80,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
start();
|
||||
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
|
||||
sendFrames(startTime: gameplay_start);
|
||||
|
||||
@@ -100,23 +99,22 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
start();
|
||||
|
||||
AddUntilStep("wait for player loader", () => (Stack.CurrentScreen as PlayerLoader)?.IsLoaded == true);
|
||||
AddUntilStep("wait for player loader", () => this.ChildrenOfType<PlayerLoader>().SingleOrDefault()?.IsLoaded == true);
|
||||
|
||||
AddUntilStep("queue send frames on player load", () =>
|
||||
{
|
||||
var loadingPlayer = (Stack.CurrentScreen as PlayerLoader)?.CurrentPlayer;
|
||||
var loadingPlayer = this.ChildrenOfType<PlayerLoader>().SingleOrDefault()?.CurrentPlayer;
|
||||
|
||||
if (loadingPlayer == null)
|
||||
return false;
|
||||
|
||||
loadingPlayer.OnLoadComplete += _ =>
|
||||
{
|
||||
spectatorClient.SendFramesFromUser(streamingUser.Id, 10, gameplay_start);
|
||||
};
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
|
||||
AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
|
||||
AddAssert("time is greater than seek target", () => currentFrameStableTime, () => Is.GreaterThan(gameplay_start));
|
||||
@@ -127,10 +125,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
loadSpectatingScreen();
|
||||
|
||||
AddAssert("screen hasn't changed", () => Stack.CurrentScreen is SoloSpectator);
|
||||
AddAssert("screen hasn't changed", () => Stack.CurrentScreen is SoloSpectatorScreen);
|
||||
|
||||
start();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
|
||||
sendFrames();
|
||||
AddAssert("ensure frames arrived", () => replayHandler.HasFrames);
|
||||
@@ -156,7 +154,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
loadSpectatingScreen();
|
||||
|
||||
start();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
checkPaused(true);
|
||||
|
||||
// send enough frames to ensure play won't be paused
|
||||
@@ -172,7 +170,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
sendFrames(300);
|
||||
|
||||
loadSpectatingScreen();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
|
||||
sendFrames(300);
|
||||
|
||||
@@ -187,15 +185,15 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
start();
|
||||
sendFrames();
|
||||
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
|
||||
Player lastPlayer = null;
|
||||
Player lastPlayer = null!;
|
||||
AddStep("store first player", () => lastPlayer = player);
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
AddAssert("player is different", () => lastPlayer != player);
|
||||
}
|
||||
|
||||
@@ -206,7 +204,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
start();
|
||||
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
checkPaused(true);
|
||||
sendFrames();
|
||||
|
||||
@@ -215,6 +213,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
checkPaused(false); // Should continue playing until out of frames
|
||||
checkPaused(true); // And eventually stop after running out of frames and fail.
|
||||
// Todo: Should check for + display a failed message.
|
||||
|
||||
AddAssert("fail overlay present", () => player.ChildrenOfType<FailOverlay>().Single().IsPresent);
|
||||
AddAssert("overlay can only quit", () => player.ChildrenOfType<FailOverlay>().Single().Buttons.Single().Text == GameplayMenuOverlayStrings.Quit);
|
||||
AddStep("press quit button", () => player.ChildrenOfType<FailOverlay>().Single().Buttons.Single().TriggerClick());
|
||||
AddAssert("player exited", () => Stack.CurrentScreen is SoloSpectatorScreen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -224,7 +227,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
|
||||
AddStep("stop spectating", () => (Stack.CurrentScreen as Player)?.Exit());
|
||||
AddUntilStep("spectating stopped", () => spectatorScreen.GetChildScreen() == null);
|
||||
@@ -237,14 +240,14 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
|
||||
AddStep("stop spectating", () => (Stack.CurrentScreen as Player)?.Exit());
|
||||
AddUntilStep("spectating stopped", () => spectatorScreen.GetChildScreen() == null);
|
||||
|
||||
// host starts playing a new session
|
||||
start();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -255,7 +258,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
start(-1234);
|
||||
sendFrames();
|
||||
|
||||
AddAssert("screen didn't change", () => Stack.CurrentScreen is SoloSpectator);
|
||||
AddAssert("screen didn't change", () => Stack.CurrentScreen is SoloSpectatorScreen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -279,7 +282,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestFinalFrameInBundleHasHeader()
|
||||
{
|
||||
FrameDataBundle lastBundle = null;
|
||||
FrameDataBundle? lastBundle = null;
|
||||
|
||||
AddStep("bind to client", () => spectatorClient.OnNewFrames += (_, bundle) => lastBundle = bundle);
|
||||
|
||||
@@ -288,8 +291,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
finish();
|
||||
|
||||
AddUntilStep("bundle received", () => lastBundle != null);
|
||||
AddAssert("first frame does not have header", () => lastBundle.Frames[0].Header == null);
|
||||
AddAssert("last frame has header", () => lastBundle.Frames[^1].Header != null);
|
||||
AddAssert("first frame does not have header", () => lastBundle?.Frames[0].Header == null);
|
||||
AddAssert("last frame has header", () => lastBundle?.Frames[^1].Header != null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -299,7 +302,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
|
||||
}
|
||||
|
||||
@@ -310,14 +313,14 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
|
||||
AddStep("send passed", () => spectatorClient.SendEndPlay(streamingUser.Id, SpectatedUserState.Passed));
|
||||
AddUntilStep("state is passed", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Passed);
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
|
||||
}
|
||||
|
||||
@@ -328,44 +331,72 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
|
||||
AddStep("send quit", () => spectatorClient.SendEndPlay(streamingUser.Id));
|
||||
AddUntilStep("state is quit", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Quit);
|
||||
|
||||
AddAssert("wait for player exit", () => Stack.CurrentScreen is SoloSpectatorScreen);
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFailedState()
|
||||
public void TestFailedStateDuringPlay()
|
||||
{
|
||||
loadSpectatingScreen();
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
waitForPlayer();
|
||||
|
||||
waitForPlayerCurrent();
|
||||
|
||||
AddStep("send failed", () => spectatorClient.SendEndPlay(streamingUser.Id, SpectatedUserState.Failed));
|
||||
AddUntilStep("state is failed", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Failed);
|
||||
|
||||
AddUntilStep("wait for player to fail", () => player.GameplayState.HasFailed);
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
waitForPlayer();
|
||||
waitForPlayerCurrent();
|
||||
AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFailedStateDuringLoading()
|
||||
{
|
||||
loadSpectatingScreen();
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
|
||||
waitForPlayerLoader();
|
||||
|
||||
AddStep("send failed", () => spectatorClient.SendEndPlay(streamingUser.Id, SpectatedUserState.Failed));
|
||||
AddUntilStep("state is failed", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Failed);
|
||||
|
||||
AddAssert("wait for player exit", () => Stack.CurrentScreen is SoloSpectatorScreen);
|
||||
|
||||
start();
|
||||
sendFrames();
|
||||
waitForPlayerCurrent();
|
||||
AddUntilStep("state is playing", () => spectatorClient.WatchedUserStates[streamingUser.Id].State == SpectatedUserState.Playing);
|
||||
}
|
||||
|
||||
private OsuFramedReplayInputHandler replayHandler =>
|
||||
(OsuFramedReplayInputHandler)Stack.ChildrenOfType<OsuInputManager>().First().ReplayInputHandler;
|
||||
(OsuFramedReplayInputHandler)Stack.ChildrenOfType<OsuInputManager>().First().ReplayInputHandler!;
|
||||
|
||||
private Player player => Stack.CurrentScreen as Player;
|
||||
private Player player => this.ChildrenOfType<Player>().Single();
|
||||
|
||||
private double currentFrameStableTime
|
||||
=> player.ChildrenOfType<FrameStabilityContainer>().First().CurrentTime;
|
||||
|
||||
private void waitForPlayer() => AddUntilStep("wait for player", () => (Stack.CurrentScreen as Player)?.IsLoaded == true);
|
||||
private void waitForPlayerLoader() => AddUntilStep("wait for loading", () => this.ChildrenOfType<SpectatorPlayerLoader>().SingleOrDefault()?.IsLoaded == true);
|
||||
|
||||
private void waitForPlayerCurrent() => AddUntilStep("wait for player current", () => this.ChildrenOfType<Player>().SingleOrDefault()?.IsCurrentScreen() == true);
|
||||
|
||||
private void start(int? beatmapId = null) => AddStep("start play", () => spectatorClient.SendStartPlay(streamingUser.Id, beatmapId ?? importedBeatmapId));
|
||||
|
||||
@@ -381,7 +412,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private void loadSpectatingScreen()
|
||||
{
|
||||
AddStep("load spectator", () => LoadScreen(spectatorScreen = new SoloSpectator(streamingUser)));
|
||||
AddStep("load spectator", () => LoadScreen(spectatorScreen = new SoloSpectatorScreen(streamingUser)));
|
||||
AddUntilStep("wait for screen load", () => spectatorScreen.LoadState == LoadState.Loaded);
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
foreach (var legacyFrame in frames.Frames)
|
||||
{
|
||||
var frame = new TestReplayFrame();
|
||||
frame.FromLegacy(legacyFrame, null);
|
||||
frame.FromLegacy(legacyFrame, null!);
|
||||
playbackReplay.Frames.Add(frame);
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public partial class TestInputConsumer : CompositeDrawable, IKeyBindingHandler<TestAction>
|
||||
{
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent.ReceivePositionalInputAt(screenSpacePos);
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent!.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
private readonly Box box;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@@ -14,39 +15,47 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public partial class TestSceneStarCounter : OsuTestScene
|
||||
{
|
||||
private readonly StarCounter starCounter;
|
||||
private readonly StarCounter twentyStarCounter;
|
||||
private readonly OsuSpriteText starsLabel;
|
||||
|
||||
public TestSceneStarCounter()
|
||||
{
|
||||
starCounter = new StarCounter
|
||||
Add(new FillFlowContainer
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
};
|
||||
|
||||
Add(starCounter);
|
||||
|
||||
starsLabel = new OsuSpriteText
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Scale = new Vector2(2),
|
||||
Y = 50,
|
||||
};
|
||||
|
||||
Add(starsLabel);
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(20),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
starCounter = new StarCounter(),
|
||||
twentyStarCounter = new StarCounter(20),
|
||||
starsLabel = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Scale = new Vector2(2),
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
setStars(5);
|
||||
|
||||
AddRepeatStep("random value", () => setStars(RNG.NextSingle() * (starCounter.StarCount + 1)), 10);
|
||||
AddSliderStep("exact value", 0f, 10f, 5f, setStars);
|
||||
AddStep("stop animation", () => starCounter.StopAnimation());
|
||||
AddRepeatStep("random value", () => setStars(RNG.NextSingle() * (twentyStarCounter.StarCount + 1)), 10);
|
||||
AddSliderStep("exact value", 0f, 20f, 5f, setStars);
|
||||
AddStep("stop animation", () =>
|
||||
{
|
||||
starCounter.StopAnimation();
|
||||
twentyStarCounter.StopAnimation();
|
||||
});
|
||||
AddStep("reset", () => setStars(0));
|
||||
}
|
||||
|
||||
private void setStars(float stars)
|
||||
{
|
||||
starCounter.Current = stars;
|
||||
twentyStarCounter.Current = stars;
|
||||
starsLabel.Text = starCounter.Current.ToString("0.00");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,14 +106,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
if (storyboard != null)
|
||||
storyboardContainer.Remove(storyboard, true);
|
||||
|
||||
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
|
||||
storyboardContainer.Clock = decoupledClock;
|
||||
storyboardContainer.Clock = new FramedClock(Beatmap.Value.Track);
|
||||
|
||||
storyboard = toLoad.CreateDrawable(SelectedMods.Value);
|
||||
storyboard.Passing = false;
|
||||
|
||||
storyboardContainer.Add(storyboard);
|
||||
decoupledClock.ChangeSource(Beatmap.Value.Track);
|
||||
}
|
||||
|
||||
private void loadStoryboard(string filename, Action<Storyboard>? setUpStoryboard = null)
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public partial class TestSceneStoryboardCommands : OsuTestScene
|
||||
{
|
||||
[Cached(typeof(Storyboard))]
|
||||
private TestStoryboard storyboard { get; set; } = new TestStoryboard
|
||||
{
|
||||
UseSkinSprites = false,
|
||||
AlwaysProvideTexture = true,
|
||||
};
|
||||
|
||||
private readonly ManualClock manualClock = new ManualClock { Rate = 1, IsRunning = true };
|
||||
private int clockDirection;
|
||||
|
||||
private const string lookup_name = "hitcircleoverlay";
|
||||
private const double clock_limit = 2500;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private Container content = null!;
|
||||
private SpriteText timelineText = null!;
|
||||
private Box timelineMarker = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
base.Content.Children = new Drawable[]
|
||||
{
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
timelineText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Margin = new MarginPadding { Bottom = 60 },
|
||||
},
|
||||
timelineMarker = new Box
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomCentre,
|
||||
RelativePositionAxes = Axes.X,
|
||||
Size = new Vector2(2, 50),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("start clock", () => clockDirection = 1);
|
||||
AddStep("pause clock", () => clockDirection = 0);
|
||||
AddStep("set clock = 0", () => manualClock.CurrentTime = 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNormalCommandPlayback()
|
||||
{
|
||||
AddStep("create storyboard", () => Child = createStoryboard(s =>
|
||||
{
|
||||
s.Commands.AddY(Easing.OutBounce, 500, 900, 100, 240);
|
||||
s.Commands.AddY(Easing.OutQuint, 1100, 1500, 240, 100);
|
||||
}));
|
||||
|
||||
assert(0, 100);
|
||||
assert(500, 100);
|
||||
assert(1000, 240);
|
||||
assert(1500, 100);
|
||||
assert(clock_limit, 100);
|
||||
assert(1500, 100);
|
||||
assert(1000, 240);
|
||||
assert(500, 100);
|
||||
assert(0, 100);
|
||||
|
||||
void assert(double time, double y)
|
||||
{
|
||||
AddStep($"set clock = {time}", () => manualClock.CurrentTime = time);
|
||||
AddAssert($"sprite y = {y} at t = {time}", () => this.ChildrenOfType<DrawableStoryboardSprite>().Single().Y == y);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLoopingCommandsPlayback()
|
||||
{
|
||||
AddStep("create storyboard", () => Child = createStoryboard(s =>
|
||||
{
|
||||
var loop = s.AddLoopingGroup(250, 1);
|
||||
loop.AddY(Easing.OutBounce, 0, 400, 100, 240);
|
||||
loop.AddY(Easing.OutQuint, 600, 1000, 240, 100);
|
||||
}));
|
||||
|
||||
assert(0, 100);
|
||||
assert(250, 100);
|
||||
assert(850, 240);
|
||||
assert(1250, 100);
|
||||
assert(1850, 240);
|
||||
assert(2250, 100);
|
||||
assert(clock_limit, 100);
|
||||
assert(2250, 100);
|
||||
assert(1850, 240);
|
||||
assert(1250, 100);
|
||||
assert(850, 240);
|
||||
assert(250, 100);
|
||||
assert(0, 100);
|
||||
|
||||
void assert(double time, double y)
|
||||
{
|
||||
AddStep($"set clock = {time}", () => manualClock.CurrentTime = time);
|
||||
AddAssert($"sprite y = {y} at t = {time}", () => this.ChildrenOfType<DrawableStoryboardSprite>().Single().Y == y);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLoopManyTimes()
|
||||
{
|
||||
AddStep("create storyboard", () => Child = createStoryboard(s =>
|
||||
{
|
||||
var loop = s.AddLoopingGroup(500, 10000);
|
||||
loop.AddY(Easing.OutBounce, 0, 60, 100, 240);
|
||||
loop.AddY(Easing.OutQuint, 80, 120, 240, 100);
|
||||
}));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParameterTemporaryEffect()
|
||||
{
|
||||
AddStep("create storyboard", () => Child = createStoryboard(s =>
|
||||
{
|
||||
s.Commands.AddFlipV(Easing.None, 1000, 1500, true, false);
|
||||
}));
|
||||
|
||||
AddAssert("sprite not flipped at t = 0", () => !this.ChildrenOfType<DrawableStoryboardSprite>().Single().FlipV);
|
||||
|
||||
AddStep("set clock = 1250", () => manualClock.CurrentTime = 1250);
|
||||
AddAssert("sprite flipped at t = 1250", () => this.ChildrenOfType<DrawableStoryboardSprite>().Single().FlipV);
|
||||
|
||||
AddStep("set clock = 2000", () => manualClock.CurrentTime = 2000);
|
||||
AddAssert("sprite not flipped at t = 2000", () => !this.ChildrenOfType<DrawableStoryboardSprite>().Single().FlipV);
|
||||
|
||||
AddStep("resume clock", () => clockDirection = 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParameterPermanentEffect()
|
||||
{
|
||||
AddStep("create storyboard", () => Child = createStoryboard(s =>
|
||||
{
|
||||
s.Commands.AddFlipV(Easing.None, 1000, 1000, true, true);
|
||||
}));
|
||||
|
||||
AddAssert("sprite flipped at t = 0", () => this.ChildrenOfType<DrawableStoryboardSprite>().Single().FlipV);
|
||||
|
||||
AddStep("set clock = 1250", () => manualClock.CurrentTime = 1250);
|
||||
AddAssert("sprite flipped at t = 1250", () => this.ChildrenOfType<DrawableStoryboardSprite>().Single().FlipV);
|
||||
|
||||
AddStep("set clock = 2000", () => manualClock.CurrentTime = 2000);
|
||||
AddAssert("sprite flipped at t = 2000", () => this.ChildrenOfType<DrawableStoryboardSprite>().Single().FlipV);
|
||||
|
||||
AddStep("resume clock", () => clockDirection = 1);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (manualClock.CurrentTime > clock_limit || manualClock.CurrentTime < 0)
|
||||
clockDirection = -clockDirection;
|
||||
|
||||
manualClock.CurrentTime += Time.Elapsed * clockDirection;
|
||||
timelineText.Text = $"Time: {manualClock.CurrentTime:0}ms";
|
||||
timelineMarker.X = (float)(manualClock.CurrentTime / clock_limit);
|
||||
}
|
||||
|
||||
private DrawableStoryboard createStoryboard(Action<StoryboardSprite>? addCommands = null)
|
||||
{
|
||||
var layer = storyboard.GetLayer("Background");
|
||||
|
||||
var sprite = new StoryboardSprite(lookup_name, Anchor.Centre, new Vector2(320, 240));
|
||||
sprite.Commands.AddScale(Easing.None, 0, clock_limit, 0.5f, 0.5f);
|
||||
sprite.Commands.AddAlpha(Easing.None, 0, clock_limit, 1, 1);
|
||||
addCommands?.Invoke(sprite);
|
||||
|
||||
layer.Elements.Clear();
|
||||
layer.Add(sprite);
|
||||
|
||||
return storyboard.CreateDrawable().With(c => c.Clock = new FramedClock(manualClock));
|
||||
}
|
||||
|
||||
private partial class TestStoryboard : Storyboard
|
||||
{
|
||||
public override DrawableStoryboard CreateDrawable(IReadOnlyList<Mod>? mods = null)
|
||||
{
|
||||
return new TestDrawableStoryboard(this, mods);
|
||||
}
|
||||
|
||||
public bool AlwaysProvideTexture { get; set; }
|
||||
|
||||
public override string GetStoragePathFromStoryboardPath(string path) => AlwaysProvideTexture ? path : string.Empty;
|
||||
|
||||
private partial class TestDrawableStoryboard : DrawableStoryboard
|
||||
{
|
||||
private readonly bool alwaysProvideTexture;
|
||||
|
||||
public TestDrawableStoryboard(TestStoryboard storyboard, IReadOnlyList<Mod>? mods)
|
||||
: base(storyboard, mods)
|
||||
{
|
||||
alwaysProvideTexture = storyboard.AlwaysProvideTexture;
|
||||
}
|
||||
|
||||
protected override IResourceStore<byte[]> CreateResourceLookupStore() => alwaysProvideTexture
|
||||
? new AlwaysReturnsTextureStore()
|
||||
: new ResourceStore<byte[]>();
|
||||
|
||||
internal class AlwaysReturnsTextureStore : IResourceStore<byte[]>
|
||||
{
|
||||
private const string test_image = "Resources/Textures/test-image.png";
|
||||
|
||||
private readonly DllResourceStore store;
|
||||
|
||||
public AlwaysReturnsTextureStore()
|
||||
{
|
||||
store = TestResources.GetStore();
|
||||
}
|
||||
|
||||
public void Dispose() => store.Dispose();
|
||||
|
||||
public byte[] Get(string name) => store.Get(test_image);
|
||||
|
||||
public Task<byte[]> GetAsync(string name, CancellationToken cancellationToken = new CancellationToken()) => store.GetAsync(test_image, cancellationToken);
|
||||
|
||||
public Stream GetStream(string name) => store.GetStream(test_image);
|
||||
|
||||
public IEnumerable<string> GetAvailableResources() => store.GetAvailableResources();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
backgroundLayer.Add(new StoryboardSampleInfo("Intro/welcome.mp3", time: -7000, volume: 20));
|
||||
backgroundLayer.Add(new StoryboardSampleInfo("Intro/welcome.mp3", time: -5000, volume: 20));
|
||||
backgroundLayer.Add(new StoryboardSampleInfo("Intro/welcome.mp3", time: 0, volume: 20));
|
||||
backgroundLayer.Add(new StoryboardSampleInfo("Intro/welcome.mp3", time: 2000, volume: 20));
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Storyboards;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public partial class TestSceneStoryboardWithIntro : PlayerTestScene
|
||||
{
|
||||
protected override bool HasCustomSteps => true;
|
||||
protected override bool AllowFail => true;
|
||||
|
||||
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||
{
|
||||
var beatmap = new Beatmap();
|
||||
beatmap.HitObjects.Add(new HitCircle { StartTime = firstObjectStartTime });
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard? storyboard = null)
|
||||
{
|
||||
return base.CreateWorkingBeatmap(beatmap, createStoryboard(storyboardStartTime));
|
||||
}
|
||||
|
||||
private Storyboard createStoryboard(double startTime)
|
||||
{
|
||||
var storyboard = new Storyboard();
|
||||
var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
|
||||
sprite.Commands.AddAlpha(Easing.None, startTime, 0, 0, 1);
|
||||
storyboard.GetLayer("Background").Add(sprite);
|
||||
return storyboard;
|
||||
}
|
||||
|
||||
private double firstObjectStartTime;
|
||||
private double storyboardStartTime;
|
||||
|
||||
[SetUpSteps]
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
AddStep("enable storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, true));
|
||||
AddStep("set dim level to 0", () => LocalConfig.SetValue<double>(OsuSetting.DimLevel, 0));
|
||||
AddStep("reset first hitobject time", () => firstObjectStartTime = 0);
|
||||
AddStep("reset storyboard start time", () => storyboardStartTime = 0);
|
||||
}
|
||||
|
||||
[TestCase(-5000, 0)]
|
||||
[TestCase(-5000, 30000)]
|
||||
public void TestStoryboardSingleSkip(double storyboardStart, double firstObject)
|
||||
{
|
||||
AddStep($"set storyboard start time to {storyboardStart}", () => storyboardStartTime = storyboardStart);
|
||||
AddStep($"set first object start time to {firstObject}", () => firstObjectStartTime = firstObject);
|
||||
CreateTest();
|
||||
|
||||
AddStep("skip", () => InputManager.Key(osuTK.Input.Key.Space));
|
||||
AddAssert("skip performed", () => Player.ChildrenOfType<SkipOverlay>().Any(s => s.SkipCount == 1));
|
||||
AddUntilStep("gameplay clock advanced", () => Player.GameplayClockContainer.CurrentTime, () => Is.GreaterThanOrEqualTo(firstObject - 2000));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStoryboardDoubleSkip()
|
||||
{
|
||||
AddStep("set storyboard start time to -11000", () => storyboardStartTime = -11000);
|
||||
AddStep("set first object start time to 11000", () => firstObjectStartTime = 11000);
|
||||
CreateTest();
|
||||
|
||||
AddStep("skip", () => InputManager.Key(osuTK.Input.Key.Space));
|
||||
AddAssert("skip performed", () => Player.ChildrenOfType<SkipOverlay>().Any(s => s.SkipCount == 1));
|
||||
AddUntilStep("gameplay clock advanced", () => Player.GameplayClockContainer.CurrentTime, () => Is.GreaterThanOrEqualTo(0));
|
||||
|
||||
AddStep("skip", () => InputManager.Key(osuTK.Input.Key.Space));
|
||||
AddAssert("skip performed", () => Player.ChildrenOfType<SkipOverlay>().Any(s => s.SkipCount == 2));
|
||||
AddUntilStep("gameplay clock advanced", () => Player.GameplayClockContainer.CurrentTime, () => Is.GreaterThanOrEqualTo(9000));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
protected override bool HasCustomSteps => true;
|
||||
|
||||
protected override bool AllowBackwardsSeeks => true;
|
||||
|
||||
protected new OutroPlayer Player => (OutroPlayer)base.Player;
|
||||
|
||||
private double currentBeatmapDuration;
|
||||
@@ -72,12 +74,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStoryboardExitDuringOutroStillExits()
|
||||
public void TestStoryboardExitDuringOutroProgressesToResults()
|
||||
{
|
||||
CreateTest();
|
||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||
AddStep("exit via pause", () => Player.ExitViaPause());
|
||||
AddAssert("player exited", () => !Player.IsCurrentScreen() && Player.GetChildScreen() == null);
|
||||
AddUntilStep("reached results screen", () => Stack.CurrentScreen is ResultsScreen);
|
||||
}
|
||||
|
||||
[TestCase(false)]
|
||||
@@ -171,7 +173,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddStep("disable storyboard", () => LocalConfig.SetValue(OsuSetting.ShowStoryboard, false));
|
||||
AddUntilStep("completion set by processor", () => Player.ScoreProcessor.HasCompleted.Value);
|
||||
AddStep("exit via pause", () => Player.ExitViaPause());
|
||||
AddAssert("player exited", () => Stack.CurrentScreen == null);
|
||||
AddUntilStep("reached results screen", () => Stack.CurrentScreen is ResultsScreen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -214,7 +216,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
var storyboard = new Storyboard();
|
||||
var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
|
||||
sprite.TimelineGroup.Alpha.Add(Easing.None, 0, duration, 1, 0);
|
||||
sprite.Commands.AddAlpha(Easing.None, 0, duration, 1, 0);
|
||||
storyboard.GetLayer("Background").Add(sprite);
|
||||
return storyboard;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
@@ -56,6 +57,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
scoreProcessor.RevertResult(
|
||||
new JudgementResult(new HitCircle { HitWindows = hitWindows }, new Judgement())
|
||||
{
|
||||
GameplayRate = 1.0,
|
||||
TimeOffset = 25,
|
||||
Type = HitResult.Perfect,
|
||||
});
|
||||
@@ -80,6 +82,27 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddUntilStep("UR = 250", () => counter.Current.Value == 250.0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStaticRateChange()
|
||||
{
|
||||
AddStep("Create Display", recreateDisplay);
|
||||
|
||||
AddRepeatStep("Set UR to 250 at 1.5x", () => applyJudgement(25, true, 1.5), 4);
|
||||
|
||||
AddUntilStep("UR = 250/1.5", () => counter.Current.Value == Math.Round(250.0 / 1.5));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDynamicRateChange()
|
||||
{
|
||||
AddStep("Create Display", recreateDisplay);
|
||||
|
||||
AddRepeatStep("Set UR to 100 at 1.0x", () => applyJudgement(10, true, 1.0), 4);
|
||||
AddRepeatStep("Bring UR to 100 at 1.5x", () => applyJudgement(15, true, 1.5), 4);
|
||||
|
||||
AddUntilStep("UR = 100", () => counter.Current.Value == 100.0);
|
||||
}
|
||||
|
||||
private void recreateDisplay()
|
||||
{
|
||||
Clear();
|
||||
@@ -92,7 +115,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
});
|
||||
}
|
||||
|
||||
private void applyJudgement(double offsetMs, bool alt)
|
||||
private void applyJudgement(double offsetMs, bool alt, double gameplayRate = 1.0)
|
||||
{
|
||||
double placement = offsetMs;
|
||||
|
||||
@@ -105,6 +128,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
scoreProcessor.ApplyResult(new JudgementResult(new HitCircle { HitWindows = hitWindows }, new Judgement())
|
||||
{
|
||||
TimeOffset = placement,
|
||||
GameplayRate = gameplayRate,
|
||||
Type = HitResult.Perfect,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Screens.Menu;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
public partial class TestSceneIntroMusicActionHandling : OsuGameTestScene
|
||||
{
|
||||
private GlobalActionContainer globalActionContainer => Game.ChildrenOfType<GlobalActionContainer>().First();
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
CreateNewGame();
|
||||
// we do not want to progress to main menu immediately, hence the override and lack of `ConfirmAtMainMenu()` call here.
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPauseDuringIntro()
|
||||
{
|
||||
AddUntilStep("Wait for music", () => Game?.MusicController.IsPlaying == true);
|
||||
|
||||
// Check that pause doesn't work during intro sequence.
|
||||
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
|
||||
AddAssert("Still playing before menu", () => Game?.MusicController.IsPlaying == true);
|
||||
AddUntilStep("Wait for main menu", () => Game?.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);
|
||||
|
||||
// Check that toggling after intro still works.
|
||||
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
|
||||
AddUntilStep("Music paused", () => Game?.MusicController.IsPlaying == false && Game?.MusicController.UserPauseRequested == true);
|
||||
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
|
||||
AddUntilStep("Music resumed", () => Game?.MusicController.IsPlaying == true && Game?.MusicController.UserPauseRequested == false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,20 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Login;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Users;
|
||||
using osu.Game.Users.Drawables;
|
||||
using osuTK.Input;
|
||||
|
||||
@@ -18,8 +24,13 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
[TestFixture]
|
||||
public partial class TestSceneLoginOverlay : OsuManualInputManagerTestScene
|
||||
{
|
||||
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
||||
|
||||
private LoginOverlay loginOverlay = null!;
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager configManager { get; set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@@ -40,9 +51,84 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
public void TestLoginSuccess()
|
||||
{
|
||||
AddStep("logout", () => API.Logout());
|
||||
assertAPIState(APIState.Offline);
|
||||
|
||||
AddStep("enter password", () => loginOverlay.ChildrenOfType<OsuPasswordTextBox>().First().Text = "password");
|
||||
AddStep("submit", () => loginOverlay.ChildrenOfType<OsuButton>().First(b => b.Text.ToString() == "Sign in").TriggerClick());
|
||||
|
||||
assertAPIState(APIState.RequiresSecondFactorAuth);
|
||||
AddUntilStep("wait for second factor auth form", () => loginOverlay.ChildrenOfType<SecondFactorAuthForm>().SingleOrDefault(), () => Is.Not.Null);
|
||||
|
||||
AddStep("set up verification handling", () => dummyAPI.HandleRequest = req =>
|
||||
{
|
||||
switch (req)
|
||||
{
|
||||
case VerifySessionRequest verifySessionRequest:
|
||||
if (verifySessionRequest.VerificationKey == "88800088")
|
||||
verifySessionRequest.TriggerSuccess();
|
||||
else
|
||||
verifySessionRequest.TriggerFailure(new WebException());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
AddStep("enter code", () => loginOverlay.ChildrenOfType<OsuTextBox>().First().Text = "88800088");
|
||||
assertAPIState(APIState.Online);
|
||||
assertDropdownState(UserAction.Online);
|
||||
|
||||
AddStep("set failing", () => { dummyAPI.SetState(APIState.Failing); });
|
||||
AddStep("return to online", () => { dummyAPI.SetState(APIState.Online); });
|
||||
|
||||
AddStep("clear handler", () => dummyAPI.HandleRequest = null);
|
||||
|
||||
assertDropdownState(UserAction.Online);
|
||||
AddStep("change user state", () => dummyAPI.LocalUser.Value.Status.Value = UserStatus.DoNotDisturb);
|
||||
assertDropdownState(UserAction.DoNotDisturb);
|
||||
}
|
||||
|
||||
private void assertDropdownState(UserAction state)
|
||||
{
|
||||
AddAssert($"dropdown state is {state}", () => loginOverlay.ChildrenOfType<UserDropdown>().First().Current.Value, () => Is.EqualTo(state));
|
||||
}
|
||||
|
||||
private void assertAPIState(APIState expected) =>
|
||||
AddUntilStep($"login state is {expected}", () => API.State.Value, () => Is.EqualTo(expected));
|
||||
|
||||
[Test]
|
||||
public void TestVerificationFailure()
|
||||
{
|
||||
bool verificationHandled = false;
|
||||
AddStep("reset flag", () => verificationHandled = false);
|
||||
AddStep("logout", () => API.Logout());
|
||||
assertAPIState(APIState.Offline);
|
||||
|
||||
AddStep("enter password", () => loginOverlay.ChildrenOfType<OsuPasswordTextBox>().First().Text = "password");
|
||||
AddStep("submit", () => loginOverlay.ChildrenOfType<OsuButton>().First(b => b.Text.ToString() == "Sign in").TriggerClick());
|
||||
|
||||
assertAPIState(APIState.RequiresSecondFactorAuth);
|
||||
AddUntilStep("wait for second factor auth form", () => loginOverlay.ChildrenOfType<SecondFactorAuthForm>().SingleOrDefault(), () => Is.Not.Null);
|
||||
|
||||
AddStep("set up verification handling", () => dummyAPI.HandleRequest = req =>
|
||||
{
|
||||
switch (req)
|
||||
{
|
||||
case VerifySessionRequest verifySessionRequest:
|
||||
if (verifySessionRequest.VerificationKey == "88800088")
|
||||
verifySessionRequest.TriggerSuccess();
|
||||
else
|
||||
verifySessionRequest.TriggerFailure(new WebException());
|
||||
verificationHandled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
AddStep("enter code", () => loginOverlay.ChildrenOfType<OsuTextBox>().First().Text = "abcdefgh");
|
||||
AddUntilStep("wait for verification handled", () => verificationHandled);
|
||||
assertAPIState(APIState.RequiresSecondFactorAuth);
|
||||
AddStep("clear handler", () => dummyAPI.HandleRequest = null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -78,6 +164,12 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
AddStep("enter password", () => loginOverlay.ChildrenOfType<OsuPasswordTextBox>().First().Text = "password");
|
||||
AddStep("submit", () => loginOverlay.ChildrenOfType<OsuButton>().First(b => b.Text.ToString() == "Sign in").TriggerClick());
|
||||
|
||||
assertAPIState(APIState.RequiresSecondFactorAuth);
|
||||
AddUntilStep("wait for second factor auth form", () => loginOverlay.ChildrenOfType<SecondFactorAuthForm>().SingleOrDefault(), () => Is.Not.Null);
|
||||
|
||||
AddStep("enter code", () => loginOverlay.ChildrenOfType<OsuTextBox>().First().Text = "88800088");
|
||||
assertAPIState(APIState.Online);
|
||||
|
||||
AddStep("click on flag", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(loginOverlay.ChildrenOfType<UpdateableFlag>().First());
|
||||
@@ -85,5 +177,36 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
});
|
||||
AddAssert("login overlay is hidden", () => loginOverlay.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUncheckingRememberUsernameClearsIt()
|
||||
{
|
||||
AddStep("logout", () => API.Logout());
|
||||
AddStep("set username", () => configManager.SetValue(OsuSetting.Username, "test_user"));
|
||||
AddStep("set remember password", () => configManager.SetValue(OsuSetting.SavePassword, true));
|
||||
AddStep("uncheck remember username", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(loginOverlay.ChildrenOfType<SettingsCheckbox>().First());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddAssert("remember username off", () => configManager.Get<bool>(OsuSetting.SaveUsername), () => Is.False);
|
||||
AddAssert("remember password off", () => configManager.Get<bool>(OsuSetting.SavePassword), () => Is.False);
|
||||
AddAssert("username cleared", () => configManager.Get<string>(OsuSetting.Username), () => Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUncheckingRememberPasswordClearsToken()
|
||||
{
|
||||
AddStep("logout", () => API.Logout());
|
||||
AddStep("set token", () => configManager.SetValue(OsuSetting.Token, "test_token"));
|
||||
AddStep("set remember password", () => configManager.SetValue(OsuSetting.SavePassword, true));
|
||||
AddStep("uncheck remember token", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(loginOverlay.ChildrenOfType<SettingsCheckbox>().Last());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddAssert("remember password off", () => configManager.Get<bool>(OsuSetting.SavePassword), () => Is.False);
|
||||
AddAssert("token cleared", () => configManager.Get<string>(OsuSetting.Token), () => Is.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
public partial class TestSceneMainMenu : OsuGameTestScene
|
||||
{
|
||||
private OnlineMenuBanner onlineMenuBanner => Game.ChildrenOfType<OnlineMenuBanner>().Single();
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
AddStep("don't fetch online content", () => onlineMenuBanner.FetchOnlineContent = false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOnlineMenuBannerTrusted()
|
||||
{
|
||||
AddStep("set online content", () => onlineMenuBanner.Current.Value = new APIMenuContent
|
||||
{
|
||||
Images = new[]
|
||||
{
|
||||
new APIMenuImage
|
||||
{
|
||||
Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png",
|
||||
Url = $@"{API.WebsiteRootUrl}/home/news/2023-12-21-project-loved-december-2023",
|
||||
}
|
||||
}
|
||||
});
|
||||
AddAssert("system title not visible", () => onlineMenuBanner.State.Value, () => Is.EqualTo(Visibility.Hidden));
|
||||
AddStep("enter menu", () => InputManager.Key(Key.Enter));
|
||||
AddUntilStep("system title visible", () => onlineMenuBanner.State.Value, () => Is.EqualTo(Visibility.Visible));
|
||||
AddUntilStep("image loaded", () => onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>().FirstOrDefault()?.IsLoaded, () => Is.True);
|
||||
|
||||
AddStep("click banner", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(onlineMenuBanner);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
// Might not catch every occurrence due to async nature, but works in manual testing and saves annoying test setup.
|
||||
AddAssert("no dialog", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault()?.CurrentDialog == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOnlineMenuBannerUntrustedDomain()
|
||||
{
|
||||
AddStep("set online content", () => onlineMenuBanner.Current.Value = new APIMenuContent
|
||||
{
|
||||
Images = new[]
|
||||
{
|
||||
new APIMenuImage
|
||||
{
|
||||
Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png",
|
||||
Url = @"https://google.com",
|
||||
}
|
||||
}
|
||||
});
|
||||
AddAssert("system title not visible", () => onlineMenuBanner.State.Value, () => Is.EqualTo(Visibility.Hidden));
|
||||
AddStep("enter menu", () => InputManager.Key(Key.Enter));
|
||||
AddUntilStep("system title visible", () => onlineMenuBanner.State.Value, () => Is.EqualTo(Visibility.Visible));
|
||||
AddUntilStep("image loaded", () => onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>().FirstOrDefault()?.IsLoaded, () => Is.True);
|
||||
|
||||
AddStep("click banner", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(onlineMenuBanner);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for dialog", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault()?.CurrentDialog != null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
public partial class TestSceneOnlineMenuBanner : OsuTestScene
|
||||
{
|
||||
private OnlineMenuBanner onlineMenuBanner = null!;
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("Create banner", () =>
|
||||
{
|
||||
Child = onlineMenuBanner = new OnlineMenuBanner
|
||||
{
|
||||
FetchOnlineContent = false,
|
||||
DelayBetweenRotation = 500,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
State = { Value = Visibility.Visible }
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBasic()
|
||||
{
|
||||
AddStep("set online content", () => onlineMenuBanner.Current.Value = new APIMenuContent
|
||||
{
|
||||
Images = new[]
|
||||
{
|
||||
new APIMenuImage
|
||||
{
|
||||
Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png",
|
||||
Url = @"https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023",
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
AddUntilStep("wait for one image shown", () =>
|
||||
{
|
||||
var images = onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>();
|
||||
|
||||
if (images.Count() != 1)
|
||||
return false;
|
||||
|
||||
var image = images.Single();
|
||||
|
||||
return image.IsPresent && image.Image.Url == "https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023";
|
||||
});
|
||||
|
||||
AddStep("set another title", () => onlineMenuBanner.Current.Value = new APIMenuContent
|
||||
{
|
||||
Images = new[]
|
||||
{
|
||||
new APIMenuImage
|
||||
{
|
||||
Image = @"https://assets.ppy.sh/main-menu/wf2023-vote@2x.png",
|
||||
Url = @"https://osu.ppy.sh/community/contests/189",
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AddUntilStep("wait for new image shown", () =>
|
||||
{
|
||||
var images = onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>();
|
||||
|
||||
if (images.Count() != 1)
|
||||
return false;
|
||||
|
||||
var image = images.Single();
|
||||
|
||||
return image.IsPresent && image.Image.Url == "https://osu.ppy.sh/community/contests/189";
|
||||
});
|
||||
|
||||
AddStep("set title with nonexistent image", () => onlineMenuBanner.Current.Value = new APIMenuContent
|
||||
{
|
||||
Images = new[]
|
||||
{
|
||||
new APIMenuImage
|
||||
{
|
||||
Image = @"https://test.invalid/@2x", // .invalid TLD reserved by https://datatracker.ietf.org/doc/html/rfc2606#section-2
|
||||
Url = @"https://osu.ppy.sh/community/contests/189",
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AddUntilStep("wait for no image shown", () => onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>().SingleOrDefault()?.Size, () => Is.EqualTo(Vector2.Zero));
|
||||
|
||||
AddStep("unset system title", () => onlineMenuBanner.Current.Value = new APIMenuContent());
|
||||
|
||||
AddUntilStep("wait for no image shown", () => !onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>().Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleImages()
|
||||
{
|
||||
AddStep("set multiple images", () => onlineMenuBanner.Current.Value = new APIMenuContent
|
||||
{
|
||||
Images = new[]
|
||||
{
|
||||
new APIMenuImage
|
||||
{
|
||||
Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png",
|
||||
Url = @"https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023",
|
||||
},
|
||||
new APIMenuImage
|
||||
{
|
||||
Image = @"https://assets.ppy.sh/main-menu/wf2023-vote@2x.png",
|
||||
Url = @"https://osu.ppy.sh/community/contests/189",
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
AddUntilStep("wait for first image shown", () =>
|
||||
{
|
||||
var images = onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>();
|
||||
|
||||
if (images.Count() != 2)
|
||||
return false;
|
||||
|
||||
return images.First().IsPresent && !images.Last().IsPresent;
|
||||
});
|
||||
|
||||
AddUntilStep("wait for second image shown", () =>
|
||||
{
|
||||
var images = onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>();
|
||||
|
||||
if (images.Count() != 2)
|
||||
return false;
|
||||
|
||||
return !images.First().IsPresent && images.Last().IsPresent;
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFutureSingle()
|
||||
{
|
||||
AddStep("set image with time constraints", () => onlineMenuBanner.Current.Value = new APIMenuContent
|
||||
{
|
||||
Images = new[]
|
||||
{
|
||||
new APIMenuImage
|
||||
{
|
||||
Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png",
|
||||
Url = @"https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023",
|
||||
Begins = DateTimeOffset.Now.AddSeconds(2),
|
||||
Expires = DateTimeOffset.Now.AddSeconds(5),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
AddUntilStep("wait for no image shown", () => !onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>().Any(i => i.IsPresent));
|
||||
|
||||
AddUntilStep("wait for one image shown", () =>
|
||||
{
|
||||
var images = onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>();
|
||||
|
||||
if (images.Count() != 1)
|
||||
return false;
|
||||
|
||||
var image = images.Single();
|
||||
|
||||
return image.IsPresent && image.Image.Url == "https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023";
|
||||
});
|
||||
|
||||
AddUntilStep("wait for no image shown", () => !onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>().Any(i => i.IsPresent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExpiryMultiple()
|
||||
{
|
||||
AddStep("set multiple images, second expiring soon", () => onlineMenuBanner.Current.Value = new APIMenuContent
|
||||
{
|
||||
Images = new[]
|
||||
{
|
||||
new APIMenuImage
|
||||
{
|
||||
Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png",
|
||||
Url = @"https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023",
|
||||
},
|
||||
new APIMenuImage
|
||||
{
|
||||
Image = @"https://assets.ppy.sh/main-menu/wf2023-vote@2x.png",
|
||||
Url = @"https://osu.ppy.sh/community/contests/189",
|
||||
Expires = DateTimeOffset.Now.AddSeconds(2),
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
AddUntilStep("wait for first image shown", () =>
|
||||
{
|
||||
var images = onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>();
|
||||
|
||||
if (images.Count() != 2)
|
||||
return false;
|
||||
|
||||
return images.First().IsPresent && !images.Last().IsPresent;
|
||||
});
|
||||
|
||||
AddUntilStep("wait for second image shown", () =>
|
||||
{
|
||||
var images = onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>();
|
||||
|
||||
if (images.Count() != 2)
|
||||
return false;
|
||||
|
||||
return !images.First().IsPresent && images.Last().IsPresent;
|
||||
});
|
||||
|
||||
AddUntilStep("wait for expiry", () =>
|
||||
{
|
||||
return onlineMenuBanner
|
||||
.ChildrenOfType<OnlineMenuBanner.MenuImage>()
|
||||
.Any(i => !i.Image.IsCurrent);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for first image shown", () =>
|
||||
{
|
||||
var images = onlineMenuBanner.ChildrenOfType<OnlineMenuBanner.MenuImage>();
|
||||
|
||||
if (images.Count() != 2)
|
||||
return false;
|
||||
|
||||
return images.First().IsPresent && !images.Last().IsPresent;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
foreach (var fountain in Children.OfType<StarFountain>())
|
||||
{
|
||||
if (RNG.NextSingle() > 0.8f)
|
||||
fountain.Shoot();
|
||||
fountain.Shoot(RNG.Next(-1, 2));
|
||||
}
|
||||
}, 150);
|
||||
}
|
||||
|
||||
+14
-6
@@ -1,19 +1,27 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Screens.Menu;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
public partial class TestSceneDisclaimer : ScreenTestScene
|
||||
public partial class TestSceneSupporterDisplay : OsuTestScene
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
[Test]
|
||||
public void TestBasic()
|
||||
{
|
||||
AddStep("load disclaimer", () => LoadScreen(new Disclaimer()));
|
||||
AddStep("create display", () =>
|
||||
{
|
||||
Child = new SupporterDisplay
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("toggle support", () =>
|
||||
{
|
||||
@@ -250,7 +250,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
}
|
||||
|
||||
public virtual IBindable<int> UnreadCount => null;
|
||||
public virtual IBindable<int> UnreadCount { get; } = new Bindable<int>();
|
||||
|
||||
public IEnumerable<Notification> AllNotifications => Enumerable.Empty<Notification>();
|
||||
}
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays.Toolbar;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@@ -16,6 +21,8 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
[TestFixture]
|
||||
public partial class TestSceneToolbarUserButton : OsuManualInputManagerTestScene
|
||||
{
|
||||
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
||||
|
||||
public TestSceneToolbarUserButton()
|
||||
{
|
||||
Container mainContainer;
|
||||
@@ -69,19 +76,107 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
[Test]
|
||||
public void TestLoginLogout()
|
||||
{
|
||||
AddStep("Log out", () => ((DummyAPIAccess)API).Logout());
|
||||
AddStep("Log in", () => ((DummyAPIAccess)API).Login("wang", "jang"));
|
||||
AddStep("Log out", () => dummyAPI.Logout());
|
||||
AddStep("Log in", () => dummyAPI.Login("wang", "jang"));
|
||||
AddStep("Authenticate via second factor", () => dummyAPI.AuthenticateSecondFactor("abcdefgh"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStates()
|
||||
{
|
||||
AddStep("Log in", () => ((DummyAPIAccess)API).Login("wang", "jang"));
|
||||
AddStep("Log in", () => dummyAPI.Login("wang", "jang"));
|
||||
AddStep("Authenticate via second factor", () => dummyAPI.AuthenticateSecondFactor("abcdefgh"));
|
||||
|
||||
foreach (var state in Enum.GetValues<APIState>())
|
||||
{
|
||||
AddStep($"Change state to {state}", () => ((DummyAPIAccess)API).SetState(state));
|
||||
AddStep($"Change state to {state}", () => dummyAPI.SetState(state));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTransientUserStatisticsDisplay()
|
||||
{
|
||||
AddStep("Log in", () => dummyAPI.Login("wang", "jang"));
|
||||
AddStep("Gain", () =>
|
||||
{
|
||||
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
|
||||
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
|
||||
new ScoreInfo(),
|
||||
new UserStatistics
|
||||
{
|
||||
GlobalRank = 123_456,
|
||||
PP = 1234
|
||||
},
|
||||
new UserStatistics
|
||||
{
|
||||
GlobalRank = 111_111,
|
||||
PP = 1357
|
||||
});
|
||||
});
|
||||
AddStep("Loss", () =>
|
||||
{
|
||||
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
|
||||
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
|
||||
new ScoreInfo(),
|
||||
new UserStatistics
|
||||
{
|
||||
GlobalRank = 111_111,
|
||||
PP = 1357
|
||||
},
|
||||
new UserStatistics
|
||||
{
|
||||
GlobalRank = 123_456,
|
||||
PP = 1234
|
||||
});
|
||||
});
|
||||
AddStep("No change", () =>
|
||||
{
|
||||
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
|
||||
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
|
||||
new ScoreInfo(),
|
||||
new UserStatistics
|
||||
{
|
||||
GlobalRank = 111_111,
|
||||
PP = 1357
|
||||
},
|
||||
new UserStatistics
|
||||
{
|
||||
GlobalRank = 111_111,
|
||||
PP = 1357
|
||||
});
|
||||
});
|
||||
AddStep("Was null", () =>
|
||||
{
|
||||
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
|
||||
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
|
||||
new ScoreInfo(),
|
||||
new UserStatistics
|
||||
{
|
||||
GlobalRank = null,
|
||||
PP = null
|
||||
},
|
||||
new UserStatistics
|
||||
{
|
||||
GlobalRank = 111_111,
|
||||
PP = 1357
|
||||
});
|
||||
});
|
||||
AddStep("Became null", () =>
|
||||
{
|
||||
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
|
||||
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
|
||||
new ScoreInfo(),
|
||||
new UserStatistics
|
||||
{
|
||||
GlobalRank = 111_111,
|
||||
PP = 1357
|
||||
},
|
||||
new UserStatistics
|
||||
{
|
||||
GlobalRank = null,
|
||||
PP = null
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osuTK;
|
||||
|
||||
@@ -29,7 +30,7 @@ namespace osu.Game.Tests.Visual.Mods
|
||||
public void TestMaximumAchievableAccuracy() =>
|
||||
CreateModTest(new ModTestData
|
||||
{
|
||||
Mod = new ModAccuracyChallenge
|
||||
Mod = new OsuModAccuracyChallenge
|
||||
{
|
||||
MinimumAccuracy = { Value = 0.6 }
|
||||
},
|
||||
@@ -49,7 +50,7 @@ namespace osu.Game.Tests.Visual.Mods
|
||||
public void TestStandardAccuracy() =>
|
||||
CreateModTest(new ModTestData
|
||||
{
|
||||
Mod = new ModAccuracyChallenge
|
||||
Mod = new OsuModAccuracyChallenge
|
||||
{
|
||||
MinimumAccuracy = { Value = 0.6 },
|
||||
AccuracyJudgeMode = { Value = ModAccuracyChallenge.AccuracyMode.Standard }
|
||||
|
||||
@@ -69,8 +69,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}),
|
||||
createLoungeRoom(new Room
|
||||
{
|
||||
Name = { Value = "Multiplayer room" },
|
||||
Status = { Value = new RoomStatusOpen() },
|
||||
Name = { Value = "Private room" },
|
||||
Status = { Value = new RoomStatusOpenPrivate() },
|
||||
HasPassword = { Value = true },
|
||||
EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
|
||||
Type = { Value = MatchType.HeadToHead },
|
||||
Playlist =
|
||||
|
||||
@@ -16,11 +16,14 @@ using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Beatmaps.Drawables.Cards;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Models;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
@@ -302,6 +305,37 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectableMouseHandling()
|
||||
{
|
||||
bool resultsRequested = false;
|
||||
|
||||
AddStep("reset flag", () => resultsRequested = false);
|
||||
createPlaylist(p =>
|
||||
{
|
||||
p.AllowSelection = true;
|
||||
p.AllowShowingResults = true;
|
||||
p.RequestResults = _ => resultsRequested = true;
|
||||
});
|
||||
|
||||
AddUntilStep("wait for load", () => playlist.ChildrenOfType<DrawableLinkCompiler>().Any() && playlist.ChildrenOfType<BeatmapCardThumbnail>().First().DrawWidth > 0);
|
||||
AddStep("move mouse to first item title", () =>
|
||||
{
|
||||
var drawQuad = playlist.ChildrenOfType<LinkFlowContainer>().First().ScreenSpaceDrawQuad;
|
||||
var location = (drawQuad.TopLeft + drawQuad.BottomLeft) / 2 + new Vector2(drawQuad.Width * 0.2f, 0);
|
||||
InputManager.MoveMouseTo(location);
|
||||
});
|
||||
AddAssert("first item title not hovered", () => playlist.ChildrenOfType<DrawableLinkCompiler>().First().IsHovered, () => Is.False);
|
||||
AddStep("click left mouse", () => InputManager.Click(MouseButton.Left));
|
||||
AddUntilStep("first item selected", () => playlist.ChildrenOfType<DrawableRoomPlaylistItem>().First().IsSelectedItem, () => Is.True);
|
||||
// implies being clickable.
|
||||
AddUntilStep("first item title hovered", () => playlist.ChildrenOfType<DrawableLinkCompiler>().First().IsHovered, () => Is.True);
|
||||
|
||||
AddStep("move mouse to second item results button", () => InputManager.MoveMouseTo(playlist.ChildrenOfType<GrayButton>().ElementAt(5)));
|
||||
AddStep("click left mouse", () => InputManager.Click(MouseButton.Left));
|
||||
AddUntilStep("results requested", () => resultsRequested);
|
||||
}
|
||||
|
||||
private void moveToItem(int index, Vector2? offset = null)
|
||||
=> AddStep($"move mouse to item {index}", () => InputManager.MoveMouseTo(playlist.ChildrenOfType<DrawableRoomPlaylistItem>().ElementAt(index), offset));
|
||||
|
||||
|
||||
@@ -10,12 +10,14 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.OnlinePlay;
|
||||
using osu.Game.Utils;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
@@ -23,6 +25,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
public partial class TestSceneFreeModSelectOverlay : MultiplayerTestScene
|
||||
{
|
||||
private FreeModSelectOverlay freeModSelectOverlay;
|
||||
private FooterButtonFreeMods footerButtonFreeMods;
|
||||
private readonly Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods = new Bindable<Dictionary<ModType, IReadOnlyList<Mod>>>();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@@ -119,11 +122,46 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("select all button enabled", () => this.ChildrenOfType<SelectAllModsButton>().Single().Enabled.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectAllViaFooterButtonThenDeselectFromOverlay()
|
||||
{
|
||||
createFreeModSelect();
|
||||
|
||||
AddAssert("overlay select all button enabled", () => freeModSelectOverlay.ChildrenOfType<SelectAllModsButton>().Single().Enabled.Value);
|
||||
AddAssert("footer button displays off", () => footerButtonFreeMods.ChildrenOfType<IHasText>().Any(t => t.Text == "off"));
|
||||
|
||||
AddStep("click footer select all button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(footerButtonFreeMods);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("all mods selected", assertAllAvailableModsSelected);
|
||||
AddAssert("footer button displays all", () => footerButtonFreeMods.ChildrenOfType<IHasText>().Any(t => t.Text == "all"));
|
||||
|
||||
AddStep("click deselect all button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<DeselectAllModsButton>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddUntilStep("all mods deselected", () => !freeModSelectOverlay.SelectedMods.Value.Any());
|
||||
AddAssert("footer button displays off", () => footerButtonFreeMods.ChildrenOfType<IHasText>().Any(t => t.Text == "off"));
|
||||
}
|
||||
|
||||
private void createFreeModSelect()
|
||||
{
|
||||
AddStep("create free mod select screen", () => Child = freeModSelectOverlay = new FreeModSelectOverlay
|
||||
AddStep("create free mod select screen", () => Children = new Drawable[]
|
||||
{
|
||||
State = { Value = Visibility.Visible }
|
||||
freeModSelectOverlay = new FreeModSelectOverlay
|
||||
{
|
||||
State = { Value = Visibility.Visible }
|
||||
},
|
||||
footerButtonFreeMods = new FooterButtonFreeMods(freeModSelectOverlay)
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Current = { BindTarget = freeModSelectOverlay.SelectedMods },
|
||||
},
|
||||
});
|
||||
AddUntilStep("all column content loaded",
|
||||
() => freeModSelectOverlay.ChildrenOfType<ModColumn>().Any()
|
||||
@@ -133,10 +171,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
private bool assertAllAvailableModsSelected()
|
||||
{
|
||||
var allAvailableMods = availableMods.Value
|
||||
.SelectMany(pair => pair.Value)
|
||||
.Where(pair => pair.Key != ModType.System)
|
||||
.SelectMany(pair => ModUtils.FlattenMods(pair.Value))
|
||||
.Where(mod => mod.UserPlayable && mod.HasImplementation)
|
||||
.ToList();
|
||||
|
||||
if (freeModSelectOverlay.SelectedMods.Value.Count != allAvailableMods.Count)
|
||||
return false;
|
||||
|
||||
foreach (var availableMod in allAvailableMods)
|
||||
{
|
||||
if (freeModSelectOverlay.SelectedMods.Value.All(selectedMod => selectedMod.GetType() != availableMod.GetType()))
|
||||
|
||||
@@ -84,12 +84,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFocusOnTabKeyWhenExpanded()
|
||||
public void TestFocusOnEnterKeyWhenExpanded()
|
||||
{
|
||||
setLocalUserPlaying(true);
|
||||
|
||||
assertChatFocused(false);
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
AddStep("press enter", () => InputManager.Key(Key.Enter));
|
||||
assertChatFocused(true);
|
||||
}
|
||||
|
||||
@@ -99,19 +99,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
setLocalUserPlaying(true);
|
||||
|
||||
assertChatFocused(false);
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
AddStep("press enter", () => InputManager.Key(Key.Enter));
|
||||
assertChatFocused(true);
|
||||
AddStep("press escape", () => InputManager.Key(Key.Escape));
|
||||
assertChatFocused(false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFocusOnTabKeyWhenNotExpanded()
|
||||
public void TestFocusOnEnterKeyWhenNotExpanded()
|
||||
{
|
||||
AddStep("set not expanded", () => chatDisplay.Expanded.Value = false);
|
||||
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
AddStep("press enter", () => InputManager.Key(Key.Enter));
|
||||
assertChatFocused(true);
|
||||
AddUntilStep("is visible", () => chatDisplay.IsPresent);
|
||||
|
||||
@@ -120,21 +120,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFocusToggleViaAction()
|
||||
{
|
||||
AddStep("set not expanded", () => chatDisplay.Expanded.Value = false);
|
||||
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
assertChatFocused(true);
|
||||
AddUntilStep("is visible", () => chatDisplay.IsPresent);
|
||||
|
||||
AddStep("press tab", () => InputManager.Key(Key.Tab));
|
||||
assertChatFocused(false);
|
||||
AddUntilStep("is not visible", () => !chatDisplay.IsPresent);
|
||||
}
|
||||
|
||||
private void assertChatFocused(bool isFocused) =>
|
||||
AddAssert($"chat {(isFocused ? "focused" : "not focused")}", () => textBox.HasFocus == isFocused);
|
||||
|
||||
|
||||
@@ -58,12 +58,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
.SkipWhile(r => r.Room.Category.Value == RoomCategory.Spotlight)
|
||||
.All(r => r.Room.Category.Value == RoomCategory.Normal));
|
||||
|
||||
AddStep("remove first room", () => RoomManager.RemoveRoom(RoomManager.Rooms.FirstOrDefault(r => r.RoomID.Value == 0)));
|
||||
AddStep("remove first room", () => RoomManager.RemoveRoom(RoomManager.Rooms.First(r => r.RoomID.Value == 0)));
|
||||
AddAssert("has 4 rooms", () => container.Rooms.Count == 4);
|
||||
AddAssert("first room removed", () => container.Rooms.All(r => r.Room.RoomID.Value != 0));
|
||||
|
||||
AddStep("select first room", () => container.Rooms.First().TriggerClick());
|
||||
AddAssert("first spotlight selected", () => checkRoomSelected(RoomManager.Rooms.First(r => r.Category.Value == RoomCategory.Spotlight)));
|
||||
|
||||
AddStep("remove last room", () => RoomManager.RemoveRoom(RoomManager.Rooms.MinBy(r => r.RoomID?.Value)));
|
||||
AddAssert("first spotlight still selected", () => checkRoomSelected(RoomManager.Rooms.First(r => r.Category.Value == RoomCategory.Spotlight)));
|
||||
|
||||
AddStep("remove spotlight room", () => RoomManager.RemoveRoom(RoomManager.Rooms.Single(r => r.Category.Value == RoomCategory.Spotlight)));
|
||||
AddAssert("selection vacated", () => checkRoomSelected(null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -378,6 +378,41 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}, users);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAbortMatch()
|
||||
{
|
||||
AddStep("setup client", () =>
|
||||
{
|
||||
multiplayerClient.Setup(m => m.StartMatch())
|
||||
.Callback(() =>
|
||||
{
|
||||
multiplayerClient.Raise(m => m.LoadRequested -= null);
|
||||
multiplayerClient.Object.Room!.State = MultiplayerRoomState.WaitingForLoad;
|
||||
|
||||
// The local user state doesn't really matter, so let's do the same as the base implementation for these tests.
|
||||
changeUserState(localUser.UserID, MultiplayerUserState.Idle);
|
||||
});
|
||||
|
||||
multiplayerClient.Setup(m => m.AbortMatch())
|
||||
.Callback(() =>
|
||||
{
|
||||
multiplayerClient.Object.Room!.State = MultiplayerRoomState.Open;
|
||||
raiseRoomUpdated();
|
||||
});
|
||||
});
|
||||
|
||||
// Ready
|
||||
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
||||
|
||||
// Start match
|
||||
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
||||
AddUntilStep("countdown button disabled", () => !this.ChildrenOfType<MultiplayerCountdownButton>().Single().Enabled.Value);
|
||||
|
||||
// Abort
|
||||
ClickButtonWhenEnabled<MultiplayerReadyButton>();
|
||||
AddStep("check abort request received", () => multiplayerClient.Verify(m => m.AbortMatch(), Times.Once));
|
||||
}
|
||||
|
||||
private void verifyGameplayStartFlow()
|
||||
{
|
||||
checkLocalUserState(MultiplayerUserState.Ready);
|
||||
|
||||
@@ -49,6 +49,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
LoadComponentAsync(leaderboard = new MultiSpectatorLeaderboard(clocks.Keys.Select(id => new MultiplayerRoomUser(id)).ToArray())
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Expanded = { Value = true }
|
||||
}, Add);
|
||||
});
|
||||
|
||||
@@ -79,6 +79,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddWaitStep("wait a bit", 20);
|
||||
}
|
||||
|
||||
[TestCase(2)]
|
||||
[TestCase(16)]
|
||||
public void TestTeams(int count)
|
||||
{
|
||||
int[] userIds = getPlayerIds(count);
|
||||
|
||||
start(userIds, teams: true);
|
||||
loadSpectateScreen();
|
||||
|
||||
sendFrames(userIds, 1000);
|
||||
AddWaitStep("wait a bit", 20);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleStartRequests()
|
||||
{
|
||||
@@ -411,7 +424,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
public void TestIntroStoryboardElement() => testLeadIn(b =>
|
||||
{
|
||||
var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
|
||||
sprite.TimelineGroup.Alpha.Add(Easing.None, -2000, 0, 0, 1);
|
||||
sprite.Commands.AddAlpha(Easing.None, -2000, 0, 0, 1);
|
||||
b.Storyboard.GetLayer("Background").Add(sprite);
|
||||
});
|
||||
|
||||
@@ -450,16 +463,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
private void start(int userId, int? beatmapId = null) => start(new[] { userId }, beatmapId);
|
||||
|
||||
private void start(int[] userIds, int? beatmapId = null, APIMod[]? mods = null)
|
||||
private void start(int[] userIds, int? beatmapId = null, APIMod[]? mods = null, bool teams = false)
|
||||
{
|
||||
AddStep("start play", () =>
|
||||
{
|
||||
foreach (int id in userIds)
|
||||
for (int i = 0; i < userIds.Length; i++)
|
||||
{
|
||||
int id = userIds[i];
|
||||
var user = new MultiplayerRoomUser(id)
|
||||
{
|
||||
User = new APIUser { Id = id },
|
||||
Mods = mods ?? Array.Empty<APIMod>(),
|
||||
MatchState = teams ? new TeamVersusUserState { TeamID = i % 2 } : null,
|
||||
};
|
||||
|
||||
OnlinePlayDependencies.MultiplayerClient.AddUser(user, true);
|
||||
|
||||
@@ -29,6 +29,9 @@ using osu.Game.Rulesets.Catch;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.OnlinePlay;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
@@ -690,10 +693,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
|
||||
AddUntilStep("wait for results", () => multiplayerComponents.CurrentScreen is ResultsScreen);
|
||||
|
||||
AddAssert("check is fail", () =>
|
||||
{
|
||||
var scoreInfo = ((ResultsScreen)multiplayerComponents.CurrentScreen).Score;
|
||||
|
||||
return scoreInfo?.Passed == false && scoreInfo.Rank == ScoreRank.F;
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
[FlakyTest] // See above
|
||||
[Ignore("Failing too often, needs revisiting in some future.")]
|
||||
// This test is failing even after 10 retries (see https://github.com/ppy/osu/actions/runs/6700910613/job/18208272419)
|
||||
// Something is stopping the ready button from changing states, over multiple runs.
|
||||
public void TestGameplayExitFlow()
|
||||
{
|
||||
Bindable<double>? holdDelay = null;
|
||||
@@ -999,6 +1011,43 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGameplayStartsWhileInSongSelectWithDifferentRuleset()
|
||||
{
|
||||
createRoom(() => new Room
|
||||
{
|
||||
Name = { Value = "Test Room" },
|
||||
QueueMode = { Value = QueueMode.AllPlayers },
|
||||
Playlist =
|
||||
{
|
||||
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0)).BeatmapInfo)
|
||||
{
|
||||
RulesetID = new OsuRuleset().RulesetInfo.OnlineID,
|
||||
AllowedMods = new[] { new APIMod { Acronym = "HD" } },
|
||||
},
|
||||
new PlaylistItem(beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.Ruleset.OnlineID == 1)).BeatmapInfo)
|
||||
{
|
||||
RulesetID = new TaikoRuleset().RulesetInfo.OnlineID,
|
||||
AllowedMods = new[] { new APIMod { Acronym = "HD" } },
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("select hidden", () => multiplayerClient.ChangeUserMods(new[] { new APIMod { Acronym = "HD" } }));
|
||||
AddStep("make user ready", () => multiplayerClient.ChangeState(MultiplayerUserState.Ready));
|
||||
AddStep("press edit on second item", () => this.ChildrenOfType<DrawableRoomPlaylistItem>().Single(i => i.Item.RulesetID == 1)
|
||||
.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistEditButton>().Single().TriggerClick());
|
||||
|
||||
AddUntilStep("wait for song select", () => InputManager.ChildrenOfType<MultiplayerMatchSongSelect>().FirstOrDefault()?.BeatmapSetsLoaded == true);
|
||||
AddAssert("ruleset is taiko", () => Ruleset.Value.OnlineID == 1);
|
||||
|
||||
AddStep("start match", () => multiplayerClient.StartMatch().WaitSafely());
|
||||
|
||||
AddUntilStep("wait for loading", () => multiplayerClient.ClientRoom?.State == MultiplayerRoomState.WaitingForLoad);
|
||||
AddUntilStep("wait for gameplay to start", () => multiplayerClient.ClientRoom?.State == MultiplayerRoomState.Playing);
|
||||
AddAssert("hidden is selected", () => SelectedMods.Value, () => Has.One.TypeOf(typeof(OsuModHidden)));
|
||||
}
|
||||
|
||||
private void enterGameplay()
|
||||
{
|
||||
pressReadyButton();
|
||||
|
||||
@@ -22,6 +22,7 @@ using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
@@ -286,6 +287,41 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
[FlakyTest] // See above
|
||||
public void TestModSelectOverlay()
|
||||
{
|
||||
AddStep("add playlist item", () =>
|
||||
{
|
||||
SelectedRoom.Value.Playlist.Add(new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo)
|
||||
{
|
||||
RulesetID = new OsuRuleset().RulesetInfo.OnlineID,
|
||||
RequiredMods = new[]
|
||||
{
|
||||
new APIMod(new OsuModDoubleTime { SpeedChange = { Value = 2.0 } }),
|
||||
new APIMod(new OsuModStrictTracking()),
|
||||
},
|
||||
AllowedMods = new[]
|
||||
{
|
||||
new APIMod(new OsuModFlashlight()),
|
||||
}
|
||||
});
|
||||
});
|
||||
ClickButtonWhenEnabled<MultiplayerMatchSettingsOverlay.CreateOrUpdateButton>();
|
||||
|
||||
AddUntilStep("wait for join", () => RoomJoined);
|
||||
|
||||
ClickButtonWhenEnabled<RoomSubScreen.UserModSelectButton>();
|
||||
AddAssert("mod select shows unranked", () => screen.UserModsSelectOverlay.ChildrenOfType<RankingInformationDisplay>().Single().Ranked.Value == false);
|
||||
AddAssert("score multiplier = 1.20", () => screen.UserModsSelectOverlay.ChildrenOfType<RankingInformationDisplay>().Single().ModMultiplier.Value, () => Is.EqualTo(1.2).Within(0.01));
|
||||
|
||||
AddStep("select flashlight", () => screen.UserModsSelectOverlay.ChildrenOfType<ModPanel>().Single(m => m.Mod is ModFlashlight).TriggerClick());
|
||||
AddAssert("score multiplier = 1.35", () => screen.UserModsSelectOverlay.ChildrenOfType<RankingInformationDisplay>().Single().ModMultiplier.Value, () => Is.EqualTo(1.35).Within(0.01));
|
||||
|
||||
AddStep("change flashlight setting", () => ((OsuModFlashlight)screen.UserModsSelectOverlay.SelectedMods.Value.Single()).FollowDelay.Value = 1200);
|
||||
AddAssert("score multiplier = 1.20", () => screen.UserModsSelectOverlay.ChildrenOfType<RankingInformationDisplay>().Single().ModMultiplier.Value, () => Is.EqualTo(1.2).Within(0.01));
|
||||
}
|
||||
|
||||
private partial class TestMultiplayerMatchSubScreen : MultiplayerMatchSubScreen
|
||||
{
|
||||
[Resolved(canBeNull: true)]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user