mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Merge remote-tracking branch 'upstream/master' into collapse-graph-option
This commit is contained in:
@ -10,13 +10,13 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.States;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
@ -36,7 +36,7 @@ using osuTK.Graphics;
|
||||
namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneBackgroundScreenBeatmap : ManualInputManagerTestScene
|
||||
public class TestSceneUserDimBackgrounds : ManualInputManagerTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
@ -50,26 +50,14 @@ namespace osu.Game.Tests.Visual.Background
|
||||
private DummySongSelect songSelect;
|
||||
private TestPlayerLoader playerLoader;
|
||||
private TestPlayer player;
|
||||
private DatabaseContextFactory factory;
|
||||
private BeatmapManager manager;
|
||||
private RulesetStore rulesets;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, AudioManager audio)
|
||||
{
|
||||
factory = new DatabaseContextFactory(LocalStorage);
|
||||
factory.ResetDatabase();
|
||||
|
||||
using (var usage = factory.Get())
|
||||
usage.Migrate();
|
||||
|
||||
factory.ResetDatabase();
|
||||
|
||||
using (var usage = factory.Get())
|
||||
usage.Migrate();
|
||||
|
||||
Dependencies.Cache(rulesets = new RulesetStore(factory));
|
||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, audio, host, Beatmap.Default));
|
||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
|
||||
Dependencies.Cache(new OsuConfigManager(LocalStorage));
|
||||
|
||||
manager.Import(TestResources.GetTestBeatmapForImport()).Wait();
|
||||
@ -131,20 +119,20 @@ namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
performFullSetup();
|
||||
createFakeStoryboard();
|
||||
AddStep("Storyboard Enabled", () =>
|
||||
AddStep("Enable Storyboard", () =>
|
||||
{
|
||||
player.ReplacesBackground.Value = true;
|
||||
player.StoryboardEnabled.Value = true;
|
||||
});
|
||||
waitForDim();
|
||||
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible());
|
||||
AddStep("Storyboard Disabled", () =>
|
||||
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible);
|
||||
AddStep("Disable Storyboard", () =>
|
||||
{
|
||||
player.ReplacesBackground.Value = false;
|
||||
player.StoryboardEnabled.Value = false;
|
||||
});
|
||||
waitForDim();
|
||||
AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && player.IsStoryboardInvisible());
|
||||
AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && !player.IsStoryboardVisible);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -161,22 +149,44 @@ namespace osu.Game.Tests.Visual.Background
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the <see cref="UserDimContainer"/> is properly accepting user-defined visual changes at all.
|
||||
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a background.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void DisableUserDimTest()
|
||||
public void DisableUserDimBackgroundTest()
|
||||
{
|
||||
performFullSetup();
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
AddStep("EnableUserDim disabled", () => songSelect.DimEnabled.Value = false);
|
||||
AddStep("Enable user dim", () => songSelect.DimEnabled.Value = false);
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled());
|
||||
AddStep("EnableUserDim enabled", () => songSelect.DimEnabled.Value = true);
|
||||
AddStep("Disable user dim", () => songSelect.DimEnabled.Value = true);
|
||||
waitForDim();
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a storyboard.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void DisableUserDimStoryboardTest()
|
||||
{
|
||||
performFullSetup();
|
||||
createFakeStoryboard();
|
||||
AddStep("Enable Storyboard", () =>
|
||||
{
|
||||
player.ReplacesBackground.Value = true;
|
||||
player.StoryboardEnabled.Value = true;
|
||||
});
|
||||
AddStep("Enable user dim", () => player.DimmableStoryboard.EnableUserDim.Value = true);
|
||||
AddStep("Set dim level to 1", () => songSelect.DimLevel.Value = 1f);
|
||||
waitForDim();
|
||||
AddAssert("Storyboard is invisible", () => !player.IsStoryboardVisible);
|
||||
AddStep("Disable user dim", () => player.DimmableStoryboard.EnableUserDim.Value = false);
|
||||
waitForDim();
|
||||
AddAssert("Storyboard is visible", () => player.IsStoryboardVisible);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the visual settings container retains dim and blur when pausing
|
||||
/// </summary>
|
||||
@ -199,9 +209,10 @@ namespace osu.Game.Tests.Visual.Background
|
||||
public void TransitionTest()
|
||||
{
|
||||
performFullSetup();
|
||||
var results = new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } });
|
||||
AddStep("Transition to Results", () => player.Push(results));
|
||||
AddUntilStep("Wait for results is current", results.IsCurrentScreen);
|
||||
FadeAccessibleResults results = null;
|
||||
AddStep("Transition to Results", () => player.Push(results =
|
||||
new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } })));
|
||||
AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());
|
||||
waitForDim();
|
||||
AddAssert("Screen is undimmed, original background retained", () =>
|
||||
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());
|
||||
@ -241,14 +252,15 @@ namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
player.StoryboardEnabled.Value = false;
|
||||
player.ReplacesBackground.Value = false;
|
||||
player.CurrentStoryboardContainer.Add(new OsuSpriteText
|
||||
player.DimmableStoryboard.Add(new OsuSpriteText
|
||||
{
|
||||
Size = new Vector2(250, 50),
|
||||
Size = new Vector2(500, 50),
|
||||
Alpha = 1,
|
||||
Colour = Color4.Tomato,
|
||||
Colour = Color4.White,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = "THIS IS A STORYBOARD",
|
||||
Font = new FontUsage(size: 50)
|
||||
});
|
||||
});
|
||||
|
||||
@ -268,12 +280,18 @@ namespace osu.Game.Tests.Visual.Background
|
||||
AddUntilStep("Song select has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
||||
AddStep("Set default user settings", () =>
|
||||
{
|
||||
Mods.Value = Mods.Value.Concat(new[] { new OsuModNoFail() }).ToArray();
|
||||
SelectedMods.Value = SelectedMods.Value.Concat(new[] { new OsuModNoFail() }).ToArray();
|
||||
songSelect.DimLevel.Value = 0.7f;
|
||||
songSelect.BlurLevel.Value = 0.4f;
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
rulesets?.Dispose();
|
||||
}
|
||||
|
||||
private class DummySongSelect : PlaySongSelect
|
||||
{
|
||||
protected override BackgroundScreen CreateBackground()
|
||||
@ -296,11 +314,11 @@ namespace osu.Game.Tests.Visual.Background
|
||||
config.BindWith(OsuSetting.BlurLevel, BlurLevel);
|
||||
}
|
||||
|
||||
public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)DimLevel.Value);
|
||||
public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1f - ((FadeAccessibleBackground)Background).CurrentDim);
|
||||
|
||||
public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White;
|
||||
|
||||
public bool IsUserBlurApplied() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2((float)BlurLevel.Value * 25);
|
||||
public bool IsUserBlurApplied() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2((float)BlurLevel.Value * BackgroundScreenBeatmap.USER_BLUR_FACTOR);
|
||||
|
||||
public bool IsUserBlurDisabled() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0);
|
||||
|
||||
@ -333,17 +351,7 @@ namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||
|
||||
protected override UserDimContainer CreateStoryboardContainer()
|
||||
{
|
||||
return new TestUserDimContainer(true)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 1,
|
||||
EnableUserDim = { Value = true }
|
||||
};
|
||||
}
|
||||
|
||||
public UserDimContainer CurrentStoryboardContainer => StoryboardContainer;
|
||||
public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard;
|
||||
|
||||
// Whether or not the player should be allowed to load.
|
||||
public bool BlockLoad;
|
||||
@ -357,9 +365,7 @@ namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsStoryboardVisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha == 1;
|
||||
|
||||
public bool IsStoryboardInvisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha <= 1;
|
||||
public bool IsStoryboardVisible => DimmableStoryboard.ContentDisplayed;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config, CancellationToken token)
|
||||
@ -392,15 +398,17 @@ namespace osu.Game.Tests.Visual.Background
|
||||
|
||||
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
||||
{
|
||||
protected override UserDimContainer CreateFadeContainer() => fadeContainer = new TestUserDimContainer { RelativeSizeAxes = Axes.Both };
|
||||
protected override DimmableBackground CreateFadeContainer() => dimmable = new TestDimmableBackground { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public Color4 CurrentColour => fadeContainer.CurrentColour;
|
||||
public Color4 CurrentColour => dimmable.CurrentColour;
|
||||
|
||||
public float CurrentAlpha => fadeContainer.CurrentAlpha;
|
||||
public float CurrentAlpha => dimmable.CurrentAlpha;
|
||||
|
||||
public float CurrentDim => dimmable.DimLevel;
|
||||
|
||||
public Vector2 CurrentBlur => Background.BlurSigma;
|
||||
|
||||
private TestUserDimContainer fadeContainer;
|
||||
private TestDimmableBackground dimmable;
|
||||
|
||||
public FadeAccessibleBackground(WorkingBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
@ -408,15 +416,12 @@ namespace osu.Game.Tests.Visual.Background
|
||||
}
|
||||
}
|
||||
|
||||
private class TestUserDimContainer : UserDimContainer
|
||||
private class TestDimmableBackground : BackgroundScreenBeatmap.DimmableBackground
|
||||
{
|
||||
public Color4 CurrentColour => DimContainer.Colour;
|
||||
public float CurrentAlpha => DimContainer.Alpha;
|
||||
public Color4 CurrentColour => Content.Colour;
|
||||
public float CurrentAlpha => Content.Alpha;
|
||||
|
||||
public TestUserDimContainer(bool isStoryboard = false)
|
||||
: base(isStoryboard)
|
||||
{
|
||||
}
|
||||
public new float DimLevel => base.DimLevel;
|
||||
}
|
||||
}
|
||||
}
|
112
osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs
Normal file
112
osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs
Normal file
@ -0,0 +1,112 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
public class TestSceneUserDimContainer : OsuTestScene
|
||||
{
|
||||
private TestUserDimContainer userDimContainer;
|
||||
|
||||
private readonly BindableBool isBreakTime = new BindableBool();
|
||||
|
||||
private Bindable<bool> lightenDuringBreaks = new Bindable<bool>();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
lightenDuringBreaks = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks);
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
Child = userDimContainer = new TestUserDimContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new Box
|
||||
{
|
||||
Colour = Color4.White,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
};
|
||||
|
||||
userDimContainer.IsBreakTime.BindTo(isBreakTime);
|
||||
isBreakTime.Value = false;
|
||||
|
||||
lightenDuringBreaks.Value = false;
|
||||
});
|
||||
|
||||
private const float test_user_dim = 0.6f;
|
||||
private const float test_user_dim_lightened = test_user_dim - UserDimContainer.BREAK_LIGHTEN_AMOUNT;
|
||||
|
||||
[TestCase(test_user_dim, test_user_dim_lightened)]
|
||||
[TestCase(0.2f, 0.0f)]
|
||||
[TestCase(0.0f, 0.0f)]
|
||||
public void TestBreakLightening(float userDim, float expectedBreakDim)
|
||||
{
|
||||
AddStep($"set dim level {userDim}", () => userDimContainer.UserDimLevel.Value = userDim);
|
||||
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
||||
|
||||
AddStep("set break", () => isBreakTime.Value = true);
|
||||
AddUntilStep("has lightened", () => userDimContainer.DimEqual(expectedBreakDim));
|
||||
AddStep("clear break", () => isBreakTime.Value = false);
|
||||
AddUntilStep("not lightened", () => userDimContainer.DimEqual(userDim));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEnableSettingDuringBreak()
|
||||
{
|
||||
AddStep("set dim level 0.6", () => userDimContainer.UserDimLevel.Value = test_user_dim);
|
||||
|
||||
AddStep("set break", () => isBreakTime.Value = true);
|
||||
AddUntilStep("not lightened", () => userDimContainer.DimEqual(test_user_dim));
|
||||
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
||||
AddUntilStep("has lightened", () => userDimContainer.DimEqual(test_user_dim_lightened));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDisableSettingDuringBreak()
|
||||
{
|
||||
AddStep("set dim level 0.6", () => userDimContainer.UserDimLevel.Value = test_user_dim);
|
||||
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
||||
|
||||
AddStep("set break", () => isBreakTime.Value = true);
|
||||
AddUntilStep("has lightened", () => userDimContainer.DimEqual(test_user_dim_lightened));
|
||||
AddStep("clear lighten during break", () => lightenDuringBreaks.Value = false);
|
||||
AddUntilStep("not lightened", () => userDimContainer.DimEqual(test_user_dim));
|
||||
AddStep("clear break", () => isBreakTime.Value = false);
|
||||
AddUntilStep("not lightened", () => userDimContainer.DimEqual(test_user_dim));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestIgnoreUserSettings()
|
||||
{
|
||||
AddStep("set dim level 0.6", () => userDimContainer.UserDimLevel.Value = test_user_dim);
|
||||
AddUntilStep("dim reached", () => userDimContainer.DimEqual(test_user_dim));
|
||||
|
||||
AddStep("ignore settings", () => userDimContainer.IgnoreUserSettings.Value = true);
|
||||
AddUntilStep("no dim", () => userDimContainer.DimEqual(0));
|
||||
AddStep("set break", () => isBreakTime.Value = true);
|
||||
AddAssert("no dim", () => userDimContainer.DimEqual(0));
|
||||
AddStep("clear break", () => isBreakTime.Value = false);
|
||||
AddAssert("no dim", () => userDimContainer.DimEqual(0));
|
||||
}
|
||||
|
||||
private class TestUserDimContainer : UserDimContainer
|
||||
{
|
||||
public bool DimEqual(float expectedDimLevel) => Content.Colour == OsuColour.Gray(1f - expectedDimLevel);
|
||||
|
||||
public new Bindable<double> UserDimLevel => base.UserDimLevel;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,16 +3,20 @@
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using static osu.Game.Tests.Visual.Components.TestScenePreviewTrackManager.TestPreviewTrackManager;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Components
|
||||
{
|
||||
public class TestScenePreviewTrackManager : OsuTestScene, IPreviewTrackOwner
|
||||
{
|
||||
private readonly PreviewTrackManager trackManager = new TestPreviewTrackManager();
|
||||
private readonly TestPreviewTrackManager trackManager = new TestPreviewTrackManager();
|
||||
|
||||
private AudioManager audio;
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
@ -23,8 +27,10 @@ namespace osu.Game.Tests.Visual.Components
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
this.audio = audio;
|
||||
|
||||
Add(trackManager);
|
||||
}
|
||||
|
||||
@ -34,6 +40,7 @@ namespace osu.Game.Tests.Visual.Components
|
||||
PreviewTrack track = null;
|
||||
|
||||
AddStep("get track", () => track = getOwnedTrack());
|
||||
AddUntilStep("wait loaded", () => track.IsLoaded);
|
||||
AddStep("start", () => track.Start());
|
||||
AddAssert("started", () => track.IsRunning);
|
||||
AddStep("stop", () => track.Stop());
|
||||
@ -52,10 +59,15 @@ namespace osu.Game.Tests.Visual.Components
|
||||
track2 = getOwnedTrack();
|
||||
});
|
||||
|
||||
AddUntilStep("wait loaded", () => track1.IsLoaded && track2.IsLoaded);
|
||||
|
||||
AddStep("start track 1", () => track1.Start());
|
||||
AddStep("start track 2", () => track2.Start());
|
||||
AddAssert("track 1 stopped", () => !track1.IsRunning);
|
||||
AddAssert("track 2 started", () => track2.IsRunning);
|
||||
AddStep("start track 1", () => track1.Start());
|
||||
AddAssert("track 2 stopped", () => !track2.IsRunning);
|
||||
AddAssert("track 1 started", () => track1.IsRunning);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -64,6 +76,7 @@ namespace osu.Game.Tests.Visual.Components
|
||||
PreviewTrack track = null;
|
||||
|
||||
AddStep("get track", () => track = getOwnedTrack());
|
||||
AddUntilStep("wait loaded", () => track.IsLoaded);
|
||||
AddStep("start", () => track.Start());
|
||||
AddStep("stop by owner", () => trackManager.StopAnyPlaying(this));
|
||||
AddAssert("stopped", () => !track.IsRunning);
|
||||
@ -76,6 +89,7 @@ namespace osu.Game.Tests.Visual.Components
|
||||
PreviewTrack track = null;
|
||||
|
||||
AddStep("get track", () => Add(owner = new TestTrackOwner(track = getTrack())));
|
||||
AddUntilStep("wait loaded", () => track.IsLoaded);
|
||||
AddStep("start", () => track.Start());
|
||||
AddStep("attempt stop", () => trackManager.StopAnyPlaying(this));
|
||||
AddAssert("not stopped", () => track.IsRunning);
|
||||
@ -83,22 +97,100 @@ namespace osu.Game.Tests.Visual.Components
|
||||
AddAssert("stopped", () => !track.IsRunning);
|
||||
}
|
||||
|
||||
private PreviewTrack getTrack() => trackManager.Get(null);
|
||||
[Test]
|
||||
public void TestNonPresentTrack()
|
||||
{
|
||||
TestPreviewTrack track = null;
|
||||
|
||||
private PreviewTrack getOwnedTrack()
|
||||
AddStep("get non-present track", () =>
|
||||
{
|
||||
Add(new TestTrackOwner(track = getTrack()));
|
||||
track.Alpha = 0;
|
||||
});
|
||||
AddUntilStep("wait loaded", () => track.IsLoaded);
|
||||
AddStep("start", () => track.Start());
|
||||
AddStep("seek to end", () => track.Track.Seek(track.Track.Length));
|
||||
AddAssert("track stopped", () => !track.IsRunning);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that <see cref="PreviewTrackManager.CurrentTrack"/> changes correctly.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCurrentTrackChanges()
|
||||
{
|
||||
PreviewTrack track = null;
|
||||
TestTrackOwner owner = null;
|
||||
|
||||
AddStep("get track", () => Add(owner = new TestTrackOwner(track = getTrack())));
|
||||
AddUntilStep("wait loaded", () => track.IsLoaded);
|
||||
AddStep("start track", () => track.Start());
|
||||
AddAssert("current is track", () => trackManager.CurrentTrack == track);
|
||||
AddStep("pause manager updates", () => trackManager.AllowUpdate = false);
|
||||
AddStep("stop any playing", () => trackManager.StopAnyPlaying(owner));
|
||||
AddAssert("current not changed", () => trackManager.CurrentTrack == track);
|
||||
AddStep("resume manager updates", () => trackManager.AllowUpdate = true);
|
||||
AddAssert("current is null", () => trackManager.CurrentTrack == null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that <see cref="PreviewTrackManager"/> mutes game-wide audio tracks correctly.
|
||||
/// </summary>
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void TestEnsureMutingCorrectly(bool stopAnyPlaying)
|
||||
{
|
||||
PreviewTrack track = null;
|
||||
TestTrackOwner owner = null;
|
||||
|
||||
AddStep("ensure volume not zero", () =>
|
||||
{
|
||||
if (audio.Volume.Value == 0)
|
||||
audio.Volume.Value = 1;
|
||||
|
||||
if (audio.VolumeTrack.Value == 0)
|
||||
audio.VolumeTrack.Value = 1;
|
||||
});
|
||||
|
||||
AddAssert("game not muted", () => audio.Tracks.AggregateVolume.Value != 0);
|
||||
|
||||
AddStep("get track", () => Add(owner = new TestTrackOwner(track = getTrack())));
|
||||
AddUntilStep("wait loaded", () => track.IsLoaded);
|
||||
AddStep("start track", () => track.Start());
|
||||
AddAssert("game is muted", () => audio.Tracks.AggregateVolume.Value == 0);
|
||||
|
||||
if (stopAnyPlaying)
|
||||
AddStep("stop any playing", () => trackManager.StopAnyPlaying(owner));
|
||||
else
|
||||
AddStep("stop track", () => track.Stop());
|
||||
|
||||
AddAssert("game not muted", () => audio.Tracks.AggregateVolume.Value != 0);
|
||||
}
|
||||
|
||||
private TestPreviewTrack getTrack() => (TestPreviewTrack)trackManager.Get(null);
|
||||
|
||||
private TestPreviewTrack getOwnedTrack()
|
||||
{
|
||||
var track = getTrack();
|
||||
|
||||
Add(track);
|
||||
LoadComponentAsync(track, Add);
|
||||
|
||||
return track;
|
||||
}
|
||||
|
||||
private class TestTrackOwner : CompositeDrawable, IPreviewTrackOwner
|
||||
{
|
||||
private readonly PreviewTrack track;
|
||||
|
||||
public TestTrackOwner(PreviewTrack track)
|
||||
{
|
||||
AddInternal(track);
|
||||
this.track = track;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
LoadComponentAsync(track, AddInternal);
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
@ -109,14 +201,28 @@ namespace osu.Game.Tests.Visual.Components
|
||||
}
|
||||
}
|
||||
|
||||
private class TestPreviewTrackManager : PreviewTrackManager
|
||||
public class TestPreviewTrackManager : PreviewTrackManager
|
||||
{
|
||||
public bool AllowUpdate = true;
|
||||
|
||||
public new PreviewTrack CurrentTrack => base.CurrentTrack;
|
||||
|
||||
protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore);
|
||||
|
||||
protected class TestPreviewTrack : TrackManagerPreviewTrack
|
||||
public override bool UpdateSubTree()
|
||||
{
|
||||
if (!AllowUpdate)
|
||||
return true;
|
||||
|
||||
return base.UpdateSubTree();
|
||||
}
|
||||
|
||||
public class TestPreviewTrack : TrackManagerPreviewTrack
|
||||
{
|
||||
private readonly ITrackStore trackManager;
|
||||
|
||||
public new Track Track => base.Track;
|
||||
|
||||
public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager)
|
||||
: base(beatmapSetInfo, trackManager)
|
||||
{
|
||||
|
36
osu.Game.Tests/Visual/Editor/TestSceneComposeScreen.cs
Normal file
36
osu.Game.Tests/Visual/Editor/TestSceneComposeScreen.cs
Normal file
@ -0,0 +1,36 @@
|
||||
// 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.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneComposeScreen : EditorClockTestScene
|
||||
{
|
||||
[Cached(typeof(EditorBeatmap))]
|
||||
[Cached(typeof(IBeatSnapProvider))]
|
||||
private readonly EditorBeatmap editorBeatmap =
|
||||
new EditorBeatmap(new OsuBeatmap
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Ruleset = new OsuRuleset().RulesetInfo
|
||||
}
|
||||
});
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
|
||||
|
||||
Child = new ComposeScreen();
|
||||
}
|
||||
}
|
||||
}
|
169
osu.Game.Tests/Visual/Editor/TestSceneDistanceSnapGrid.cs
Normal file
169
osu.Game.Tests/Visual/Editor/TestSceneDistanceSnapGrid.cs
Normal file
@ -0,0 +1,169 @@
|
||||
// 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;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
public class TestSceneDistanceSnapGrid : EditorClockTestScene
|
||||
{
|
||||
private const double beat_length = 100;
|
||||
private static readonly Vector2 grid_position = new Vector2(512, 384);
|
||||
|
||||
[Cached(typeof(EditorBeatmap))]
|
||||
private readonly EditorBeatmap editorBeatmap;
|
||||
|
||||
[Cached(typeof(IDistanceSnapProvider))]
|
||||
private readonly SnapProvider snapProvider = new SnapProvider();
|
||||
|
||||
public TestSceneDistanceSnapGrid()
|
||||
{
|
||||
editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||
editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = beat_length });
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.SlateGray
|
||||
},
|
||||
new TestDistanceSnapGrid()
|
||||
};
|
||||
});
|
||||
|
||||
[TestCase(1)]
|
||||
[TestCase(2)]
|
||||
[TestCase(3)]
|
||||
[TestCase(4)]
|
||||
[TestCase(6)]
|
||||
[TestCase(8)]
|
||||
[TestCase(12)]
|
||||
[TestCase(16)]
|
||||
public void TestBeatDivisor(int divisor)
|
||||
{
|
||||
AddStep($"set beat divisor = {divisor}", () => BeatDivisor.Value = divisor);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLimitedDistance()
|
||||
{
|
||||
AddStep("create limited grid", () =>
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.SlateGray
|
||||
},
|
||||
new TestDistanceSnapGrid(100)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private class TestDistanceSnapGrid : DistanceSnapGrid
|
||||
{
|
||||
public new float DistanceSpacing => base.DistanceSpacing;
|
||||
|
||||
public TestDistanceSnapGrid(double? endTime = null)
|
||||
: base(grid_position, 0, endTime)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CreateContent(Vector2 startPosition)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5),
|
||||
Position = startPosition
|
||||
});
|
||||
|
||||
int beatIndex = 0;
|
||||
|
||||
for (float s = startPosition.X + DistanceSpacing; s <= DrawWidth && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5, 10),
|
||||
Position = new Vector2(s, startPosition.Y),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
|
||||
for (float s = startPosition.X - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5, 10),
|
||||
Position = new Vector2(s, startPosition.Y),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
|
||||
for (float s = startPosition.Y + DistanceSpacing; s <= DrawHeight && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(10, 5),
|
||||
Position = new Vector2(startPosition.X, s),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
|
||||
for (float s = startPosition.Y - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(10, 5),
|
||||
Position = new Vector2(startPosition.X, s),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public override (Vector2 position, double time) GetSnappedPosition(Vector2 screenSpacePosition)
|
||||
=> (Vector2.Zero, 0);
|
||||
}
|
||||
|
||||
private class SnapProvider : IDistanceSnapProvider
|
||||
{
|
||||
public (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time) => (position, time);
|
||||
|
||||
public float GetBeatSnapDistanceAt(double referenceTime) => 10;
|
||||
|
||||
public float DurationToDistance(double referenceTime, double duration) => (float)duration;
|
||||
|
||||
public double DistanceToDuration(double referenceTime, float distance) => distance;
|
||||
|
||||
public double GetSnappedDurationFromDistance(double referenceTime, float distance) => 0;
|
||||
|
||||
public float GetSnappedDistanceFromDistance(double referenceTime, float distance) => 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Edit.Compose;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneEditorCompose : EditorClockTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(ComposeScreen) };
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
Child = new ComposeScreen();
|
||||
}
|
||||
}
|
||||
}
|
@ -10,9 +10,11 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -25,6 +27,7 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(TimelineArea),
|
||||
typeof(TimelineHitObjectDisplay),
|
||||
typeof(Timeline),
|
||||
typeof(TimelineButton),
|
||||
typeof(CentreMarker)
|
||||
@ -35,6 +38,10 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
Beatmap.Value = new WaveformTestBeatmap(audio);
|
||||
|
||||
var editorBeatmap = new EditorBeatmap((Beatmap<HitObject>)Beatmap.Value.Beatmap);
|
||||
|
||||
Dependencies.Cache(editorBeatmap);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
@ -50,6 +57,7 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
},
|
||||
new TimelineArea
|
||||
{
|
||||
Child = new TimelineHitObjectDisplay(editorBeatmap),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -62,8 +70,11 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
private readonly Drawable marker;
|
||||
|
||||
private readonly IBindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||
private IAdjustableClock adjustableClock;
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IAdjustableClock adjustableClock { get; set; }
|
||||
|
||||
public AudioVisualiser()
|
||||
{
|
||||
@ -85,13 +96,6 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAdjustableClock adjustableClock, IBindable<WorkingBeatmap> beatmap)
|
||||
{
|
||||
this.adjustableClock = adjustableClock;
|
||||
this.beatmap.BindTo(beatmap);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -101,7 +105,7 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
}
|
||||
}
|
||||
|
||||
private class StartStopButton : Button
|
||||
private class StartStopButton : OsuButton
|
||||
{
|
||||
private IAdjustableClock adjustableClock;
|
||||
private bool started;
|
||||
|
@ -28,18 +28,7 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
var testBeatmap = new Beatmap
|
||||
{
|
||||
ControlPointInfo = new ControlPointInfo
|
||||
{
|
||||
TimingPoints =
|
||||
{
|
||||
new TimingControlPoint { Time = 0, BeatLength = 200 },
|
||||
new TimingControlPoint { Time = 100, BeatLength = 400 },
|
||||
new TimingControlPoint { Time = 175, BeatLength = 800 },
|
||||
new TimingControlPoint { Time = 350, BeatLength = 200 },
|
||||
new TimingControlPoint { Time = 450, BeatLength = 100 },
|
||||
new TimingControlPoint { Time = 500, BeatLength = 307.69230769230802 }
|
||||
}
|
||||
},
|
||||
ControlPointInfo = new ControlPointInfo(),
|
||||
HitObjects =
|
||||
{
|
||||
new HitCircle { StartTime = 0 },
|
||||
@ -47,6 +36,13 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
}
|
||||
};
|
||||
|
||||
testBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 200 });
|
||||
testBeatmap.ControlPointInfo.Add(100, new TimingControlPoint { BeatLength = 400 });
|
||||
testBeatmap.ControlPointInfo.Add(175, new TimingControlPoint { BeatLength = 800 });
|
||||
testBeatmap.ControlPointInfo.Add(350, new TimingControlPoint { BeatLength = 200 });
|
||||
testBeatmap.ControlPointInfo.Add(450, new TimingControlPoint { BeatLength = 100 });
|
||||
testBeatmap.ControlPointInfo.Add(500, new TimingControlPoint { BeatLength = 307.69230769230802 });
|
||||
|
||||
Beatmap.Value = CreateWorkingBeatmap(testBeatmap);
|
||||
|
||||
Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock };
|
||||
|
@ -16,15 +16,14 @@ using osu.Game.Rulesets.Osu.Edit;
|
||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit.Compose;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
[TestFixture]
|
||||
[Cached(Type = typeof(IPlacementHandler))]
|
||||
public class TestSceneHitObjectComposer : OsuTestScene, IPlacementHandler
|
||||
public class TestSceneHitObjectComposer : EditorClockTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
@ -39,8 +38,6 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
typeof(HitCirclePlacementBlueprint),
|
||||
};
|
||||
|
||||
private HitObjectComposer composer;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -63,19 +60,15 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
},
|
||||
});
|
||||
|
||||
var editorBeatmap = new EditorBeatmap(Beatmap.Value.GetPlayableBeatmap(new OsuRuleset().RulesetInfo));
|
||||
|
||||
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
Dependencies.CacheAs<IAdjustableClock>(clock);
|
||||
Dependencies.CacheAs<IFrameBasedClock>(clock);
|
||||
Dependencies.CacheAs(editorBeatmap);
|
||||
Dependencies.CacheAs<IBeatSnapProvider>(editorBeatmap);
|
||||
|
||||
Child = composer = new OsuHitObjectComposer(new OsuRuleset());
|
||||
Child = new OsuHitObjectComposer(new OsuRuleset());
|
||||
}
|
||||
|
||||
public void BeginPlacement(HitObject hitObject)
|
||||
{
|
||||
}
|
||||
|
||||
public void EndPlacement(HitObject hitObject) => composer.Add(hitObject);
|
||||
|
||||
public void Delete(HitObject hitObject) => composer.Remove(hitObject);
|
||||
}
|
||||
}
|
||||
|
39
osu.Game.Tests/Visual/Editor/TestSceneTimingScreen.cs
Normal file
39
osu.Game.Tests/Visual/Editor/TestSceneTimingScreen.cs
Normal file
@ -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;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Timing;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneTimingScreen : EditorClockTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ControlPointTable),
|
||||
typeof(ControlPointSettings),
|
||||
typeof(Section<>),
|
||||
typeof(TimingSection),
|
||||
typeof(EffectSection),
|
||||
typeof(SampleSection),
|
||||
typeof(DifficultySection),
|
||||
typeof(RowAttribute)
|
||||
};
|
||||
|
||||
[Cached(typeof(EditorBeatmap))]
|
||||
private readonly EditorBeatmap editorBeatmap = new EditorBeatmap(new OsuBeatmap());
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
|
||||
Child = new TimingScreen();
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
|
@ -3,25 +3,40 @@
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Storyboards;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
[Description("Player instantiated with an autoplay mod.")]
|
||||
public class TestSceneAutoplay : AllPlayersTestScene
|
||||
{
|
||||
private ClockBackedTestWorkingBeatmap.TrackVirtualManual track;
|
||||
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
Mods.Value = Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
||||
SelectedMods.Value = SelectedMods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
||||
return new ScoreAccessiblePlayer();
|
||||
}
|
||||
|
||||
protected override void AddCheckSteps()
|
||||
{
|
||||
AddUntilStep("score above zero", () => ((ScoreAccessiblePlayer)Player).ScoreProcessor.TotalScore.Value > 0);
|
||||
AddUntilStep("key counter counted keys", () => ((ScoreAccessiblePlayer)Player).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||
AddUntilStep("key counter counted keys", () => ((ScoreAccessiblePlayer)Player).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 2));
|
||||
AddStep("rewind", () => track.Seek(-10000));
|
||||
AddUntilStep("key counter reset", () => ((ScoreAccessiblePlayer)Player).HUDOverlay.KeyCounter.Children.All(kc => kc.CountPresses == 0));
|
||||
}
|
||||
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||
{
|
||||
var working = base.CreateWorkingBeatmap(beatmap, storyboard);
|
||||
|
||||
track = (ClockBackedTestWorkingBeatmap.TrackVirtualManual)working.Track;
|
||||
|
||||
return working;
|
||||
}
|
||||
|
||||
private class ScoreAccessiblePlayer : TestPlayer
|
||||
@ -29,6 +44,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||
public new HUDOverlay HUDOverlay => base.HUDOverlay;
|
||||
|
||||
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
|
||||
|
||||
public ScoreAccessiblePlayer()
|
||||
: base(false, false)
|
||||
{
|
||||
|
@ -1,8 +1,11 @@
|
||||
// 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.Timing;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
@ -11,78 +14,185 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[TestFixture]
|
||||
public class TestSceneBreakOverlay : OsuTestScene
|
||||
{
|
||||
private readonly BreakOverlay breakOverlay;
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(BreakOverlay),
|
||||
};
|
||||
|
||||
private readonly TestBreakOverlay breakOverlay;
|
||||
|
||||
private readonly IReadOnlyList<BreakPeriod> testBreaks = new List<BreakPeriod>
|
||||
{
|
||||
new BreakPeriod
|
||||
{
|
||||
StartTime = 1000,
|
||||
EndTime = 5000,
|
||||
},
|
||||
new BreakPeriod
|
||||
{
|
||||
StartTime = 6000,
|
||||
EndTime = 13500,
|
||||
},
|
||||
};
|
||||
|
||||
public TestSceneBreakOverlay()
|
||||
{
|
||||
Child = breakOverlay = new BreakOverlay(true);
|
||||
|
||||
AddStep("2s break", () => startBreak(2000));
|
||||
AddStep("5s break", () => startBreak(5000));
|
||||
AddStep("10s break", () => startBreak(10000));
|
||||
AddStep("15s break", () => startBreak(15000));
|
||||
AddStep("2s, 2s", startMultipleBreaks);
|
||||
AddStep("0.5s, 0.7s, 1s, 2s", startAnotherMultipleBreaks);
|
||||
Add(breakOverlay = new TestBreakOverlay(true));
|
||||
}
|
||||
|
||||
private void startBreak(double duration)
|
||||
[Test]
|
||||
public void TestShowBreaks()
|
||||
{
|
||||
breakOverlay.Breaks = new List<BreakPeriod>
|
||||
setClock(false);
|
||||
|
||||
addShowBreakStep(2);
|
||||
addShowBreakStep(5);
|
||||
addShowBreakStep(15);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoEffectsBreak()
|
||||
{
|
||||
var shortBreak = new BreakPeriod { EndTime = 500 };
|
||||
|
||||
setClock(true);
|
||||
loadBreaksStep("short break", new[] { shortBreak });
|
||||
|
||||
addBreakSeeks(shortBreak, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleBreaks()
|
||||
{
|
||||
setClock(true);
|
||||
loadBreaksStep("multiple breaks", testBreaks);
|
||||
|
||||
foreach (var b in testBreaks)
|
||||
addBreakSeeks(b, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRewindBreaks()
|
||||
{
|
||||
setClock(true);
|
||||
loadBreaksStep("multiple breaks", testBreaks);
|
||||
|
||||
foreach (var b in testBreaks.Reverse())
|
||||
addBreakSeeks(b, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSkipBreaks()
|
||||
{
|
||||
setClock(true);
|
||||
loadBreaksStep("multiple breaks", testBreaks);
|
||||
|
||||
seekAndAssertBreak("seek to break start", testBreaks[1].StartTime, true);
|
||||
AddAssert("is skipped to break #2", () => breakOverlay.CurrentBreakIndex == 1);
|
||||
|
||||
seekAndAssertBreak("seek to break middle", testBreaks[1].StartTime + testBreaks[1].Duration / 2, true);
|
||||
seekAndAssertBreak("seek to break end", testBreaks[1].EndTime, false);
|
||||
seekAndAssertBreak("seek to break after end", testBreaks[1].EndTime + 500, false);
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void TestBeforeGameplayStart(bool withBreaks)
|
||||
{
|
||||
setClock(true);
|
||||
|
||||
if (withBreaks)
|
||||
loadBreaksStep("multiple breaks", testBreaks);
|
||||
|
||||
seekAndAssertBreak("seek to break intro time", -100, true);
|
||||
seekAndAssertBreak("seek to break intro time", 0, false);
|
||||
}
|
||||
|
||||
private void addShowBreakStep(double seconds)
|
||||
{
|
||||
AddStep($"show '{seconds}s' break", () => breakOverlay.Breaks = new List<BreakPeriod>
|
||||
{
|
||||
new BreakPeriod
|
||||
{
|
||||
StartTime = Clock.CurrentTime,
|
||||
EndTime = Clock.CurrentTime + duration,
|
||||
EndTime = Clock.CurrentTime + seconds * 1000,
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void startMultipleBreaks()
|
||||
private void setClock(bool useManual)
|
||||
{
|
||||
double currentTime = Clock.CurrentTime;
|
||||
|
||||
breakOverlay.Breaks = new List<BreakPeriod>
|
||||
{
|
||||
new BreakPeriod
|
||||
{
|
||||
StartTime = currentTime,
|
||||
EndTime = currentTime + 2000,
|
||||
},
|
||||
new BreakPeriod
|
||||
{
|
||||
StartTime = currentTime + 4000,
|
||||
EndTime = currentTime + 6000,
|
||||
}
|
||||
};
|
||||
AddStep($"set {(useManual ? "manual" : "realtime")} clock", () => breakOverlay.SwitchClock(useManual));
|
||||
}
|
||||
|
||||
private void startAnotherMultipleBreaks()
|
||||
private void loadBreaksStep(string breakDescription, IReadOnlyList<BreakPeriod> breaks)
|
||||
{
|
||||
double currentTime = Clock.CurrentTime;
|
||||
AddStep($"load {breakDescription}", () => breakOverlay.Breaks = breaks);
|
||||
seekAndAssertBreak("seek back to 0", 0, false);
|
||||
}
|
||||
|
||||
breakOverlay.Breaks = new List<BreakPeriod>
|
||||
private void addBreakSeeks(BreakPeriod b, bool isReversed)
|
||||
{
|
||||
if (isReversed)
|
||||
{
|
||||
new BreakPeriod // Duration is less than 650 - too short to appear
|
||||
{
|
||||
StartTime = currentTime,
|
||||
EndTime = currentTime + 500,
|
||||
},
|
||||
new BreakPeriod
|
||||
{
|
||||
StartTime = currentTime + 1500,
|
||||
EndTime = currentTime + 2200,
|
||||
},
|
||||
new BreakPeriod
|
||||
{
|
||||
StartTime = currentTime + 3200,
|
||||
EndTime = currentTime + 4200,
|
||||
},
|
||||
new BreakPeriod
|
||||
{
|
||||
StartTime = currentTime + 5200,
|
||||
EndTime = currentTime + 7200,
|
||||
}
|
||||
};
|
||||
seekAndAssertBreak("seek to break after end", b.EndTime + 500, false);
|
||||
seekAndAssertBreak("seek to break end", b.EndTime, false);
|
||||
seekAndAssertBreak("seek to break middle", b.StartTime + b.Duration / 2, b.HasEffect);
|
||||
seekAndAssertBreak("seek to break start", b.StartTime, b.HasEffect);
|
||||
}
|
||||
else
|
||||
{
|
||||
seekAndAssertBreak("seek to break start", b.StartTime, b.HasEffect);
|
||||
seekAndAssertBreak("seek to break middle", b.StartTime + b.Duration / 2, b.HasEffect);
|
||||
seekAndAssertBreak("seek to break end", b.EndTime, false);
|
||||
seekAndAssertBreak("seek to break after end", b.EndTime + 500, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void seekAndAssertBreak(string seekStepDescription, double time, bool shouldBeBreak)
|
||||
{
|
||||
AddStep(seekStepDescription, () => breakOverlay.ManualClockTime = time);
|
||||
AddAssert($"is{(!shouldBeBreak ? " not" : string.Empty)} break time", () =>
|
||||
{
|
||||
breakOverlay.ProgressTime();
|
||||
return breakOverlay.IsBreakTime.Value == shouldBeBreak;
|
||||
});
|
||||
}
|
||||
|
||||
private class TestBreakOverlay : BreakOverlay
|
||||
{
|
||||
private readonly FramedClock framedManualClock;
|
||||
private readonly ManualClock manualClock;
|
||||
private IFrameBasedClock originalClock;
|
||||
|
||||
public new int CurrentBreakIndex => base.CurrentBreakIndex;
|
||||
|
||||
public double ManualClockTime
|
||||
{
|
||||
get => manualClock.CurrentTime;
|
||||
set => manualClock.CurrentTime = value;
|
||||
}
|
||||
|
||||
public TestBreakOverlay(bool letterboxing)
|
||||
: base(letterboxing)
|
||||
{
|
||||
framedManualClock = new FramedClock(manualClock = new ManualClock());
|
||||
ProcessCustomClock = false;
|
||||
}
|
||||
|
||||
public void ProgressTime()
|
||||
{
|
||||
framedManualClock.ProcessFrame();
|
||||
Update();
|
||||
}
|
||||
|
||||
public void SwitchClock(bool setManual) => Clock = setManual ? framedManualClock : originalClock;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
originalClock = Clock;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,329 @@
|
||||
// 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.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Difficulty;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneDrawableScrollingRuleset : OsuTestScene
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount of time visible by the "view window" of the playfield.
|
||||
/// All hitobjects added through <see cref="createBeatmap"/> are spaced apart by this value, such that for a beat length of 1000,
|
||||
/// there will be at most 2 hitobjects visible in the "view window".
|
||||
/// </summary>
|
||||
private const double time_range = 1000;
|
||||
|
||||
private readonly ManualClock testClock = new ManualClock();
|
||||
private TestDrawableScrollingRuleset drawableRuleset;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() => testClock.CurrentTime = 0);
|
||||
|
||||
[Test]
|
||||
public void TestRelativeBeatLengthScaleSingleTimingPoint()
|
||||
{
|
||||
var beatmap = createBeatmap();
|
||||
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range / 2 });
|
||||
|
||||
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
||||
|
||||
assertPosition(0, 0f);
|
||||
|
||||
// The single timing point is 1x speed relative to itself, such that the hitobject occurring time_range milliseconds later should appear
|
||||
// at the bottom of the view window regardless of the timing point's beat length
|
||||
assertPosition(1, 1f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRelativeBeatLengthScaleTimingPointBeyondEndDoesNotBecomeDominant()
|
||||
{
|
||||
var beatmap = createBeatmap();
|
||||
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range / 2 });
|
||||
beatmap.ControlPointInfo.Add(12000, new TimingControlPoint { BeatLength = time_range });
|
||||
beatmap.ControlPointInfo.Add(100000, new TimingControlPoint { BeatLength = time_range });
|
||||
|
||||
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
||||
|
||||
assertPosition(0, 0f);
|
||||
assertPosition(1, 1f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRelativeBeatLengthScaleFromSecondTimingPoint()
|
||||
{
|
||||
var beatmap = createBeatmap();
|
||||
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
|
||||
beatmap.ControlPointInfo.Add(3 * time_range, new TimingControlPoint { BeatLength = time_range / 2 });
|
||||
|
||||
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
||||
|
||||
// The first timing point should have a relative velocity of 2
|
||||
assertPosition(0, 0f);
|
||||
assertPosition(1, 0.5f);
|
||||
assertPosition(2, 1f);
|
||||
|
||||
// Move to the second timing point
|
||||
setTime(3 * time_range);
|
||||
assertPosition(3, 0f);
|
||||
|
||||
// As above, this is the timing point that is 1x speed relative to itself, so the hitobject occurring time_range milliseconds later should be at the bottom of the view window
|
||||
assertPosition(4, 1f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNonRelativeScale()
|
||||
{
|
||||
var beatmap = createBeatmap();
|
||||
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
|
||||
beatmap.ControlPointInfo.Add(3 * time_range, new TimingControlPoint { BeatLength = time_range / 2 });
|
||||
|
||||
createTest(beatmap);
|
||||
|
||||
assertPosition(0, 0f);
|
||||
assertPosition(1, 1);
|
||||
|
||||
// Move to the second timing point
|
||||
setTime(3 * time_range);
|
||||
assertPosition(3, 0f);
|
||||
|
||||
// For a beat length of 500, the view window of this timing point is elongated 2x (1000 / 500), such that the second hitobject is two TimeRanges away (offscreen)
|
||||
// To bring it on-screen, half TimeRange is added to the current time, bringing the second half of the view window into view, and the hitobject should appear at the bottom
|
||||
setTime(3 * time_range + time_range / 2);
|
||||
assertPosition(4, 1f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSliderMultiplierDoesNotAffectRelativeBeatLength()
|
||||
{
|
||||
var beatmap = createBeatmap();
|
||||
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
|
||||
beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2;
|
||||
|
||||
createTest(beatmap, d => d.RelativeScaleBeatLengthsOverride = true);
|
||||
AddStep("adjust time range", () => drawableRuleset.TimeRange.Value = 5000);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
assertPosition(i, i / 5f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSliderMultiplierAffectsNonRelativeBeatLength()
|
||||
{
|
||||
var beatmap = createBeatmap();
|
||||
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
|
||||
beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2;
|
||||
|
||||
createTest(beatmap);
|
||||
AddStep("adjust time range", () => drawableRuleset.TimeRange.Value = 2000);
|
||||
|
||||
assertPosition(0, 0);
|
||||
assertPosition(1, 1);
|
||||
}
|
||||
|
||||
private void assertPosition(int index, float relativeY) => AddAssert($"hitobject {index} at {relativeY}",
|
||||
() => Precision.AlmostEquals(drawableRuleset.Playfield.AllHitObjects.ElementAt(index).DrawPosition.Y, drawableRuleset.Playfield.HitObjectContainer.DrawHeight * relativeY));
|
||||
|
||||
private void setTime(double time)
|
||||
{
|
||||
AddStep($"set time = {time}", () => testClock.CurrentTime = time);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="IBeatmap"/>, containing 10 hitobjects and user-provided timing points.
|
||||
/// The hitobjects are spaced <see cref="time_range"/> milliseconds apart.
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="IBeatmap"/>.</returns>
|
||||
private IBeatmap createBeatmap()
|
||||
{
|
||||
var beatmap = new Beatmap<HitObject> { BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo } };
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
beatmap.HitObjects.Add(new HitObject { StartTime = i * time_range });
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
private void createTest(IBeatmap beatmap, Action<TestDrawableScrollingRuleset> overrideAction = null) => AddStep("create test", () =>
|
||||
{
|
||||
var ruleset = new TestScrollingRuleset();
|
||||
|
||||
drawableRuleset = (TestDrawableScrollingRuleset)ruleset.CreateDrawableRulesetWith(CreateWorkingBeatmap(beatmap).GetPlayableBeatmap(ruleset.RulesetInfo));
|
||||
drawableRuleset.FrameStablePlayback = false;
|
||||
|
||||
overrideAction?.Invoke(drawableRuleset);
|
||||
|
||||
Child = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Height = 0.75f,
|
||||
Width = 400,
|
||||
Masking = true,
|
||||
Clock = new FramedClock(testClock),
|
||||
Child = drawableRuleset
|
||||
};
|
||||
});
|
||||
|
||||
#region Ruleset
|
||||
|
||||
private class TestScrollingRuleset : Ruleset
|
||||
{
|
||||
public override IEnumerable<Mod> GetModsFor(ModType type) => throw new NotImplementedException();
|
||||
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new TestDrawableScrollingRuleset(this, beatmap, mods);
|
||||
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TestBeatmapConverter(beatmap, null);
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => throw new NotImplementedException();
|
||||
|
||||
public override string Description { get; } = string.Empty;
|
||||
|
||||
public override string ShortName { get; } = string.Empty;
|
||||
}
|
||||
|
||||
private class TestDrawableScrollingRuleset : DrawableScrollingRuleset<TestHitObject>
|
||||
{
|
||||
public bool RelativeScaleBeatLengthsOverride { get; set; }
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public override DrawableHitObject<TestHitObject> CreateDrawableRepresentation(TestHitObject h) => new DrawableTestHitObject(h);
|
||||
|
||||
protected override PassThroughInputManager CreateInputManager() => new PassThroughInputManager();
|
||||
|
||||
protected override Playfield CreatePlayfield() => new TestPlayfield();
|
||||
}
|
||||
|
||||
private class TestPlayfield : ScrollingPlayfield
|
||||
{
|
||||
public TestPlayfield()
|
||||
{
|
||||
AddInternal(new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.2f,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Top = 150 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 2,
|
||||
Colour = Color4.Green
|
||||
},
|
||||
HitObjectContainer
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private class TestBeatmapConverter : BeatmapConverter<TestHitObject>
|
||||
{
|
||||
public TestBeatmapConverter(IBeatmap beatmap, Ruleset ruleset)
|
||||
: base(beatmap, ruleset)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool CanConvert() => true;
|
||||
|
||||
protected override IEnumerable<TestHitObject> ConvertHitObject(HitObject original, IBeatmap beatmap)
|
||||
{
|
||||
yield return new TestHitObject
|
||||
{
|
||||
StartTime = original.StartTime,
|
||||
EndTime = (original as IHasEndTime)?.EndTime ?? (original.StartTime + 100)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HitObject
|
||||
|
||||
private class TestHitObject : HitObject, IHasEndTime
|
||||
{
|
||||
public double EndTime { get; set; }
|
||||
|
||||
public double Duration => EndTime - StartTime;
|
||||
}
|
||||
|
||||
private class DrawableTestHitObject : DrawableHitObject<TestHitObject>
|
||||
{
|
||||
public DrawableTestHitObject(TestHitObject hitObject)
|
||||
: base(hitObject)
|
||||
{
|
||||
Anchor = Anchor.TopCentre;
|
||||
Origin = Anchor.TopCentre;
|
||||
|
||||
Size = new Vector2(100, 25);
|
||||
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.LightPink
|
||||
},
|
||||
new Box
|
||||
{
|
||||
Origin = Anchor.CentreLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 2,
|
||||
Colour = Color4.Red
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
Mods.Value = Array.Empty<Mod>();
|
||||
SelectedMods.Value = Array.Empty<Mod>();
|
||||
return new FailPlayer();
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
ScoreProcessor.FailConditions += (_, __) => true;
|
||||
HealthProcessor.FailConditions += (_, __) => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
44
osu.Game.Tests/Visual/Gameplay/TestSceneFailJudgement.cs
Normal file
44
osu.Game.Tests/Visual/Gameplay/TestSceneFailJudgement.cs
Normal file
@ -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 System;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneFailJudgement : AllPlayersTestScene
|
||||
{
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
SelectedMods.Value = Array.Empty<Mod>();
|
||||
return new FailPlayer();
|
||||
}
|
||||
|
||||
protected override void AddCheckSteps()
|
||||
{
|
||||
AddUntilStep("wait for fail", () => Player.HasFailed);
|
||||
AddUntilStep("wait for multiple judged objects", () => ((FailPlayer)Player).DrawableRuleset.Playfield.AllHitObjects.Count(h => h.AllJudged) > 1);
|
||||
AddAssert("total judgements == 1", () => ((FailPlayer)Player).HealthProcessor.JudgedHits >= 1);
|
||||
}
|
||||
|
||||
private class FailPlayer : TestPlayer
|
||||
{
|
||||
public new HealthProcessor HealthProcessor => base.HealthProcessor;
|
||||
|
||||
public FailPlayer()
|
||||
: base(false, false)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
HealthProcessor.FailConditions += (_, __) => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,12 +3,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK;
|
||||
@ -29,57 +30,118 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase game)
|
||||
{
|
||||
Child = globalActionContainer = new GlobalActionContainer(game)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
pauseOverlay = new PauseOverlay
|
||||
{
|
||||
OnResume = () => Logger.Log(@"Resume"),
|
||||
OnRetry = () => Logger.Log(@"Retry"),
|
||||
OnQuit = () => Logger.Log(@"Quit"),
|
||||
},
|
||||
failOverlay = new FailOverlay
|
||||
Child = globalActionContainer = new GlobalActionContainer(game);
|
||||
}
|
||||
|
||||
{
|
||||
OnRetry = () => Logger.Log(@"Retry"),
|
||||
OnQuit = () => Logger.Log(@"Quit"),
|
||||
}
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
globalActionContainer.Children = new Drawable[]
|
||||
{
|
||||
pauseOverlay = new PauseOverlay
|
||||
{
|
||||
OnResume = () => Logger.Log(@"Resume"),
|
||||
OnRetry = () => Logger.Log(@"Retry"),
|
||||
OnQuit = () => Logger.Log(@"Quit"),
|
||||
},
|
||||
failOverlay = new FailOverlay
|
||||
|
||||
{
|
||||
OnRetry = () => Logger.Log(@"Retry"),
|
||||
OnQuit = () => Logger.Log(@"Quit"),
|
||||
}
|
||||
};
|
||||
|
||||
InputManager.MoveMouseTo(Vector2.Zero);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestAdjustRetryCount()
|
||||
{
|
||||
showOverlay();
|
||||
|
||||
var retryCount = 0;
|
||||
|
||||
AddStep("Add retry", () =>
|
||||
AddRepeatStep("Add retry", () =>
|
||||
{
|
||||
retryCount++;
|
||||
pauseOverlay.Retries = failOverlay.Retries = retryCount;
|
||||
});
|
||||
}, 10);
|
||||
}
|
||||
|
||||
AddToggleStep("Toggle pause overlay", t => pauseOverlay.ToggleVisibility());
|
||||
AddToggleStep("Toggle fail overlay", t => failOverlay.ToggleVisibility());
|
||||
/// <summary>
|
||||
/// Tests that pressing enter after an overlay shows doesn't trigger an event because a selection hasn't occurred.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestEnterWithoutSelection()
|
||||
{
|
||||
showOverlay();
|
||||
|
||||
testHideResets();
|
||||
AddStep("Press select", () => press(GlobalAction.Select));
|
||||
AddAssert("Overlay still open", () => pauseOverlay.State.Value == Visibility.Visible);
|
||||
}
|
||||
|
||||
testEnterWithoutSelection();
|
||||
testKeyUpFromInitial();
|
||||
testKeyDownFromInitial();
|
||||
testKeyUpWrapping();
|
||||
testKeyDownWrapping();
|
||||
/// <summary>
|
||||
/// Tests that pressing the up arrow from the initial state selects the last button.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestKeyUpFromInitial()
|
||||
{
|
||||
showOverlay();
|
||||
|
||||
testMouseSelectionAfterKeySelection();
|
||||
testKeySelectionAfterMouseSelection();
|
||||
AddStep("Up arrow", () => press(Key.Up));
|
||||
AddAssert("Last button selected", () => pauseOverlay.Buttons.Last().Selected.Value);
|
||||
}
|
||||
|
||||
testMouseDeselectionResets();
|
||||
/// <summary>
|
||||
/// Tests that pressing the down arrow from the initial state selects the first button.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestKeyDownFromInitial()
|
||||
{
|
||||
showOverlay();
|
||||
|
||||
testClickSelection();
|
||||
testEnterKeySelection();
|
||||
AddStep("Down arrow", () => press(Key.Down));
|
||||
AddAssert("First button selected", () => getButton(0).Selected.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that pressing the up arrow repeatedly causes the selected button to wrap correctly.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestKeyUpWrapping()
|
||||
{
|
||||
AddStep("Show overlay", () => failOverlay.Show());
|
||||
|
||||
AddStep("Up arrow", () => press(Key.Up));
|
||||
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value);
|
||||
AddStep("Up arrow", () => press(Key.Up));
|
||||
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value);
|
||||
AddStep("Up arrow", () => press(Key.Up));
|
||||
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that pressing the down arrow repeatedly causes the selected button to wrap correctly.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestKeyDownWrapping()
|
||||
{
|
||||
AddStep("Show overlay", () => failOverlay.Show());
|
||||
|
||||
AddStep("Down arrow", () => press(Key.Down));
|
||||
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value);
|
||||
AddStep("Down arrow", () => press(Key.Down));
|
||||
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value);
|
||||
AddStep("Down arrow", () => press(Key.Down));
|
||||
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test that hiding the overlay after hovering a button will reset the overlay to the initial state with no buttons selected.
|
||||
/// </summary>
|
||||
private void testHideResets()
|
||||
[Test]
|
||||
public void TestHideResets()
|
||||
{
|
||||
AddStep("Show overlay", () => failOverlay.Show());
|
||||
|
||||
@ -90,141 +152,78 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that pressing enter after an overlay shows doesn't trigger an event because a selection hasn't occurred.
|
||||
/// Tests that entering menu with cursor initially on button doesn't selects it immediately.
|
||||
/// This is to allow for stable keyboard navigation.
|
||||
/// </summary>
|
||||
private void testEnterWithoutSelection()
|
||||
[Test]
|
||||
public void TestInitialButtonHover()
|
||||
{
|
||||
AddStep("Show overlay", () => pauseOverlay.Show());
|
||||
showOverlay();
|
||||
|
||||
AddStep("Press select", () => press(GlobalAction.Select));
|
||||
AddAssert("Overlay still open", () => pauseOverlay.State.Value == Visibility.Visible);
|
||||
AddStep("Hover first button", () => InputManager.MoveMouseTo(getButton(0)));
|
||||
|
||||
AddStep("Hide overlay", () => pauseOverlay.Hide());
|
||||
}
|
||||
showOverlay();
|
||||
|
||||
/// <summary>
|
||||
/// Tests that pressing the up arrow from the initial state selects the last button.
|
||||
/// </summary>
|
||||
private void testKeyUpFromInitial()
|
||||
{
|
||||
AddStep("Show overlay", () => pauseOverlay.Show());
|
||||
AddAssert("First button not selected", () => !getButton(0).Selected.Value);
|
||||
|
||||
AddStep("Up arrow", () => press(Key.Up));
|
||||
AddAssert("Last button selected", () => pauseOverlay.Buttons.Last().Selected.Value);
|
||||
AddStep("Move slightly", () => InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + new Vector2(1)));
|
||||
|
||||
AddStep("Hide overlay", () => pauseOverlay.Hide());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that pressing the down arrow from the initial state selects the first button.
|
||||
/// </summary>
|
||||
private void testKeyDownFromInitial()
|
||||
{
|
||||
AddStep("Show overlay", () => pauseOverlay.Show());
|
||||
|
||||
AddStep("Down arrow", () => press(Key.Down));
|
||||
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected.Value);
|
||||
|
||||
AddStep("Hide overlay", () => pauseOverlay.Hide());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that pressing the up arrow repeatedly causes the selected button to wrap correctly.
|
||||
/// </summary>
|
||||
private void testKeyUpWrapping()
|
||||
{
|
||||
AddStep("Show overlay", () => failOverlay.Show());
|
||||
|
||||
AddStep("Up arrow", () => press(Key.Up));
|
||||
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value);
|
||||
AddStep("Up arrow", () => press(Key.Up));
|
||||
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value);
|
||||
AddStep("Up arrow", () => press(Key.Up));
|
||||
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value);
|
||||
|
||||
AddStep("Hide overlay", () => failOverlay.Hide());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that pressing the down arrow repeatedly causes the selected button to wrap correctly.
|
||||
/// </summary>
|
||||
private void testKeyDownWrapping()
|
||||
{
|
||||
AddStep("Show overlay", () => failOverlay.Show());
|
||||
|
||||
AddStep("Down arrow", () => press(Key.Down));
|
||||
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value);
|
||||
AddStep("Down arrow", () => press(Key.Down));
|
||||
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value);
|
||||
AddStep("Down arrow", () => press(Key.Down));
|
||||
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value);
|
||||
|
||||
AddStep("Hide overlay", () => failOverlay.Hide());
|
||||
AddAssert("First button selected", () => getButton(0).Selected.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that hovering a button that was previously selected with the keyboard correctly selects the new button and deselects the previous button.
|
||||
/// </summary>
|
||||
private void testMouseSelectionAfterKeySelection()
|
||||
[Test]
|
||||
public void TestMouseSelectionAfterKeySelection()
|
||||
{
|
||||
AddStep("Show overlay", () => pauseOverlay.Show());
|
||||
|
||||
var secondButton = pauseOverlay.Buttons.Skip(1).First();
|
||||
showOverlay();
|
||||
|
||||
AddStep("Down arrow", () => press(Key.Down));
|
||||
AddStep("Hover second button", () => InputManager.MoveMouseTo(secondButton));
|
||||
AddAssert("First button not selected", () => !pauseOverlay.Buttons.First().Selected.Value);
|
||||
AddAssert("Second button selected", () => secondButton.Selected.Value);
|
||||
|
||||
AddStep("Hide overlay", () => pauseOverlay.Hide());
|
||||
AddStep("Hover second button", () => InputManager.MoveMouseTo(getButton(1)));
|
||||
AddAssert("First button not selected", () => !getButton(0).Selected.Value);
|
||||
AddAssert("Second button selected", () => getButton(1).Selected.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that pressing a key after selecting a button with a hover event correctly selects a new button and deselects the previous button.
|
||||
/// </summary>
|
||||
private void testKeySelectionAfterMouseSelection()
|
||||
[Test]
|
||||
public void TestKeySelectionAfterMouseSelection()
|
||||
{
|
||||
AddStep("Show overlay", () =>
|
||||
{
|
||||
pauseOverlay.Show();
|
||||
InputManager.MoveMouseTo(Vector2.Zero);
|
||||
});
|
||||
|
||||
var secondButton = pauseOverlay.Buttons.Skip(1).First();
|
||||
|
||||
AddStep("Hover second button", () => InputManager.MoveMouseTo(secondButton));
|
||||
AddStep("Hover second button", () => InputManager.MoveMouseTo(getButton(1)));
|
||||
AddStep("Up arrow", () => press(Key.Up));
|
||||
AddAssert("Second button not selected", () => !secondButton.Selected.Value);
|
||||
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected.Value);
|
||||
|
||||
AddStep("Hide overlay", () => pauseOverlay.Hide());
|
||||
AddAssert("Second button not selected", () => !getButton(1).Selected.Value);
|
||||
AddAssert("First button selected", () => getButton(0).Selected.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that deselecting with the mouse by losing hover will reset the overlay to the initial state.
|
||||
/// </summary>
|
||||
private void testMouseDeselectionResets()
|
||||
[Test]
|
||||
public void TestMouseDeselectionResets()
|
||||
{
|
||||
AddStep("Show overlay", () => pauseOverlay.Show());
|
||||
showOverlay();
|
||||
|
||||
var secondButton = pauseOverlay.Buttons.Skip(1).First();
|
||||
|
||||
AddStep("Hover second button", () => InputManager.MoveMouseTo(secondButton));
|
||||
AddStep("Hover second button", () => InputManager.MoveMouseTo(getButton(1)));
|
||||
AddStep("Unhover second button", () => InputManager.MoveMouseTo(Vector2.Zero));
|
||||
AddStep("Down arrow", () => press(Key.Down));
|
||||
AddAssert("First button selected", () => pauseOverlay.Buttons.First().Selected.Value); // Initial state condition
|
||||
|
||||
AddStep("Hide overlay", () => pauseOverlay.Hide());
|
||||
AddAssert("First button selected", () => getButton(0).Selected.Value); // Initial state condition
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that clicking on a button correctly causes a click event for that button.
|
||||
/// </summary>
|
||||
private void testClickSelection()
|
||||
[Test]
|
||||
public void TestClickSelection()
|
||||
{
|
||||
AddStep("Show overlay", () => pauseOverlay.Show());
|
||||
|
||||
var retryButton = pauseOverlay.Buttons.Skip(1).First();
|
||||
showOverlay();
|
||||
|
||||
bool triggered = false;
|
||||
AddStep("Click retry button", () =>
|
||||
@ -232,7 +231,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
var lastAction = pauseOverlay.OnRetry;
|
||||
pauseOverlay.OnRetry = () => triggered = true;
|
||||
|
||||
retryButton.Click();
|
||||
getButton(1).Click();
|
||||
pauseOverlay.OnRetry = lastAction;
|
||||
});
|
||||
|
||||
@ -243,9 +242,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
/// <summary>
|
||||
/// Tests that pressing the enter key with a button selected correctly causes a click event for that button.
|
||||
/// </summary>
|
||||
private void testEnterKeySelection()
|
||||
[Test]
|
||||
public void TestEnterKeySelection()
|
||||
{
|
||||
AddStep("Show overlay", () => pauseOverlay.Show());
|
||||
showOverlay();
|
||||
|
||||
AddStep("Select second button", () =>
|
||||
{
|
||||
@ -275,6 +275,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("Overlay is closed", () => pauseOverlay.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
private void showOverlay() => AddStep("Show overlay", () => pauseOverlay.Show());
|
||||
|
||||
private DialogButton getButton(int index) => pauseOverlay.Buttons.Skip(index).First();
|
||||
|
||||
private void press(Key key)
|
||||
{
|
||||
InputManager.PressKey(key);
|
||||
|
@ -7,15 +7,17 @@ using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Storyboards;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
@ -34,9 +36,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private Track track;
|
||||
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap)
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||
{
|
||||
var working = new ClockBackedTestWorkingBeatmap(beatmap, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
|
||||
var working = new ClockBackedTestWorkingBeatmap(beatmap, storyboard, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
|
||||
track = working.Track;
|
||||
return working;
|
||||
}
|
||||
@ -47,9 +49,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddUntilStep("wait for track to start running", () => track.IsRunning);
|
||||
addSeekStep(3000);
|
||||
AddAssert("all judged", () => player.DrawableRuleset.Playfield.AllHitObjects.All(h => h.Judged));
|
||||
AddUntilStep("key counter counted keys", () => player.HUDOverlay.KeyCounter.Children.All(kc => kc.CountPresses >= 7));
|
||||
AddStep("clear results", () => player.AppliedResults.Clear());
|
||||
addSeekStep(0);
|
||||
AddAssert("none judged", () => player.DrawableRuleset.Playfield.AllHitObjects.All(h => !h.Judged));
|
||||
AddUntilStep("key counters reset", () => player.HUDOverlay.KeyCounter.Children.All(kc => kc.CountPresses == 0));
|
||||
AddAssert("no results triggered", () => player.AppliedResults.Count == 0);
|
||||
}
|
||||
|
||||
@ -63,7 +67,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
Mods.Value = Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
||||
SelectedMods.Value = SelectedMods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
||||
return new RulesetExposingPlayer();
|
||||
}
|
||||
|
||||
@ -90,6 +94,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public readonly List<JudgementResult> AppliedResults = new List<JudgementResult>();
|
||||
|
||||
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||
|
||||
public new HUDOverlay HUDOverlay => base.HUDOverlay;
|
||||
|
||||
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
|
||||
|
||||
public new DrawableRuleset DrawableRuleset => base.DrawableRuleset;
|
||||
|
81
osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs
Normal file
81
osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs
Normal file
@ -0,0 +1,81 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneHUDOverlay : ManualInputManagerTestScene
|
||||
{
|
||||
private HUDOverlay hudOverlay;
|
||||
|
||||
private Drawable hideTarget => hudOverlay.KeyCounter; // best way of checking hideTargets without exposing.
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; }
|
||||
|
||||
[Test]
|
||||
public void TestShownByDefault()
|
||||
{
|
||||
createNew();
|
||||
|
||||
AddAssert("showhud is set", () => hudOverlay.ShowHud.Value);
|
||||
|
||||
AddAssert("hidetarget is visible", () => hideTarget.IsPresent);
|
||||
AddAssert("pause button is visible", () => hudOverlay.HoldToQuit.IsPresent);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFadesInOnLoadComplete()
|
||||
{
|
||||
float? initialAlpha = null;
|
||||
|
||||
createNew(h => h.OnLoadComplete += _ => initialAlpha = hideTarget.Alpha);
|
||||
AddUntilStep("wait for load", () => hudOverlay.IsAlive);
|
||||
AddAssert("initial alpha was less than 1", () => initialAlpha != null && initialAlpha < 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHideExternally()
|
||||
{
|
||||
createNew();
|
||||
|
||||
AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
|
||||
|
||||
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
|
||||
AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExternalHideDoesntAffectConfig()
|
||||
{
|
||||
bool originalConfigValue = false;
|
||||
|
||||
createNew();
|
||||
|
||||
AddStep("get original config value", () => originalConfigValue = config.Get<bool>(OsuSetting.ShowInterface));
|
||||
|
||||
AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
|
||||
AddAssert("config unchanged", () => originalConfigValue == config.Get<bool>(OsuSetting.ShowInterface));
|
||||
|
||||
AddStep("set showhud true", () => hudOverlay.ShowHud.Value = true);
|
||||
AddAssert("config unchanged", () => originalConfigValue == config.Get<bool>(OsuSetting.ShowInterface));
|
||||
}
|
||||
|
||||
private void createNew(Action<HUDOverlay> action = null)
|
||||
{
|
||||
AddStep("create overlay", () =>
|
||||
{
|
||||
Child = hudOverlay = new HUDOverlay(null, null, null, Array.Empty<Mod>());
|
||||
|
||||
action?.Invoke(hudOverlay);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
139
osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs
Normal file
139
osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs
Normal file
@ -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 NUnit.Framework;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Catch.Scoring;
|
||||
using osu.Game.Rulesets.Mania.Scoring;
|
||||
using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.Taiko.Scoring;
|
||||
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneHitErrorMeter : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(HitErrorMeter),
|
||||
typeof(BarHitErrorMeter),
|
||||
typeof(ColourHitErrorMeter)
|
||||
};
|
||||
|
||||
private BarHitErrorMeter barMeter;
|
||||
private BarHitErrorMeter barMeter2;
|
||||
private ColourHitErrorMeter colourMeter;
|
||||
private ColourHitErrorMeter colourMeter2;
|
||||
private HitWindows hitWindows;
|
||||
|
||||
public TestSceneHitErrorMeter()
|
||||
{
|
||||
recreateDisplay(new OsuHitWindows(), 5);
|
||||
|
||||
AddRepeatStep("New random judgement", () => newJudgement(), 40);
|
||||
|
||||
AddRepeatStep("New max negative", () => newJudgement(-hitWindows.WindowFor(HitResult.Meh)), 20);
|
||||
AddRepeatStep("New max positive", () => newJudgement(hitWindows.WindowFor(HitResult.Meh)), 20);
|
||||
AddStep("New fixed judgement (50ms)", () => newJudgement(50));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOsu()
|
||||
{
|
||||
AddStep("OD 1", () => recreateDisplay(new OsuHitWindows(), 1));
|
||||
AddStep("OD 10", () => recreateDisplay(new OsuHitWindows(), 10));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTaiko()
|
||||
{
|
||||
AddStep("OD 1", () => recreateDisplay(new TaikoHitWindows(), 1));
|
||||
AddStep("OD 10", () => recreateDisplay(new TaikoHitWindows(), 10));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMania()
|
||||
{
|
||||
AddStep("OD 1", () => recreateDisplay(new ManiaHitWindows(), 1));
|
||||
AddStep("OD 10", () => recreateDisplay(new ManiaHitWindows(), 10));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCatch()
|
||||
{
|
||||
AddStep("OD 1", () => recreateDisplay(new CatchHitWindows(), 1));
|
||||
AddStep("OD 10", () => recreateDisplay(new CatchHitWindows(), 10));
|
||||
}
|
||||
|
||||
private void recreateDisplay(HitWindows hitWindows, float overallDifficulty)
|
||||
{
|
||||
this.hitWindows = hitWindows;
|
||||
|
||||
hitWindows?.SetDifficulty(overallDifficulty);
|
||||
|
||||
Clear();
|
||||
|
||||
Add(new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Vertical,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText { Text = $@"Great: {hitWindows?.WindowFor(HitResult.Great)}" },
|
||||
new OsuSpriteText { Text = $@"Good: {hitWindows?.WindowFor(HitResult.Good)}" },
|
||||
new OsuSpriteText { Text = $@"Meh: {hitWindows?.WindowFor(HitResult.Meh)}" },
|
||||
}
|
||||
});
|
||||
|
||||
Add(barMeter = new BarHitErrorMeter(hitWindows, true)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
});
|
||||
|
||||
Add(barMeter2 = new BarHitErrorMeter(hitWindows, false)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
});
|
||||
|
||||
Add(colourMeter = new ColourHitErrorMeter(hitWindows)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Margin = new MarginPadding { Right = 50 }
|
||||
});
|
||||
|
||||
Add(colourMeter2 = new ColourHitErrorMeter(hitWindows)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Left = 50 }
|
||||
});
|
||||
}
|
||||
|
||||
private void newJudgement(double offset = 0)
|
||||
{
|
||||
var judgement = new JudgementResult(new HitObject(), new Judgement())
|
||||
{
|
||||
TimeOffset = offset == 0 ? RNG.Next(-150, 150) : offset,
|
||||
Type = HitResult.Perfect,
|
||||
};
|
||||
|
||||
barMeter.OnNewJudgement(judgement);
|
||||
barMeter2.OnNewJudgement(judgement);
|
||||
colourMeter.OnNewJudgement(judgement);
|
||||
colourMeter2.OnNewJudgement(judgement);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,6 +17,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
private bool exitAction;
|
||||
|
||||
protected override double TimePerAction => 100; // required for the early exit test, since hold-to-confirm delay is 200ms
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
|
@ -6,8 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -25,14 +24,15 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public TestSceneKeyCounter()
|
||||
{
|
||||
KeyCounterKeyboard rewindTestKeyCounterKeyboard;
|
||||
KeyCounterKeyboard testCounter;
|
||||
|
||||
KeyCounterDisplay kc = new KeyCounterDisplay
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Children = new KeyCounter[]
|
||||
{
|
||||
rewindTestKeyCounterKeyboard = new KeyCounterKeyboard(Key.X),
|
||||
testCounter = new KeyCounterKeyboard(Key.X),
|
||||
new KeyCounterKeyboard(Key.X),
|
||||
new KeyCounterMouse(MouseButton.Left),
|
||||
new KeyCounterMouse(MouseButton.Right),
|
||||
@ -44,10 +44,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
Key key = (Key)((int)Key.A + RNG.Next(26));
|
||||
kc.Add(new KeyCounterKeyboard(key));
|
||||
});
|
||||
AddSliderStep("Fade time", 0, 200, 50, v => kc.FadeTime = v);
|
||||
|
||||
Key testKey = ((KeyCounterKeyboard)kc.Children.First()).Key;
|
||||
double time1 = 0;
|
||||
|
||||
AddStep($"Press {testKey} key", () =>
|
||||
{
|
||||
@ -55,48 +53,17 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
InputManager.ReleaseKey(testKey);
|
||||
});
|
||||
|
||||
AddAssert($"Check {testKey} counter after keypress", () => rewindTestKeyCounterKeyboard.CountPresses == 1);
|
||||
AddAssert($"Check {testKey} counter after keypress", () => testCounter.CountPresses == 1);
|
||||
|
||||
AddStep($"Press {testKey} key", () =>
|
||||
{
|
||||
InputManager.PressKey(testKey);
|
||||
InputManager.ReleaseKey(testKey);
|
||||
time1 = Clock.CurrentTime;
|
||||
});
|
||||
|
||||
AddAssert($"Check {testKey} counter after keypress", () => rewindTestKeyCounterKeyboard.CountPresses == 2);
|
||||
|
||||
IFrameBasedClock oldClock = null;
|
||||
|
||||
AddStep($"Rewind {testKey} counter once", () =>
|
||||
{
|
||||
oldClock = rewindTestKeyCounterKeyboard.Clock;
|
||||
rewindTestKeyCounterKeyboard.Clock = new FramedOffsetClock(new FixedClock(time1 - 10));
|
||||
});
|
||||
|
||||
AddAssert($"Check {testKey} counter after rewind", () => rewindTestKeyCounterKeyboard.CountPresses == 1);
|
||||
|
||||
AddStep($"Rewind {testKey} counter to zero", () => rewindTestKeyCounterKeyboard.Clock = new FramedOffsetClock(new FixedClock(0)));
|
||||
|
||||
AddAssert($"Check {testKey} counter after rewind", () => rewindTestKeyCounterKeyboard.CountPresses == 0);
|
||||
|
||||
AddStep("Restore clock", () => rewindTestKeyCounterKeyboard.Clock = oldClock);
|
||||
AddAssert($"Check {testKey} counter after keypress", () => testCounter.CountPresses == 2);
|
||||
|
||||
Add(kc);
|
||||
}
|
||||
|
||||
private class FixedClock : IClock
|
||||
{
|
||||
private readonly double time;
|
||||
|
||||
public FixedClock(double time)
|
||||
{
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public double CurrentTime => time;
|
||||
public double Rate => 1;
|
||||
public bool IsRunning => false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
113
osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs
Normal file
113
osu.Game.Tests/Visual/Gameplay/TestSceneLeadIn.cs
Normal file
@ -0,0 +1,113 @@
|
||||
// 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.Diagnostics;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneLeadIn : RateAdjustedBeatmapTestScene
|
||||
{
|
||||
private LeadInPlayer player;
|
||||
|
||||
private const double lenience_ms = 10;
|
||||
|
||||
private const double first_hit_object = 2170;
|
||||
|
||||
[TestCase(1000, 0)]
|
||||
[TestCase(2000, 0)]
|
||||
[TestCase(3000, first_hit_object - 3000)]
|
||||
[TestCase(10000, first_hit_object - 10000)]
|
||||
public void TestLeadInProducesCorrectStartTime(double leadIn, double expectedStartTime)
|
||||
{
|
||||
loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo)
|
||||
{
|
||||
BeatmapInfo = { AudioLeadIn = leadIn }
|
||||
});
|
||||
|
||||
AddAssert($"first frame is {expectedStartTime}", () =>
|
||||
{
|
||||
Debug.Assert(player.FirstFrameClockTime != null);
|
||||
return Precision.AlmostEquals(player.FirstFrameClockTime.Value, expectedStartTime, lenience_ms);
|
||||
});
|
||||
}
|
||||
|
||||
[TestCase(1000, 0)]
|
||||
[TestCase(0, 0)]
|
||||
[TestCase(-1000, -1000)]
|
||||
[TestCase(-10000, -10000)]
|
||||
public void TestStoryboardProducesCorrectStartTime(double firstStoryboardEvent, double expectedStartTime)
|
||||
{
|
||||
var storyboard = new Storyboard();
|
||||
|
||||
var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero);
|
||||
sprite.TimelineGroup.Alpha.Add(Easing.None, firstStoryboardEvent, firstStoryboardEvent + 500, 0, 1);
|
||||
|
||||
storyboard.GetLayer("Background").Add(sprite);
|
||||
|
||||
loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo), storyboard);
|
||||
|
||||
AddAssert($"first frame is {expectedStartTime}", () =>
|
||||
{
|
||||
Debug.Assert(player.FirstFrameClockTime != null);
|
||||
return Precision.AlmostEquals(player.FirstFrameClockTime.Value, expectedStartTime, lenience_ms);
|
||||
});
|
||||
}
|
||||
|
||||
private void loadPlayerWithBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||
{
|
||||
AddStep("create player", () =>
|
||||
{
|
||||
Beatmap.Value = CreateWorkingBeatmap(beatmap, storyboard);
|
||||
LoadScreen(player = new LeadInPlayer());
|
||||
});
|
||||
|
||||
AddUntilStep("player loaded", () => player.IsLoaded && player.Alpha == 1);
|
||||
}
|
||||
|
||||
private class LeadInPlayer : TestPlayer
|
||||
{
|
||||
public LeadInPlayer()
|
||||
: base(false, false)
|
||||
{
|
||||
}
|
||||
|
||||
public double? FirstFrameClockTime;
|
||||
|
||||
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
|
||||
|
||||
public double GameplayStartTime => DrawableRuleset.GameplayStartTime;
|
||||
|
||||
public double FirstHitObjectTime => DrawableRuleset.Objects.First().StartTime;
|
||||
|
||||
public double GameplayClockTime => GameplayClockContainer.GameplayClock.CurrentTime;
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
if (!FirstFrameClockTime.HasValue)
|
||||
{
|
||||
FirstFrameClockTime = GameplayClockContainer.GameplayClock.CurrentTime;
|
||||
AddInternal(new OsuSpriteText
|
||||
{
|
||||
Text = $"GameplayStartTime: {DrawableRuleset.GameplayStartTime} "
|
||||
+ $"FirstHitObjectTime: {FirstHitObjectTime} "
|
||||
+ $"LeadInTime: {Beatmap.Value.BeatmapInfo.AudioLeadIn} "
|
||||
+ $"FirstFrameClockTime: {FirstFrameClockTime}"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
// 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 osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Tests.Visual.UserInterface;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneNightcoreBeatContainer : TestSceneBeatSyncedContainer
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ModNightcore<>)
|
||||
};
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
|
||||
Beatmap.Value.Track.Start();
|
||||
Beatmap.Value.Track.Seek(Beatmap.Value.Beatmap.HitObjects.First().StartTime - 1000);
|
||||
|
||||
Add(new ModNightcore<HitObject>.NightcoreBeatContainer());
|
||||
|
||||
AddStep("change signature to quadruple", () => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints.ForEach(p => p.TimeSignature = TimeSignatures.SimpleQuadruple));
|
||||
AddStep("change signature to triple", () => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints.ForEach(p => p.TimeSignature = TimeSignatures.SimpleTriple));
|
||||
}
|
||||
}
|
||||
}
|
@ -52,7 +52,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public void TestResumeWithResumeOverlay()
|
||||
{
|
||||
AddStep("move cursor to center", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.Centre));
|
||||
AddUntilStep("wait for hitobjects", () => Player.ScoreProcessor.Health.Value < 1);
|
||||
AddUntilStep("wait for hitobjects", () => Player.HealthProcessor.Health.Value < 1);
|
||||
|
||||
pauseAndConfirm();
|
||||
resume();
|
||||
@ -69,12 +69,30 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
confirmClockRunning(true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPauseWithResumeOverlay()
|
||||
{
|
||||
AddStep("move cursor to center", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.Centre));
|
||||
AddUntilStep("wait for hitobjects", () => Player.HealthProcessor.Health.Value < 1);
|
||||
|
||||
pauseAndConfirm();
|
||||
|
||||
resume();
|
||||
confirmClockRunning(false);
|
||||
confirmPauseOverlayShown(false);
|
||||
|
||||
pauseAndConfirm();
|
||||
|
||||
AddUntilStep("resume overlay is not active", () => Player.DrawableRuleset.ResumeOverlay.State.Value == Visibility.Hidden);
|
||||
confirmPaused();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestResumeWithResumeOverlaySkipped()
|
||||
{
|
||||
AddStep("move cursor to button", () =>
|
||||
InputManager.MoveMouseTo(Player.HUDOverlay.HoldToQuit.Children.OfType<HoldToConfirmContainer>().First().ScreenSpaceDrawQuad.Centre));
|
||||
AddUntilStep("wait for hitobjects", () => Player.ScoreProcessor.Health.Value < 1);
|
||||
AddUntilStep("wait for hitobjects", () => Player.HealthProcessor.Health.Value < 1);
|
||||
|
||||
pauseAndConfirm();
|
||||
resumeAndConfirm();
|
||||
@ -97,8 +115,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestExitTooSoon()
|
||||
{
|
||||
pauseAndConfirm();
|
||||
AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000));
|
||||
|
||||
pauseAndConfirm();
|
||||
resume();
|
||||
|
||||
AddStep("exit too soon", () => Player.Exit());
|
||||
@ -127,14 +146,49 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
exitAndConfirm();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExitFromFailedGameplay()
|
||||
{
|
||||
AddUntilStep("wait for fail", () => Player.HasFailed);
|
||||
AddStep("exit", () => Player.Exit());
|
||||
|
||||
confirmExited();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestQuickRetryFromFailedGameplay()
|
||||
{
|
||||
AddUntilStep("wait for fail", () => Player.HasFailed);
|
||||
AddStep("quick retry", () => Player.GameplayClockContainer.OfType<HotkeyRetryOverlay>().First().Action?.Invoke());
|
||||
|
||||
confirmExited();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestQuickExitFromFailedGameplay()
|
||||
{
|
||||
AddUntilStep("wait for fail", () => Player.HasFailed);
|
||||
AddStep("quick exit", () => Player.GameplayClockContainer.OfType<HotkeyExitOverlay>().First().Action?.Invoke());
|
||||
|
||||
confirmExited();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExitFromGameplay()
|
||||
{
|
||||
AddStep("exit", () => Player.Exit());
|
||||
|
||||
confirmPaused();
|
||||
|
||||
exitAndConfirm();
|
||||
AddStep("exit", () => Player.Exit());
|
||||
confirmExited();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestQuickExitFromGameplay()
|
||||
{
|
||||
AddStep("quick exit", () => Player.GameplayClockContainer.OfType<HotkeyExitOverlay>().First().Action?.Invoke());
|
||||
|
||||
confirmExited();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -160,6 +214,17 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
exitAndConfirm();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRestartAfterResume()
|
||||
{
|
||||
AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000));
|
||||
|
||||
pauseAndConfirm();
|
||||
resumeAndConfirm();
|
||||
restart();
|
||||
confirmExited();
|
||||
}
|
||||
|
||||
private void pauseAndConfirm()
|
||||
{
|
||||
pause();
|
||||
@ -177,6 +242,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddUntilStep("player not exited", () => Player.IsCurrentScreen());
|
||||
AddStep("exit", () => Player.Exit());
|
||||
confirmExited();
|
||||
confirmNoTrackAdjustments();
|
||||
}
|
||||
|
||||
private void confirmPaused()
|
||||
@ -198,6 +264,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddUntilStep("player exited", () => !Player.IsCurrentScreen());
|
||||
}
|
||||
|
||||
private void confirmNoTrackAdjustments()
|
||||
{
|
||||
AddAssert("track has no adjustments", () => Beatmap.Value.Track.AggregateFrequency.Value == 1);
|
||||
}
|
||||
|
||||
private void restart() => AddStep("restart", () => Player.Restart());
|
||||
private void pause() => AddStep("pause", () => Player.Pause());
|
||||
private void resume() => AddStep("resume", () => Player.Resume());
|
||||
|
||||
@ -213,9 +285,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
protected class PausePlayer : TestPlayer
|
||||
{
|
||||
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
|
||||
|
||||
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||
public new HealthProcessor HealthProcessor => base.HealthProcessor;
|
||||
|
||||
public new HUDOverlay HUDOverlay => base.HUDOverlay;
|
||||
|
||||
|
51
osu.Game.Tests/Visual/Gameplay/TestScenePauseWhenInactive.cs
Normal file
51
osu.Game.Tests/Visual/Gameplay/TestScenePauseWhenInactive.cs
Normal file
@ -0,0 +1,51 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
[HeadlessTest] // we alter unsafe properties on the game host to test inactive window state.
|
||||
public class TestScenePauseWhenInactive : PlayerTestScene
|
||||
{
|
||||
protected new TestPlayer Player => (TestPlayer)base.Player;
|
||||
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||
{
|
||||
var beatmap = (Beatmap)base.CreateBeatmap(ruleset);
|
||||
|
||||
beatmap.HitObjects.RemoveAll(h => h.StartTime < 30000);
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private GameHost host { get; set; }
|
||||
|
||||
public TestScenePauseWhenInactive()
|
||||
: base(new OsuRuleset())
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoesntPauseDuringIntro()
|
||||
{
|
||||
AddStep("set inactive", () => ((Bindable<bool>)host.IsActive).Value = false);
|
||||
|
||||
AddStep("resume player", () => Player.GameplayClockContainer.Start());
|
||||
AddAssert("ensure not paused", () => !Player.GameplayClockContainer.IsPaused.Value);
|
||||
AddUntilStep("wait for pause", () => Player.GameplayClockContainer.IsPaused.Value);
|
||||
AddAssert("time of pause is after gameplay start time", () => Player.GameplayClockContainer.GameplayClock.CurrentTime >= Player.DrawableRuleset.GameplayStartTime);
|
||||
}
|
||||
|
||||
protected override Player CreatePlayer(Ruleset ruleset) => new TestPlayer(true, true, true);
|
||||
}
|
||||
}
|
@ -5,38 +5,91 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestScenePlayerLoader : ManualInputManagerTestScene
|
||||
{
|
||||
private TestPlayerLoader loader;
|
||||
private OsuScreenStack stack;
|
||||
private TestPlayerLoaderContainer container;
|
||||
private TestPlayer player;
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
[Resolved]
|
||||
private AudioManager audioManager { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private SessionStatics sessionStatics { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the input manager child to a new test player loader container instance.
|
||||
/// </summary>
|
||||
/// <param name="interactive">If the test player should behave like the production one.</param>
|
||||
/// <param name="beforeLoadAction">An action to run before player load but after bindable leases are returned.</param>
|
||||
/// <param name="afterLoadAction">An action to run after container load.</param>
|
||||
public void ResetPlayer(bool interactive, Action beforeLoadAction = null, Action afterLoadAction = null)
|
||||
{
|
||||
InputManager.Child = stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both };
|
||||
audioManager.Volume.SetDefault();
|
||||
|
||||
InputManager.Clear();
|
||||
|
||||
beforeLoadAction?.Invoke();
|
||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
});
|
||||
|
||||
foreach (var mod in SelectedMods.Value.OfType<IApplicableToTrack>())
|
||||
mod.ApplyToTrack(Beatmap.Value.Track);
|
||||
|
||||
InputManager.Child = container = new TestPlayerLoaderContainer(
|
||||
loader = new TestPlayerLoader(() =>
|
||||
{
|
||||
afterLoadAction?.Invoke();
|
||||
return player = new TestPlayer(interactive, interactive);
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When <see cref="PlayerLoader"/> exits early, it has to wait for the player load task
|
||||
/// to complete before running disposal on player. This previously caused an issue where mod
|
||||
/// speed adjustments were undone too late, causing cross-screen pollution.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestEarlyExit()
|
||||
{
|
||||
AddStep("load dummy beatmap", () => ResetPlayer(false, () => SelectedMods.Value = new[] { new OsuModNightcore() }));
|
||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||
AddAssert("mod rate applied", () => Beatmap.Value.Track.Rate != 1);
|
||||
AddStep("exit loader", () => loader.Exit());
|
||||
AddUntilStep("wait for not current", () => !loader.IsCurrentScreen());
|
||||
AddAssert("player did not load", () => !player.IsLoaded);
|
||||
AddUntilStep("player disposed", () => loader.DisposalTask?.IsCompleted == true);
|
||||
AddAssert("mod rate still applied", () => Beatmap.Value.Track.Rate != 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBlockLoadViaMouseMovement()
|
||||
{
|
||||
AddStep("load dummy beatmap", () => stack.Push(loader = new TestPlayerLoader(() => new TestPlayer(false, false))));
|
||||
AddStep("load dummy beatmap", () => ResetPlayer(false));
|
||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||
AddRepeatStep("move mouse", () => InputManager.MoveMouseTo(loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft + (loader.VisualSettings.ScreenSpaceDrawQuad.BottomRight - loader.VisualSettings.ScreenSpaceDrawQuad.TopLeft) * RNG.NextSingle()), 20);
|
||||
AddAssert("loader still active", () => loader.IsCurrentScreen());
|
||||
@ -46,16 +99,17 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestLoadContinuation()
|
||||
{
|
||||
Player player = null;
|
||||
SlowLoadPlayer slowPlayer = null;
|
||||
|
||||
AddStep("load dummy beatmap", () => stack.Push(loader = new TestPlayerLoader(() => player = new TestPlayer(false, false))));
|
||||
AddStep("load dummy beatmap", () => ResetPlayer(false));
|
||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
||||
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
|
||||
AddStep("load slow dummy beatmap", () =>
|
||||
{
|
||||
stack.Push(loader = new TestPlayerLoader(() => slowPlayer = new SlowLoadPlayer(false, false)));
|
||||
InputManager.Child = container = new TestPlayerLoaderContainer(
|
||||
loader = new TestPlayerLoader(() => slowPlayer = new SlowLoadPlayer(false, false)));
|
||||
|
||||
Scheduler.AddDelayed(() => slowPlayer.AllowLoad.Set(), 5000);
|
||||
});
|
||||
|
||||
@ -65,16 +119,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestModReinstantiation()
|
||||
{
|
||||
TestPlayer player = null;
|
||||
TestMod gameMod = null;
|
||||
TestMod playerMod1 = null;
|
||||
TestMod playerMod2 = null;
|
||||
|
||||
AddStep("load player", () =>
|
||||
{
|
||||
Mods.Value = new[] { gameMod = new TestMod() };
|
||||
stack.Push(loader = new TestPlayerLoader(() => player = new TestPlayer()));
|
||||
});
|
||||
AddStep("load player", () => { ResetPlayer(true, () => SelectedMods.Value = new[] { gameMod = new TestMod() }); });
|
||||
|
||||
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
|
||||
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
||||
@ -97,10 +146,95 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("player mods applied", () => playerMod2.Applied);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestModDisplayChanges()
|
||||
{
|
||||
var testMod = new TestMod();
|
||||
|
||||
AddStep("load player", () => ResetPlayer(true));
|
||||
|
||||
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
|
||||
AddStep("set test mod in loader", () => loader.Mods.Value = new[] { testMod });
|
||||
AddAssert("test mod is displayed", () => (TestMod)loader.DisplayedMods.Single() == testMod);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMutedNotificationMasterVolume() => addVolumeSteps("master volume", () => audioManager.Volume.Value = 0, null, () => audioManager.Volume.IsDefault);
|
||||
|
||||
[Test]
|
||||
public void TestMutedNotificationTrackVolume() => addVolumeSteps("music volume", () => audioManager.VolumeTrack.Value = 0, null, () => audioManager.VolumeTrack.IsDefault);
|
||||
|
||||
[Test]
|
||||
public void TestMutedNotificationMuteButton() => addVolumeSteps("mute button", null, () => container.VolumeOverlay.IsMuted.Value = true, () => !container.VolumeOverlay.IsMuted.Value);
|
||||
|
||||
/// <remarks>
|
||||
/// Created for avoiding copy pasting code for the same steps.
|
||||
/// </remarks>
|
||||
/// <param name="volumeName">What part of the volume system is checked</param>
|
||||
/// <param name="beforeLoad">The action to be invoked to set the volume before loading</param>
|
||||
/// <param name="afterLoad">The action to be invoked to set the volume after loading</param>
|
||||
/// <param name="assert">The function to be invoked and checked</param>
|
||||
private void addVolumeSteps(string volumeName, Action beforeLoad, Action afterLoad, Func<bool> assert)
|
||||
{
|
||||
AddStep("reset notification lock", () => sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce).Value = false);
|
||||
|
||||
AddStep("load player", () => ResetPlayer(false, beforeLoad, afterLoad));
|
||||
AddUntilStep("wait for player", () => player.IsLoaded);
|
||||
|
||||
AddAssert("check for notification", () => container.NotificationOverlay.UnreadCount.Value == 1);
|
||||
AddStep("click notification", () =>
|
||||
{
|
||||
var scrollContainer = (OsuScrollContainer)container.NotificationOverlay.Children.Last();
|
||||
var flowContainer = scrollContainer.Children.OfType<FillFlowContainer<NotificationSection>>().First();
|
||||
var notification = flowContainer.First();
|
||||
|
||||
InputManager.MoveMouseTo(notification);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddAssert("check " + volumeName, assert);
|
||||
}
|
||||
|
||||
private class TestPlayerLoaderContainer : Container
|
||||
{
|
||||
[Cached]
|
||||
public readonly NotificationOverlay NotificationOverlay;
|
||||
|
||||
[Cached]
|
||||
public readonly VolumeOverlay VolumeOverlay;
|
||||
|
||||
public TestPlayerLoaderContainer(IScreen screen)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new OsuScreenStack(screen)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
NotificationOverlay = new NotificationOverlay
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
},
|
||||
VolumeOverlay = new VolumeOverlay
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private class TestPlayerLoader : PlayerLoader
|
||||
{
|
||||
public new VisualSettings VisualSettings => base.VisualSettings;
|
||||
|
||||
public new Task DisposalTask => base.DisposalTask;
|
||||
|
||||
public IReadOnlyList<Mod> DisplayedMods => MetadataInfo.Mods.Value;
|
||||
|
||||
public TestPlayerLoader(Func<Player> createPlayer)
|
||||
: base(createPlayer)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Lists;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Storyboards;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
@ -42,9 +43,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
});
|
||||
}
|
||||
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap)
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||
{
|
||||
var working = base.CreateWorkingBeatmap(beatmap);
|
||||
var working = base.CreateWorkingBeatmap(beatmap, storyboard);
|
||||
workingWeakReferences.Add(working);
|
||||
return working;
|
||||
}
|
||||
|
@ -26,12 +26,14 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
AddUntilStep("score above zero", () => ((ScoreAccessibleReplayPlayer)Player).ScoreProcessor.TotalScore.Value > 0);
|
||||
AddUntilStep("key counter counted keys", () => ((ScoreAccessibleReplayPlayer)Player).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0));
|
||||
AddAssert("cannot fail", () => !((ScoreAccessibleReplayPlayer)Player).AllowFail);
|
||||
}
|
||||
|
||||
private class ScoreAccessibleReplayPlayer : ReplayPlayer
|
||||
{
|
||||
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||
public new HUDOverlay HUDOverlay => base.HUDOverlay;
|
||||
public new bool AllowFail => base.AllowFail;
|
||||
|
||||
protected override bool PauseOnFocusLost => false;
|
||||
|
||||
|
@ -5,19 +5,22 @@ using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Ranking.Pages;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneReplayDownloadButton : OsuTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ReplayDownloadButton)
|
||||
@ -42,7 +45,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(80, 40),
|
||||
};
|
||||
});
|
||||
}
|
||||
@ -51,16 +53,15 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
return new APILegacyScoreInfo
|
||||
{
|
||||
ID = 1,
|
||||
OnlineScoreID = 2553163309,
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
OnlineRulesetID = 0,
|
||||
Replay = replayAvailable,
|
||||
User = new User
|
||||
{
|
||||
Id = 39828,
|
||||
Username = @"WubWoofWolf",
|
||||
}
|
||||
};
|
||||
}.CreateScoreInfo(rulesets);
|
||||
}
|
||||
|
||||
private class TestReplayDownloadButton : ReplayDownloadButton
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
@ -20,6 +21,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
State = { Value = Visibility.Visible }
|
||||
});
|
||||
|
||||
Add(container = new ExampleContainer());
|
||||
|
@ -3,11 +3,16 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Screens.Ranking.Pages;
|
||||
@ -22,11 +27,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ScoreInfo),
|
||||
typeof(Results),
|
||||
typeof(ResultsPage),
|
||||
typeof(ScoreResultsPage),
|
||||
typeof(LocalLeaderboardPage)
|
||||
typeof(RetryButton),
|
||||
typeof(ReplayDownloadButton),
|
||||
typeof(LocalLeaderboardPage),
|
||||
typeof(TestPlayer)
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -42,26 +49,82 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0);
|
||||
if (beatmapInfo != null)
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
|
||||
}
|
||||
|
||||
LoadScreen(new SoloResults(new ScoreInfo
|
||||
private TestSoloResults createResultsScreen() => new TestSoloResults(new ScoreInfo
|
||||
{
|
||||
TotalScore = 2845370,
|
||||
Accuracy = 0.98,
|
||||
MaxCombo = 123,
|
||||
Rank = ScoreRank.A,
|
||||
Date = DateTimeOffset.Now,
|
||||
Statistics = new Dictionary<HitResult, int>
|
||||
{
|
||||
TotalScore = 2845370,
|
||||
Accuracy = 0.98,
|
||||
MaxCombo = 123,
|
||||
Rank = ScoreRank.A,
|
||||
Date = DateTimeOffset.Now,
|
||||
Statistics = new Dictionary<HitResult, int>
|
||||
{ HitResult.Great, 50 },
|
||||
{ HitResult.Good, 20 },
|
||||
{ HitResult.Meh, 50 },
|
||||
{ HitResult.Miss, 1 }
|
||||
},
|
||||
User = new User
|
||||
{
|
||||
Username = "peppy",
|
||||
}
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void ResultsWithoutPlayer()
|
||||
{
|
||||
TestSoloResults screen = null;
|
||||
|
||||
AddStep("load results", () => Child = new OsuScreenStack(screen = createResultsScreen())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
});
|
||||
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||
AddAssert("retry overlay not present", () => screen.RetryOverlay == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResultsWithPlayer()
|
||||
{
|
||||
TestSoloResults screen = null;
|
||||
|
||||
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
|
||||
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
|
||||
}
|
||||
|
||||
private class TestResultsContainer : Container
|
||||
{
|
||||
[Cached(typeof(Player))]
|
||||
private readonly Player player = new TestPlayer();
|
||||
|
||||
public TestResultsContainer(IScreen screen)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
InternalChild = new OsuScreenStack(screen)
|
||||
{
|
||||
{ HitResult.Great, 50 },
|
||||
{ HitResult.Good, 20 },
|
||||
{ HitResult.Meh, 50 },
|
||||
{ HitResult.Miss, 1 }
|
||||
},
|
||||
User = new User
|
||||
{
|
||||
Username = "peppy",
|
||||
}
|
||||
}));
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private class TestSoloResults : SoloResults
|
||||
{
|
||||
public HotkeyRetryOverlay RetryOverlay;
|
||||
|
||||
public TestSoloResults(ScoreInfo score)
|
||||
: base(score)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
RetryOverlay = InternalChildren.OfType<HotkeyRetryOverlay>().SingleOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
|
@ -3,12 +3,14 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
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.Shapes;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -28,12 +30,16 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Cached(typeof(IReadOnlyList<Mod>))]
|
||||
private IReadOnlyList<Mod> mods { get; set; } = Array.Empty<Mod>();
|
||||
|
||||
private const int spawn_interval = 5000;
|
||||
|
||||
private readonly ScrollingTestContainer[] scrollContainers = new ScrollingTestContainer[4];
|
||||
private readonly TestPlayfield[] playfields = new TestPlayfield[4];
|
||||
private ScheduledDelegate hitObjectSpawnDelegate;
|
||||
|
||||
public TestSceneScrollingHitObjects()
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
Add(new GridContainer
|
||||
Child = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Content = new[]
|
||||
@ -43,48 +49,66 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
scrollContainers[0] = new ScrollingTestContainer(ScrollingDirection.Up)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = playfields[0] = new TestPlayfield()
|
||||
Child = playfields[0] = new TestPlayfield(),
|
||||
TimeRange = spawn_interval
|
||||
},
|
||||
scrollContainers[1] = new ScrollingTestContainer(ScrollingDirection.Up)
|
||||
scrollContainers[1] = new ScrollingTestContainer(ScrollingDirection.Down)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = playfields[1] = new TestPlayfield()
|
||||
Child = playfields[1] = new TestPlayfield(),
|
||||
TimeRange = spawn_interval
|
||||
},
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
scrollContainers[2] = new ScrollingTestContainer(ScrollingDirection.Up)
|
||||
scrollContainers[2] = new ScrollingTestContainer(ScrollingDirection.Left)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = playfields[2] = new TestPlayfield()
|
||||
Child = playfields[2] = new TestPlayfield(),
|
||||
TimeRange = spawn_interval
|
||||
},
|
||||
scrollContainers[3] = new ScrollingTestContainer(ScrollingDirection.Up)
|
||||
scrollContainers[3] = new ScrollingTestContainer(ScrollingDirection.Right)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = playfields[3] = new TestPlayfield()
|
||||
Child = playfields[3] = new TestPlayfield(),
|
||||
TimeRange = spawn_interval
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
setUpHitObjects();
|
||||
});
|
||||
|
||||
private void setUpHitObjects()
|
||||
{
|
||||
scrollContainers.ForEach(c => c.ControlPoints.Add(new MultiplierControlPoint(0)));
|
||||
|
||||
for (int i = 0; i <= spawn_interval; i += 1000)
|
||||
addHitObject(Time.Current + i);
|
||||
|
||||
hitObjectSpawnDelegate?.Cancel();
|
||||
hitObjectSpawnDelegate = Scheduler.AddDelayed(() => addHitObject(Time.Current + spawn_interval), 1000, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestScrollAlgorithms()
|
||||
{
|
||||
AddStep("Constant scroll", () => setScrollAlgorithm(ScrollVisualisationMethod.Constant));
|
||||
AddStep("Overlapping scroll", () => setScrollAlgorithm(ScrollVisualisationMethod.Overlapping));
|
||||
AddStep("Sequential scroll", () => setScrollAlgorithm(ScrollVisualisationMethod.Sequential));
|
||||
|
||||
AddSliderStep("Time range", 100, 10000, 5000, v => scrollContainers.ForEach(c => c.TimeRange = v));
|
||||
AddStep("Add control point", () => addControlPoint(Time.Current + 5000));
|
||||
AddSliderStep("Time range", 100, 10000, spawn_interval, v => scrollContainers.Where(c => c != null).ForEach(c => c.TimeRange = v));
|
||||
AddStep("Add control point", () => addControlPoint(Time.Current + spawn_interval));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
[Test]
|
||||
public void TestScrollLifetime()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
scrollContainers.ForEach(c => c.ControlPoints.Add(new MultiplierControlPoint(0)));
|
||||
|
||||
for (int i = 0; i <= 5000; i += 1000)
|
||||
addHitObject(Time.Current + i);
|
||||
|
||||
Scheduler.AddDelayed(() => addHitObject(Time.Current + 5000), 1000, true);
|
||||
AddStep("Set constant scroll", () => setScrollAlgorithm(ScrollVisualisationMethod.Constant));
|
||||
// scroll container time range must be less than the rate of spawning hitobjects
|
||||
// otherwise the hitobjects will spawn already partly visible on screen and look wrong
|
||||
AddStep("Set time range", () => scrollContainers.ForEach(c => c.TimeRange = spawn_interval / 2.0));
|
||||
}
|
||||
|
||||
private void addHitObject(double time)
|
||||
@ -200,10 +224,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateState(ArmedState state)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class TestDrawableHitObject : DrawableHitObject<HitObject>
|
||||
@ -211,15 +231,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public TestDrawableHitObject(double time)
|
||||
: base(new HitObject { StartTime = time })
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
Origin = Anchor.Custom;
|
||||
OriginPosition = new Vector2(75 / 4.0f);
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
AddInternal(new Box { Size = new Vector2(75) });
|
||||
}
|
||||
|
||||
protected override void UpdateState(ArmedState state)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,145 +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 NUnit.Framework;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneSkinReloadable : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestInitialLoad()
|
||||
{
|
||||
var secondarySource = new SecondarySource();
|
||||
SkinConsumer consumer = null;
|
||||
|
||||
AddStep("setup layout", () =>
|
||||
{
|
||||
Child = new SkinSourceContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new LocalSkinOverrideContainer(secondarySource)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true)
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox);
|
||||
AddAssert("skinchanged only called once", () => consumer.SkinChangedCount == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOverride()
|
||||
{
|
||||
var secondarySource = new SecondarySource();
|
||||
|
||||
SkinConsumer consumer = null;
|
||||
Container target = null;
|
||||
|
||||
AddStep("setup layout", () =>
|
||||
{
|
||||
Child = new SkinSourceContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = target = new LocalSkinOverrideContainer(secondarySource)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("add permissive", () => target.Add(consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true)));
|
||||
AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox);
|
||||
AddAssert("skinchanged only called once", () => consumer.SkinChangedCount == 1);
|
||||
}
|
||||
|
||||
private class NamedBox : Container
|
||||
{
|
||||
public NamedBox(string name)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.Black,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.Default.With(size: 40),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = name
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private class SkinConsumer : SkinnableDrawable
|
||||
{
|
||||
public new Drawable Drawable => base.Drawable;
|
||||
public int SkinChangedCount { get; private set; }
|
||||
|
||||
public SkinConsumer(string name, Func<string, Drawable> defaultImplementation, Func<ISkinSource, bool> allowFallback = null, bool restrictSize = true)
|
||||
: base(name, defaultImplementation, allowFallback, restrictSize)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||
{
|
||||
base.SkinChanged(skin, allowFallback);
|
||||
SkinChangedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
private class BaseSourceBox : NamedBox
|
||||
{
|
||||
public BaseSourceBox()
|
||||
: base("Base Source")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class SecondarySourceBox : NamedBox
|
||||
{
|
||||
public SecondarySourceBox()
|
||||
: base("Secondary Source")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class SecondarySource : ISkin
|
||||
{
|
||||
public Drawable GetDrawableComponent(string componentName) => new SecondarySourceBox();
|
||||
|
||||
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
||||
|
||||
public SampleChannel GetSample(string sampleName) => throw new NotImplementedException();
|
||||
|
||||
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private class SkinSourceContainer : Container, ISkin
|
||||
{
|
||||
public Drawable GetDrawableComponent(string componentName) => new BaseSourceBox();
|
||||
|
||||
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
||||
|
||||
public SampleChannel GetSample(string sampleName) => throw new NotImplementedException();
|
||||
|
||||
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
348
osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableDrawable.cs
Normal file
348
osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableDrawable.cs
Normal file
@ -0,0 +1,348 @@
|
||||
// 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.Globalization;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneSkinnableDrawable : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestConfineScaleDown()
|
||||
{
|
||||
FillFlowContainer<ExposedSkinnableDrawable> fill = null;
|
||||
|
||||
AddStep("setup layout larger source", () =>
|
||||
{
|
||||
Child = new SkinProvidingContainer(new SizedSource(50))
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = fill = new FillFlowContainer<ExposedSkinnableDrawable>
|
||||
{
|
||||
Size = new Vector2(30),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Spacing = new Vector2(10),
|
||||
Children = new[]
|
||||
{
|
||||
new ExposedSkinnableDrawable("default", _ => new DefaultBox(), _ => true),
|
||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true),
|
||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.ScaleToFit),
|
||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.NoScaling)
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
AddAssert("check sizes", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 30, 30, 30, 50 }));
|
||||
AddStep("adjust scale", () => fill.Scale = new Vector2(2));
|
||||
AddAssert("check sizes unchanged by scale", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 30, 30, 30, 50 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestConfineScaleUp()
|
||||
{
|
||||
FillFlowContainer<ExposedSkinnableDrawable> fill = null;
|
||||
|
||||
AddStep("setup layout larger source", () =>
|
||||
{
|
||||
Child = new SkinProvidingContainer(new SizedSource(30))
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = fill = new FillFlowContainer<ExposedSkinnableDrawable>
|
||||
{
|
||||
Size = new Vector2(50),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Spacing = new Vector2(10),
|
||||
Children = new[]
|
||||
{
|
||||
new ExposedSkinnableDrawable("default", _ => new DefaultBox(), _ => true),
|
||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true),
|
||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.ScaleToFit),
|
||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.NoScaling)
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
AddAssert("check sizes", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 50, 30, 50, 30 }));
|
||||
AddStep("adjust scale", () => fill.Scale = new Vector2(2));
|
||||
AddAssert("check sizes unchanged by scale", () => fill.Children.Select(c => c.Drawable.DrawWidth).SequenceEqual(new float[] { 50, 30, 50, 30 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInitialLoad()
|
||||
{
|
||||
var secondarySource = new SecondarySource();
|
||||
SkinConsumer consumer = null;
|
||||
|
||||
AddStep("setup layout", () =>
|
||||
{
|
||||
Child = new SkinSourceContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new SkinProvidingContainer(secondarySource)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true)
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox);
|
||||
AddAssert("skinchanged only called once", () => consumer.SkinChangedCount == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOverride()
|
||||
{
|
||||
var secondarySource = new SecondarySource();
|
||||
|
||||
SkinConsumer consumer = null;
|
||||
Container target = null;
|
||||
|
||||
AddStep("setup layout", () =>
|
||||
{
|
||||
Child = new SkinSourceContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = target = new SkinProvidingContainer(secondarySource)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("add permissive", () => target.Add(consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true)));
|
||||
AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox);
|
||||
AddAssert("skinchanged only called once", () => consumer.SkinChangedCount == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSwitchOff()
|
||||
{
|
||||
SkinConsumer consumer = null;
|
||||
SwitchableSkinProvidingContainer target = null;
|
||||
|
||||
AddStep("setup layout", () =>
|
||||
{
|
||||
Child = new SkinSourceContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = target = new SwitchableSkinProvidingContainer(new SecondarySource())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("add permissive", () => target.Add(consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true)));
|
||||
AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox);
|
||||
AddStep("disable", () => target.Disable());
|
||||
AddAssert("consumer using base source", () => consumer.Drawable is BaseSourceBox);
|
||||
}
|
||||
|
||||
private class SwitchableSkinProvidingContainer : SkinProvidingContainer
|
||||
{
|
||||
private bool allow = true;
|
||||
|
||||
protected override bool AllowDrawableLookup(ISkinComponent component) => allow;
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
allow = false;
|
||||
TriggerSourceChanged();
|
||||
}
|
||||
|
||||
public SwitchableSkinProvidingContainer(ISkin skin)
|
||||
: base(skin)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class ExposedSkinnableDrawable : SkinnableDrawable
|
||||
{
|
||||
public new Drawable Drawable => base.Drawable;
|
||||
|
||||
public ExposedSkinnableDrawable(string name, Func<ISkinComponent, Drawable> defaultImplementation, Func<ISkinSource, bool> allowFallback = null,
|
||||
ConfineMode confineMode = ConfineMode.ScaleDownToFit)
|
||||
: base(new TestSkinComponent(name), defaultImplementation, allowFallback, confineMode)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class DefaultBox : DrawWidthBox
|
||||
{
|
||||
public DefaultBox()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
}
|
||||
|
||||
private class DrawWidthBox : Container
|
||||
{
|
||||
private readonly OsuSpriteText text;
|
||||
|
||||
public DrawWidthBox()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.Gray,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
text.Text = DrawWidth.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
||||
private class NamedBox : Container
|
||||
{
|
||||
public NamedBox(string name)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.Black,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.Default.With(size: 40),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = name
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private class SkinConsumer : SkinnableDrawable
|
||||
{
|
||||
public new Drawable Drawable => base.Drawable;
|
||||
public int SkinChangedCount { get; private set; }
|
||||
|
||||
public SkinConsumer(string name, Func<ISkinComponent, Drawable> defaultImplementation, Func<ISkinSource, bool> allowFallback = null)
|
||||
: base(new TestSkinComponent(name), defaultImplementation, allowFallback)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||
{
|
||||
base.SkinChanged(skin, allowFallback);
|
||||
SkinChangedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
private class BaseSourceBox : NamedBox
|
||||
{
|
||||
public BaseSourceBox()
|
||||
: base("Base Source")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class SecondarySourceBox : NamedBox
|
||||
{
|
||||
public SecondarySourceBox()
|
||||
: base("Secondary Source")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class SizedSource : ISkin
|
||||
{
|
||||
private readonly float size;
|
||||
|
||||
public SizedSource(float size)
|
||||
{
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public Drawable GetDrawableComponent(ISkinComponent componentName) =>
|
||||
componentName.LookupName == "available"
|
||||
? new DrawWidthBox
|
||||
{
|
||||
Colour = Color4.Yellow,
|
||||
Size = new Vector2(size)
|
||||
}
|
||||
: null;
|
||||
|
||||
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
||||
|
||||
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private class SecondarySource : ISkin
|
||||
{
|
||||
public Drawable GetDrawableComponent(ISkinComponent componentName) => new SecondarySourceBox();
|
||||
|
||||
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
||||
|
||||
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[Cached(typeof(ISkinSource))]
|
||||
private class SkinSourceContainer : Container, ISkinSource
|
||||
{
|
||||
public Drawable GetDrawableComponent(ISkinComponent componentName) => new BaseSourceBox();
|
||||
|
||||
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
||||
|
||||
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();
|
||||
|
||||
public event Action SourceChanged
|
||||
{
|
||||
add { }
|
||||
remove { }
|
||||
}
|
||||
}
|
||||
|
||||
private class TestSkinComponent : ISkinComponent
|
||||
{
|
||||
public TestSkinComponent(string name)
|
||||
{
|
||||
LookupName = name;
|
||||
}
|
||||
|
||||
public string ComponentGroup => string.Empty;
|
||||
|
||||
public string LookupName { get; }
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +1,117 @@
|
||||
// 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.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneSkipOverlay : OsuTestScene
|
||||
public class TestSceneSkipOverlay : ManualInputManagerTestScene
|
||||
{
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
private SkipOverlay skip;
|
||||
private int requestCount;
|
||||
|
||||
Add(new SkipOverlay(Clock.CurrentTime + 5000));
|
||||
private double increment;
|
||||
|
||||
private GameplayClockContainer gameplayClockContainer;
|
||||
private GameplayClock gameplayClock;
|
||||
|
||||
private const double skip_time = 6000;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
requestCount = 0;
|
||||
increment = skip_time;
|
||||
|
||||
Child = gameplayClockContainer = new GameplayClockContainer(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), Array.Empty<Mod>(), 0)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
skip = new SkipOverlay(skip_time)
|
||||
{
|
||||
RequestSkip = () =>
|
||||
{
|
||||
requestCount++;
|
||||
gameplayClockContainer.Seek(gameplayClock.CurrentTime + increment);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
gameplayClockContainer.Start();
|
||||
gameplayClock = gameplayClockContainer.GameplayClock;
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestFadeOnIdle()
|
||||
{
|
||||
AddStep("move mouse", () => InputManager.MoveMouseTo(Vector2.Zero));
|
||||
AddUntilStep("fully visible", () => skip.Children.First().Alpha == 1);
|
||||
AddUntilStep("wait for fade", () => skip.Children.First().Alpha < 1);
|
||||
|
||||
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||
AddUntilStep("fully visible", () => skip.Children.First().Alpha == 1);
|
||||
AddUntilStep("wait for fade", () => skip.Children.First().Alpha < 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClickableAfterFade()
|
||||
{
|
||||
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||
AddUntilStep("wait for fade", () => skip.Children.First().Alpha == 0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
checkRequestCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClickOnlyActuatesOnce()
|
||||
{
|
||||
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||
AddStep("click", () =>
|
||||
{
|
||||
increment = skip_time - gameplayClock.CurrentTime - GameplayClockContainer.MINIMUM_SKIP_TIME / 2;
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
checkRequestCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClickOnlyActuatesMultipleTimes()
|
||||
{
|
||||
AddStep("set increment lower", () => increment = 3000);
|
||||
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
checkRequestCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoesntFadeOnMouseDown()
|
||||
{
|
||||
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||
AddStep("button down", () => InputManager.PressButton(MouseButton.Left));
|
||||
AddUntilStep("wait for overlay disappear", () => !skip.IsPresent);
|
||||
AddAssert("ensure button didn't disappear", () => skip.Children.First().Alpha > 0);
|
||||
AddStep("button up", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||
checkRequestCount(0);
|
||||
}
|
||||
|
||||
private void checkRequestCount(int expected) =>
|
||||
AddAssert($"request count is {expected}", () => requestCount == expected);
|
||||
}
|
||||
}
|
||||
|
193
osu.Game.Tests/Visual/Gameplay/TestSceneSliderPath.cs
Normal file
193
osu.Game.Tests/Visual/Gameplay/TestSceneSliderPath.cs
Normal file
@ -0,0 +1,193 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Lines;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneSliderPath : OsuTestScene
|
||||
{
|
||||
private readonly SmoothPath drawablePath;
|
||||
private SliderPath path;
|
||||
|
||||
public TestSceneSliderPath()
|
||||
{
|
||||
Child = drawablePath = new SmoothPath
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
};
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup() => Schedule(() =>
|
||||
{
|
||||
path = new SliderPath();
|
||||
});
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (path != null)
|
||||
{
|
||||
List<Vector2> vertices = new List<Vector2>();
|
||||
path.GetPathToProgress(vertices, 0, 1);
|
||||
|
||||
drawablePath.Vertices = vertices;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmptyPath()
|
||||
{
|
||||
}
|
||||
|
||||
[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(PathType.Linear)]
|
||||
[TestCase(PathType.Bezier)]
|
||||
[TestCase(PathType.Catmull)]
|
||||
[TestCase(PathType.PerfectCurve)]
|
||||
public void TestMultipleSegment(PathType type)
|
||||
{
|
||||
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));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddControlPoint()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(0, 100))));
|
||||
AddStep("add point", () => path.ControlPoints.Add(new PathControlPoint { Position = { Value = new Vector2(100) } }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInsertControlPoint()
|
||||
{
|
||||
AddStep("create path", () => path.ControlPoints.AddRange(createSegment(PathType.Linear, Vector2.Zero, new Vector2(100))));
|
||||
AddStep("insert point", () => path.ControlPoints.Insert(1, new PathControlPoint { Position = { Value = 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("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.Value = 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.Value = PathType.Bezier);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemoveSegmentByChangingType()
|
||||
{
|
||||
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.Value = PathType.Bezier;
|
||||
});
|
||||
|
||||
AddStep("change second point type to null", () => path.ControlPoints[1].Type.Value = null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemoveSegmentByRemovingControlPoint()
|
||||
{
|
||||
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.Value = PathType.Bezier;
|
||||
});
|
||||
|
||||
AddStep("remove second point", () => path.ControlPoints.RemoveAt(1));
|
||||
}
|
||||
|
||||
[TestCase(2)]
|
||||
[TestCase(4)]
|
||||
public void TestPerfectCurveFallbackScenarios(int points)
|
||||
{
|
||||
AddStep("create path", () =>
|
||||
{
|
||||
switch (points)
|
||||
{
|
||||
case 2:
|
||||
path.ControlPoints.AddRange(createSegment(PathType.PerfectCurve, 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)));
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLengthenLastSegment()
|
||||
{
|
||||
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("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("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("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("shorten to -10 length", () => path.ExpectedDistance.Value = -10);
|
||||
}
|
||||
|
||||
private List<PathControlPoint> createSegment(PathType type, params Vector2[] controlPoints)
|
||||
{
|
||||
var points = controlPoints.Select(p => new PathControlPoint { Position = { Value = p } }).ToList();
|
||||
points[0].Type.Value = type;
|
||||
return points;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,10 +6,7 @@ using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
@ -21,32 +21,38 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
private readonly Container<DrawableStoryboard> storyboardContainer;
|
||||
private DrawableStoryboard storyboard;
|
||||
|
||||
[Cached]
|
||||
private MusicController musicController = new MusicController();
|
||||
|
||||
public TestSceneStoryboard()
|
||||
{
|
||||
Clock = new FramedClock();
|
||||
|
||||
Add(new Container
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
musicController,
|
||||
new Container
|
||||
{
|
||||
new Box
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
storyboardContainer = new Container<DrawableStoryboard>
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
storyboardContainer = new Container<DrawableStoryboard>
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Add(new MusicController
|
||||
{
|
||||
Origin = Anchor.TopRight,
|
||||
Anchor = Anchor.TopRight,
|
||||
State = { Value = Visibility.Visible },
|
||||
new NowPlayingOverlay
|
||||
{
|
||||
Origin = Anchor.TopRight,
|
||||
Anchor = Anchor.TopRight,
|
||||
State = { Value = Visibility.Visible },
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("Restart", restart);
|
||||
|
69
osu.Game.Tests/Visual/Menus/IntroTestScene.cs
Normal file
69
osu.Game.Tests/Visual/Menus/IntroTestScene.cs
Normal file
@ -0,0 +1,69 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
[TestFixture]
|
||||
public abstract class IntroTestScene : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(StartupScreen),
|
||||
typeof(IntroScreen),
|
||||
typeof(OsuScreen),
|
||||
typeof(IntroTestScene),
|
||||
};
|
||||
|
||||
[Cached]
|
||||
private OsuLogo logo;
|
||||
|
||||
protected IntroTestScene()
|
||||
{
|
||||
Drawable introStack = null;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = float.MaxValue,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
logo = new OsuLogo
|
||||
{
|
||||
Alpha = 0,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Depth = float.MinValue,
|
||||
Position = new Vector2(0.5f),
|
||||
}
|
||||
};
|
||||
|
||||
AddStep("restart sequence", () =>
|
||||
{
|
||||
logo.FinishTransforms();
|
||||
logo.IsTracking = false;
|
||||
|
||||
introStack?.Expire();
|
||||
|
||||
Add(introStack = new OsuScreenStack(CreateScreen())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract IScreen CreateScreen();
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Users;
|
||||
|
||||
@ -10,23 +9,18 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
public class TestSceneDisclaimer : ScreenTestScene
|
||||
{
|
||||
[Cached(typeof(IAPIProvider))]
|
||||
private readonly DummyAPIAccess api = new DummyAPIAccess();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Add(api);
|
||||
|
||||
AddStep("load disclaimer", () => LoadScreen(new Disclaimer()));
|
||||
|
||||
AddStep("toggle support", () =>
|
||||
{
|
||||
api.LocalUser.Value = new User
|
||||
API.LocalUser.Value = new User
|
||||
{
|
||||
Username = api.LocalUser.Value.Username,
|
||||
Id = api.LocalUser.Value.Id,
|
||||
IsSupporter = !api.LocalUser.Value.IsSupporter,
|
||||
Username = API.LocalUser.Value.Username,
|
||||
Id = API.LocalUser.Value.Id,
|
||||
IsSupporter = !API.LocalUser.Value.IsSupporter,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
15
osu.Game.Tests/Visual/Menus/TestSceneIntroCircles.cs
Normal file
15
osu.Game.Tests/Visual/Menus/TestSceneIntroCircles.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// 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.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneIntroCircles : IntroTestScene
|
||||
{
|
||||
protected override IScreen CreateScreen() => new IntroCircles();
|
||||
}
|
||||
}
|
@ -1,54 +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 NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneIntroSequence : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(OsuLogo),
|
||||
};
|
||||
|
||||
public TestSceneIntroSequence()
|
||||
{
|
||||
OsuLogo logo;
|
||||
|
||||
var rateAdjustClock = new StopwatchClock(true);
|
||||
var framedClock = new FramedClock(rateAdjustClock);
|
||||
framedClock.ProcessFrame();
|
||||
|
||||
Add(new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Clock = framedClock,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
logo = new OsuLogo
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AddStep(@"Restart", logo.PlayIntro);
|
||||
AddSliderStep("Playback speed", 0.0, 2.0, 1, v => rateAdjustClock.Rate = v);
|
||||
}
|
||||
}
|
||||
}
|
15
osu.Game.Tests/Visual/Menus/TestSceneIntroTriangles.cs
Normal file
15
osu.Game.Tests/Visual/Menus/TestSceneIntroTriangles.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// 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.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneIntroTriangles : IntroTestScene
|
||||
{
|
||||
protected override IScreen CreateScreen() => new IntroTriangles();
|
||||
}
|
||||
}
|
@ -33,23 +33,15 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
[Test]
|
||||
public void TestInstantLoad()
|
||||
{
|
||||
bool logoVisible = false;
|
||||
// visual only, very impossible to test this using asserts.
|
||||
|
||||
AddStep("begin loading", () =>
|
||||
AddStep("load immediately", () =>
|
||||
{
|
||||
loader = new TestLoader();
|
||||
loader.AllowLoad.Set();
|
||||
|
||||
LoadScreen(loader);
|
||||
});
|
||||
|
||||
AddUntilStep("loaded", () =>
|
||||
{
|
||||
logoVisible = loader.Logo?.Alpha > 0;
|
||||
return loader.Logo != null && loader.ScreenLoaded;
|
||||
});
|
||||
|
||||
AddAssert("logo was not visible", () => !logoVisible);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -58,7 +50,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
AddStep("begin loading", () => LoadScreen(loader = new TestLoader()));
|
||||
AddUntilStep("wait for logo visible", () => loader.Logo?.Alpha > 0);
|
||||
AddStep("finish loading", () => loader.AllowLoad.Set());
|
||||
AddAssert("loaded", () => loader.Logo != null && loader.ScreenLoaded);
|
||||
AddUntilStep("loaded", () => loader.Logo != null && loader.ScreenLoaded);
|
||||
AddUntilStep("logo gone", () => loader.Logo?.Alpha == 0);
|
||||
}
|
||||
|
||||
|
244
osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs
Normal file
244
osu.Game.Tests/Visual/Menus/TestSceneScreenNavigation.cs
Normal file
@ -0,0 +1,244 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
using IntroSequence = osu.Game.Configuration.IntroSequence;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
public class TestSceneScreenNavigation : ManualInputManagerTestScene
|
||||
{
|
||||
private const float click_padding = 25;
|
||||
|
||||
private GameHost host;
|
||||
private TestOsuGame game;
|
||||
|
||||
private Vector2 backButtonPosition => game.ToScreenSpace(new Vector2(click_padding, game.LayoutRectangle.Bottom - click_padding));
|
||||
|
||||
private Vector2 optionsButtonPosition => game.ToScreenSpace(new Vector2(click_padding, click_padding));
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host)
|
||||
{
|
||||
this.host = host;
|
||||
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
};
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("Create new game instance", () =>
|
||||
{
|
||||
if (game != null)
|
||||
{
|
||||
Remove(game);
|
||||
game.Dispose();
|
||||
}
|
||||
|
||||
game = new TestOsuGame(LocalStorage, API);
|
||||
game.SetHost(host);
|
||||
|
||||
// todo: this can be removed once we can run audio trakcs without a device present
|
||||
// see https://github.com/ppy/osu/issues/1302
|
||||
game.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles);
|
||||
|
||||
Add(game);
|
||||
});
|
||||
AddUntilStep("Wait for load", () => game.IsLoaded);
|
||||
AddUntilStep("Wait for intro", () => game.ScreenStack.CurrentScreen is IntroScreen);
|
||||
confirmAtMainMenu();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExitSongSelectWithEscape()
|
||||
{
|
||||
TestSongSelect songSelect = null;
|
||||
|
||||
pushAndConfirm(() => songSelect = new TestSongSelect());
|
||||
AddStep("Show mods overlay", () => songSelect.ModSelectOverlay.Show());
|
||||
AddAssert("Overlay was shown", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible);
|
||||
pushEscape();
|
||||
AddAssert("Overlay was hidden", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden);
|
||||
exitViaEscapeAndConfirm();
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void TestSongContinuesAfterExitPlayer(bool withUserPause)
|
||||
{
|
||||
Player player = null;
|
||||
|
||||
WorkingBeatmap beatmap() => game.Beatmap.Value;
|
||||
Track track() => beatmap().Track;
|
||||
|
||||
pushAndConfirm(() => new TestSongSelect());
|
||||
|
||||
AddStep("import beatmap", () => ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).Wait());
|
||||
|
||||
AddUntilStep("wait for selected", () => !game.Beatmap.IsDefault);
|
||||
|
||||
if (withUserPause)
|
||||
AddStep("pause", () => game.Dependencies.Get<MusicController>().Stop());
|
||||
|
||||
AddStep("press enter", () => pressAndRelease(Key.Enter));
|
||||
|
||||
AddUntilStep("wait for player", () => (player = game.ScreenStack.CurrentScreen as Player) != null);
|
||||
AddUntilStep("wait for fail", () => player.HasFailed);
|
||||
|
||||
AddUntilStep("wait for track stop", () => !track().IsRunning);
|
||||
AddAssert("Ensure time before preview point", () => track().CurrentTime < beatmap().Metadata.PreviewTime);
|
||||
|
||||
pushEscape();
|
||||
|
||||
AddUntilStep("wait for track playing", () => track().IsRunning);
|
||||
AddAssert("Ensure time wasn't reset to preview point", () => track().CurrentTime < beatmap().Metadata.PreviewTime);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExitSongSelectWithClick()
|
||||
{
|
||||
TestSongSelect songSelect = null;
|
||||
|
||||
pushAndConfirm(() => songSelect = new TestSongSelect());
|
||||
AddStep("Show mods overlay", () => songSelect.ModSelectOverlay.Show());
|
||||
AddAssert("Overlay was shown", () => songSelect.ModSelectOverlay.State.Value == Visibility.Visible);
|
||||
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(backButtonPosition));
|
||||
|
||||
// BackButton handles hover using its child button, so this checks whether or not any of BackButton's children are hovered.
|
||||
AddUntilStep("Back button is hovered", () => InputManager.HoveredDrawables.Any(d => d.Parent == game.BackButton));
|
||||
|
||||
AddStep("Click back button", () => InputManager.Click(MouseButton.Left));
|
||||
AddUntilStep("Overlay was hidden", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden);
|
||||
exitViaBackButtonAndConfirm();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExitMultiWithEscape()
|
||||
{
|
||||
pushAndConfirm(() => new Screens.Multi.Multiplayer());
|
||||
exitViaEscapeAndConfirm();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestExitMultiWithBackButton()
|
||||
{
|
||||
pushAndConfirm(() => new Screens.Multi.Multiplayer());
|
||||
exitViaBackButtonAndConfirm();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOpenOptionsAndExitWithEscape()
|
||||
{
|
||||
AddUntilStep("Wait for options to load", () => game.Settings.IsLoaded);
|
||||
AddStep("Enter menu", () => pressAndRelease(Key.Enter));
|
||||
AddStep("Move mouse to options overlay", () => InputManager.MoveMouseTo(optionsButtonPosition));
|
||||
AddStep("Click options overlay", () => InputManager.Click(MouseButton.Left));
|
||||
AddAssert("Options overlay was opened", () => game.Settings.State.Value == Visibility.Visible);
|
||||
AddStep("Hide options overlay using escape", () => pressAndRelease(Key.Escape));
|
||||
AddAssert("Options overlay was closed", () => game.Settings.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
private void pushAndConfirm(Func<Screen> newScreen)
|
||||
{
|
||||
Screen screen = null;
|
||||
AddStep("Push new screen", () => game.ScreenStack.Push(screen = newScreen()));
|
||||
AddUntilStep("Wait for new screen", () => game.ScreenStack.CurrentScreen == screen && screen.IsLoaded);
|
||||
}
|
||||
|
||||
private void pushEscape() =>
|
||||
AddStep("Press escape", () => pressAndRelease(Key.Escape));
|
||||
|
||||
private void exitViaEscapeAndConfirm()
|
||||
{
|
||||
pushEscape();
|
||||
confirmAtMainMenu();
|
||||
}
|
||||
|
||||
private void exitViaBackButtonAndConfirm()
|
||||
{
|
||||
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(backButtonPosition));
|
||||
AddStep("Click back button", () => InputManager.Click(MouseButton.Left));
|
||||
confirmAtMainMenu();
|
||||
}
|
||||
|
||||
private void confirmAtMainMenu() => AddUntilStep("Wait for main menu", () => game.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);
|
||||
|
||||
private void pressAndRelease(Key key)
|
||||
{
|
||||
InputManager.PressKey(key);
|
||||
InputManager.ReleaseKey(key);
|
||||
}
|
||||
|
||||
private class TestOsuGame : OsuGame
|
||||
{
|
||||
public new ScreenStack ScreenStack => base.ScreenStack;
|
||||
|
||||
public new BackButton BackButton => base.BackButton;
|
||||
|
||||
public new SettingsPanel Settings => base.Settings;
|
||||
|
||||
public new OsuConfigManager LocalConfig => base.LocalConfig;
|
||||
|
||||
public new Bindable<WorkingBeatmap> Beatmap => base.Beatmap;
|
||||
|
||||
protected override Loader CreateLoader() => new TestLoader();
|
||||
|
||||
public TestOsuGame(Storage storage, IAPIProvider api)
|
||||
{
|
||||
Storage = storage;
|
||||
API = api;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
API.Login("Rhythm Champion", "osu!");
|
||||
}
|
||||
}
|
||||
|
||||
private class TestSongSelect : PlaySongSelect
|
||||
{
|
||||
public ModSelectOverlay ModSelectOverlay => ModSelect;
|
||||
}
|
||||
|
||||
private class TestLoader : Loader
|
||||
{
|
||||
protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler();
|
||||
|
||||
private class TestShaderPrecompiler : ShaderPrecompiler
|
||||
{
|
||||
protected override bool AllLoaded => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
// 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 osu.Game.Beatmaps;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Screens.Multi.Match.Components;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Audio;
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
[Cached(typeof(IPreviewTrackOwner))]
|
||||
public class TestSceneMatchBeatmapPanel : MultiplayerTestScene, IPreviewTrackOwner
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(MatchBeatmapPanel)
|
||||
};
|
||||
|
||||
[Resolved]
|
||||
private PreviewTrackManager previewTrackManager { get; set; }
|
||||
|
||||
public TestSceneMatchBeatmapPanel()
|
||||
{
|
||||
Add(new MatchBeatmapPanel
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
});
|
||||
|
||||
Room.Playlist.Add(new PlaylistItem { Beatmap = new BeatmapInfo { OnlineBeatmapID = 1763072 } });
|
||||
Room.Playlist.Add(new PlaylistItem { Beatmap = new BeatmapInfo { OnlineBeatmapID = 2101557 } });
|
||||
Room.Playlist.Add(new PlaylistItem { Beatmap = new BeatmapInfo { OnlineBeatmapID = 1973466 } });
|
||||
Room.Playlist.Add(new PlaylistItem { Beatmap = new BeatmapInfo { OnlineBeatmapID = 2109801 } });
|
||||
Room.Playlist.Add(new PlaylistItem { Beatmap = new BeatmapInfo { OnlineBeatmapID = 1922035 } });
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
AddStep("Select random beatmap", () =>
|
||||
{
|
||||
Room.CurrentItem.Value = Room.Playlist[RNG.Next(Room.Playlist.Count)];
|
||||
previewTrackManager.StopAnyPlaying(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
typeof(Info),
|
||||
typeof(HeaderButton),
|
||||
typeof(ReadyButton),
|
||||
typeof(ViewBeatmapButton)
|
||||
typeof(MatchBeatmapPanel)
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -14,6 +14,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneMatchLeaderboard : MultiplayerTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public TestSceneMatchLeaderboard()
|
||||
{
|
||||
Room.RoomID.Value = 3;
|
||||
@ -27,11 +29,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
});
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(IAPIProvider api)
|
||||
{
|
||||
var req = new GetRoomScoresRequest();
|
||||
req.Success += v => { };
|
||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
});
|
||||
|
||||
AddStep(@"set max", () => Room.MaxParticipants.Value = 10);
|
||||
AddStep(@"clear users", () => Room.Participants.Value = new User[] { });
|
||||
AddStep(@"clear users", () => Room.Participants.Value = System.Array.Empty<User>());
|
||||
AddStep(@"set max to null", () => Room.MaxParticipants.Value = null);
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
private class TestMatchLeaderboard : RoomLeaderboardPage.ResultsMatchLeaderboard
|
||||
{
|
||||
protected override APIRequest FetchScores(Action<IEnumerable<APIRoomScoreInfo>> scoresCallback)
|
||||
protected override APIRequest FetchScores(Action<IEnumerable<APIUserScoreAggregate>> scoresCallback)
|
||||
{
|
||||
var scores = Enumerable.Range(0, 50).Select(createRoomScore).ToArray();
|
||||
|
||||
@ -93,7 +93,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
return null;
|
||||
}
|
||||
|
||||
private APIRoomScoreInfo createRoomScore(int id) => new APIRoomScoreInfo
|
||||
private APIUserScoreAggregate createRoomScore(int id) => new APIUserScoreAggregate
|
||||
{
|
||||
User = new User { Id = id, Username = $"User {id}" },
|
||||
Accuracy = 0.98,
|
||||
|
@ -12,6 +12,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[TestFixture]
|
||||
public class TestSceneMultiScreen : ScreenTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(Screens.Multi.Multiplayer),
|
||||
|
@ -4,9 +4,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.AccountCreation;
|
||||
using osu.Game.Users;
|
||||
@ -25,17 +25,16 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(AccountCreationScreen),
|
||||
};
|
||||
|
||||
[Cached(typeof(IAPIProvider))]
|
||||
private DummyAPIAccess api = new DummyAPIAccess();
|
||||
private readonly Container userPanelArea;
|
||||
|
||||
private Bindable<User> localUser;
|
||||
|
||||
public TestSceneAccountCreationOverlay()
|
||||
{
|
||||
Container userPanelArea;
|
||||
AccountCreationOverlay accountCreation;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
api,
|
||||
accountCreation = new AccountCreationOverlay(),
|
||||
userPanelArea = new Container
|
||||
{
|
||||
@ -46,11 +45,18 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
};
|
||||
|
||||
api.Logout();
|
||||
api.LocalUser.BindValueChanged(user => { userPanelArea.Child = new UserPanel(user.NewValue) { Width = 200 }; }, true);
|
||||
|
||||
AddStep("show", () => accountCreation.Show());
|
||||
AddStep("logout", () => api.Logout());
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
API.Logout();
|
||||
|
||||
localUser = API.LocalUser.GetBoundCopy();
|
||||
localUser.BindValueChanged(user => { userPanelArea.Child = new UserPanel(user.NewValue) { Width = 200 }; }, true);
|
||||
|
||||
AddStep("logout", API.Logout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
102
osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs
Normal file
102
osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs
Normal file
@ -0,0 +1,102 @@
|
||||
// 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.UserInterface;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays.BeatmapSet;
|
||||
using osu.Game.Rulesets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneBeatmapRulesetSelector : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(BeatmapRulesetSelector),
|
||||
typeof(BeatmapRulesetTabItem),
|
||||
};
|
||||
|
||||
private readonly TestRulesetSelector selector;
|
||||
|
||||
public TestSceneBeatmapRulesetSelector()
|
||||
{
|
||||
Add(selector = new TestRulesetSelector());
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
[Test]
|
||||
public void TestMultipleRulesetsBeatmapSet()
|
||||
{
|
||||
var enabledRulesets = rulesets.AvailableRulesets.Skip(1).Take(2);
|
||||
|
||||
AddStep("load multiple rulesets beatmapset", () =>
|
||||
{
|
||||
selector.BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Beatmaps = enabledRulesets.Select(r => new BeatmapInfo { Ruleset = r }).ToList()
|
||||
};
|
||||
});
|
||||
|
||||
var tabItems = selector.TabContainer.TabItems;
|
||||
AddAssert("other rulesets disabled", () => tabItems.Except(tabItems.Where(t => enabledRulesets.Any(r => r.Equals(t.Value)))).All(t => !t.Enabled.Value));
|
||||
AddAssert("left-most ruleset selected", () => tabItems.First(t => t.Enabled.Value).Active.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSingleRulesetBeatmapSet()
|
||||
{
|
||||
var enabledRuleset = rulesets.AvailableRulesets.Last();
|
||||
|
||||
AddStep("load single ruleset beatmapset", () =>
|
||||
{
|
||||
selector.BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
{
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = enabledRuleset
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
AddAssert("single ruleset selected", () => selector.SelectedTab.Value.Equals(enabledRuleset));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmptyBeatmapSet()
|
||||
{
|
||||
AddStep("load empty beatmapset", () => selector.BeatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
Beatmaps = new List<BeatmapInfo>()
|
||||
});
|
||||
|
||||
AddAssert("no ruleset selected", () => selector.SelectedTab == null);
|
||||
AddAssert("all rulesets disabled", () => selector.TabContainer.TabItems.All(t => !t.Enabled.Value));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNullBeatmapSet()
|
||||
{
|
||||
AddStep("load null beatmapset", () => selector.BeatmapSet = null);
|
||||
|
||||
AddAssert("no ruleset selected", () => selector.SelectedTab == null);
|
||||
AddAssert("all rulesets disabled", () => selector.TabContainer.TabItems.All(t => !t.Enabled.Value));
|
||||
}
|
||||
|
||||
private class TestRulesetSelector : BeatmapRulesetSelector
|
||||
{
|
||||
public new TabItem<RulesetInfo> SelectedTab => base.SelectedTab;
|
||||
|
||||
public new TabFillFlowContainer TabContainer => base.TabContainer;
|
||||
}
|
||||
}
|
||||
}
|
@ -40,22 +40,20 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(PreviewButton),
|
||||
typeof(SuccessRate),
|
||||
typeof(BeatmapAvailability),
|
||||
typeof(BeatmapRulesetSelector),
|
||||
typeof(BeatmapRulesetTabItem),
|
||||
typeof(NotSupporterPlaceholder)
|
||||
};
|
||||
|
||||
private RulesetInfo taikoRuleset;
|
||||
private RulesetInfo maniaRuleset;
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public TestSceneBeatmapSetOverlay()
|
||||
{
|
||||
Add(overlay = new TestBeatmapSetOverlay());
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets)
|
||||
{
|
||||
taikoRuleset = rulesets.GetRuleset(1);
|
||||
maniaRuleset = rulesets.GetRuleset(3);
|
||||
}
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
[Test]
|
||||
public void TestLoading()
|
||||
@ -108,7 +106,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
StarDifficulty = 9.99,
|
||||
Version = @"TEST",
|
||||
Ruleset = maniaRuleset,
|
||||
Length = 456000,
|
||||
Ruleset = rulesets.GetRuleset(3),
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
CircleSize = 1,
|
||||
@ -118,7 +117,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
OnlineInfo = new BeatmapOnlineInfo
|
||||
{
|
||||
Length = 456000,
|
||||
CircleCount = 111,
|
||||
SliderCount = 12,
|
||||
PlayCount = 222,
|
||||
@ -135,6 +133,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
});
|
||||
|
||||
downloadAssert(true);
|
||||
|
||||
AddStep("show many difficulties", () => overlay.ShowBeatmapSet(createManyDifficultiesBeatmapSet()));
|
||||
downloadAssert(true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -173,6 +174,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
HasVideo = true,
|
||||
HasStoryboard = true,
|
||||
Covers = new BeatmapSetOnlineCovers(),
|
||||
Language = new BeatmapSetOnlineLanguage { Id = 3, Name = "English" },
|
||||
Genre = new BeatmapSetOnlineGenre { Id = 4, Name = "Rock" },
|
||||
},
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
@ -181,7 +184,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
StarDifficulty = 5.67,
|
||||
Version = @"ANOTHER TEST",
|
||||
Ruleset = taikoRuleset,
|
||||
Length = 123000,
|
||||
Ruleset = rulesets.GetRuleset(1),
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
CircleSize = 9,
|
||||
@ -191,7 +195,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
OnlineInfo = new BeatmapOnlineInfo
|
||||
{
|
||||
Length = 123000,
|
||||
CircleCount = 123,
|
||||
SliderCount = 45,
|
||||
PlayCount = 567,
|
||||
@ -210,6 +213,54 @@ namespace osu.Game.Tests.Visual.Online
|
||||
downloadAssert(false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleRulesets()
|
||||
{
|
||||
AddStep("show multiple rulesets beatmap", () =>
|
||||
{
|
||||
var beatmaps = new List<BeatmapInfo>();
|
||||
|
||||
foreach (var ruleset in rulesets.AvailableRulesets.Skip(1))
|
||||
{
|
||||
beatmaps.Add(new BeatmapInfo
|
||||
{
|
||||
Version = ruleset.Name,
|
||||
Ruleset = ruleset,
|
||||
BaseDifficulty = new BeatmapDifficulty(),
|
||||
OnlineInfo = new BeatmapOnlineInfo(),
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
overlay.ShowBeatmapSet(new BeatmapSetInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = @"multiple rulesets beatmap",
|
||||
Artist = @"none",
|
||||
Author = new User
|
||||
{
|
||||
Username = "BanchoBot",
|
||||
Id = 3,
|
||||
}
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
{
|
||||
Covers = new BeatmapSetOnlineCovers(),
|
||||
},
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
||||
Beatmaps = beatmaps
|
||||
});
|
||||
});
|
||||
|
||||
AddAssert("shown beatmaps of current ruleset", () => overlay.Header.Picker.Difficulties.All(b => b.Beatmap.Ruleset.Equals(overlay.Header.RulesetSelector.Current.Value)));
|
||||
AddAssert("left-most beatmap selected", () => overlay.Header.Picker.Difficulties.First().State == BeatmapPicker.DifficultySelectorState.Selected);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHide()
|
||||
{
|
||||
@ -222,14 +273,64 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep(@"show without reload", overlay.Show);
|
||||
}
|
||||
|
||||
private BeatmapSetInfo createManyDifficultiesBeatmapSet()
|
||||
{
|
||||
var beatmaps = new List<BeatmapInfo>();
|
||||
|
||||
for (int i = 1; i < 41; i++)
|
||||
{
|
||||
beatmaps.Add(new BeatmapInfo
|
||||
{
|
||||
OnlineBeatmapID = i * 10,
|
||||
Version = $"Test #{i}",
|
||||
Ruleset = Ruleset.Value,
|
||||
StarDifficulty = 2 + i * 0.1,
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
OverallDifficulty = 3.5f,
|
||||
},
|
||||
OnlineInfo = new BeatmapOnlineInfo(),
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return new BeatmapSetInfo
|
||||
{
|
||||
OnlineBeatmapSetID = 123,
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = @"many difficulties beatmap",
|
||||
Artist = @"none",
|
||||
Author = new User
|
||||
{
|
||||
Username = @"BanchoBot",
|
||||
Id = 3,
|
||||
},
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
{
|
||||
Preview = @"https://b.ppy.sh/preview/123.mp3",
|
||||
HasVideo = true,
|
||||
HasStoryboard = true,
|
||||
Covers = new BeatmapSetOnlineCovers(),
|
||||
},
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() },
|
||||
Beatmaps = beatmaps,
|
||||
};
|
||||
}
|
||||
|
||||
private void downloadAssert(bool shown)
|
||||
{
|
||||
AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.DownloadButtonsVisible == shown);
|
||||
AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.DownloadButtonsVisible == shown);
|
||||
}
|
||||
|
||||
private class TestBeatmapSetOverlay : BeatmapSetOverlay
|
||||
{
|
||||
public bool DownloadButtonsVisible => Header.DownloadButtonsVisible;
|
||||
public new Header Header => base.Header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays.BeatmapSet;
|
||||
using osu.Game.Screens.Select.Details;
|
||||
@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("set second set", () => details.BeatmapSet = secondSet);
|
||||
AddAssert("ratings set", () => details.Ratings.Metrics == secondSet.Metrics);
|
||||
|
||||
BeatmapSetInfo createSet() => new BeatmapSetInfo
|
||||
static BeatmapSetInfo createSet() => new BeatmapSetInfo
|
||||
{
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).Select(_ => RNG.Next(10)).ToArray() },
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
|
@ -8,7 +8,7 @@ using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays.BeatmapSet;
|
||||
using osu.Game.Screens.Select.Details;
|
||||
@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("set second set", () => successRate.Beatmap = secondBeatmap);
|
||||
AddAssert("ratings set", () => successRate.Graph.Metrics == secondBeatmap.Metrics);
|
||||
|
||||
BeatmapInfo createBeatmap() => new BeatmapInfo
|
||||
static BeatmapInfo createBeatmap() => new BeatmapInfo
|
||||
{
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
|
@ -27,6 +27,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(Comments),
|
||||
};
|
||||
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -66,6 +68,34 @@ namespace osu.Game.Tests.Visual.Online
|
||||
changelog.ShowListing();
|
||||
changelog.Show();
|
||||
});
|
||||
|
||||
AddStep(@"Ensure HTML string unescaping", () =>
|
||||
{
|
||||
changelog.ShowBuild(new APIChangelogBuild
|
||||
{
|
||||
Version = "2019.920.0",
|
||||
DisplayVersion = "2019.920.0",
|
||||
UpdateStream = new APIUpdateStream
|
||||
{
|
||||
Name = "Test",
|
||||
DisplayName = "Test"
|
||||
},
|
||||
ChangelogEntries = new List<APIChangelogEntry>
|
||||
{
|
||||
new APIChangelogEntry
|
||||
{
|
||||
Category = "Testing HTML strings unescaping",
|
||||
Title = "Ensuring HTML strings are being unescaped",
|
||||
MessageHtml = """"This text should appear triple-quoted""" >_<",
|
||||
GithubUser = new APIChangelogUser
|
||||
{
|
||||
DisplayName = "Dummy",
|
||||
OsuUsername = "Dummy",
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,12 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Overlays.Chat.Tabs;
|
||||
@ -25,7 +26,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(ChannelTabControl),
|
||||
};
|
||||
|
||||
private readonly ChannelTabControl channelTabControl;
|
||||
private readonly TestTabControl channelTabControl;
|
||||
|
||||
public TestSceneChannelTabControl()
|
||||
{
|
||||
@ -37,7 +38,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Anchor = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
channelTabControl = new ChannelTabControl
|
||||
channelTabControl = new TestTabControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.Centre,
|
||||
@ -70,35 +71,43 @@ namespace osu.Game.Tests.Visual.Online
|
||||
});
|
||||
|
||||
channelTabControl.OnRequestLeave += channel => channelTabControl.RemoveChannel(channel);
|
||||
channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.NewValue.ToString();
|
||||
channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.NewValue;
|
||||
|
||||
AddStep("Add random private channel", addRandomPrivateChannel);
|
||||
AddAssert("There is only one channels", () => channelTabControl.Items.Count() == 2);
|
||||
AddAssert("There is only one channels", () => channelTabControl.Items.Count == 2);
|
||||
AddRepeatStep("Add 3 random private channels", addRandomPrivateChannel, 3);
|
||||
AddAssert("There are four channels", () => channelTabControl.Items.Count() == 5);
|
||||
AddAssert("There are four channels", () => channelTabControl.Items.Count == 5);
|
||||
AddStep("Add random public channel", () => addChannel(RNG.Next().ToString()));
|
||||
|
||||
AddRepeatStep("Select a random channel", () => channelTabControl.Current.Value = channelTabControl.Items.ElementAt(RNG.Next(channelTabControl.Items.Count() - 1)), 20);
|
||||
AddRepeatStep("Select a random channel", () =>
|
||||
{
|
||||
List<Channel> validChannels = channelTabControl.Items.Where(c => !(c is ChannelSelectorTabItem.ChannelSelectorTabChannel)).ToList();
|
||||
channelTabControl.SelectChannel(validChannels[RNG.Next(0, validChannels.Count)]);
|
||||
}, 20);
|
||||
|
||||
Channel channelBefore = channelTabControl.Items.First();
|
||||
AddStep("set first channel", () => channelTabControl.Current.Value = channelBefore);
|
||||
Channel channelBefore = null;
|
||||
AddStep("set first channel", () => channelTabControl.SelectChannel(channelBefore = channelTabControl.Items.First(c => !(c is ChannelSelectorTabItem.ChannelSelectorTabChannel))));
|
||||
|
||||
AddStep("select selector tab", () => channelTabControl.Current.Value = channelTabControl.Items.Last());
|
||||
AddStep("select selector tab", () => channelTabControl.SelectChannel(channelTabControl.Items.Single(c => c is ChannelSelectorTabItem.ChannelSelectorTabChannel)));
|
||||
AddAssert("selector tab is active", () => channelTabControl.ChannelSelectorActive.Value);
|
||||
|
||||
AddAssert("check channel unchanged", () => channelBefore == channelTabControl.Current.Value);
|
||||
|
||||
AddStep("set second channel", () => channelTabControl.Current.Value = channelTabControl.Items.Skip(1).First());
|
||||
AddStep("set second channel", () => channelTabControl.SelectChannel(channelTabControl.Items.GetNext(channelBefore)));
|
||||
AddAssert("selector tab is inactive", () => !channelTabControl.ChannelSelectorActive.Value);
|
||||
|
||||
AddUntilStep("remove all channels", () =>
|
||||
{
|
||||
var first = channelTabControl.Items.First();
|
||||
if (first is ChannelSelectorTabItem.ChannelSelectorTabChannel)
|
||||
return true;
|
||||
foreach (var item in channelTabControl.Items.ToList())
|
||||
{
|
||||
if (item is ChannelSelectorTabItem.ChannelSelectorTabChannel)
|
||||
continue;
|
||||
|
||||
channelTabControl.RemoveChannel(first);
|
||||
return false;
|
||||
channelTabControl.RemoveChannel(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
AddAssert("selector tab is active", () => channelTabControl.ChannelSelectorActive.Value);
|
||||
@ -117,5 +126,10 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Type = ChannelType.Public,
|
||||
Name = name
|
||||
});
|
||||
|
||||
private class TestTabControl : ChannelTabControl
|
||||
{
|
||||
public void SelectChannel(Channel channel) => base.SelectTab(TabMap[channel]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
108
osu.Game.Tests/Visual/Online/TestSceneChatLineTruncation.cs
Normal file
108
osu.Game.Tests/Visual/Online/TestSceneChatLineTruncation.cs
Normal file
@ -0,0 +1,108 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Overlays.Chat;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneChatLineTruncation : OsuTestScene
|
||||
{
|
||||
private readonly TestChatLineContainer textContainer;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ChatLine),
|
||||
typeof(Message),
|
||||
typeof(LinkFlowContainer),
|
||||
typeof(MessageFormatter)
|
||||
};
|
||||
|
||||
public TestSceneChatLineTruncation()
|
||||
{
|
||||
Add(textContainer = new TestChatLineContainer
|
||||
{
|
||||
Padding = new MarginPadding { Left = 20, Right = 20 },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
testFormatting();
|
||||
}
|
||||
|
||||
private void clear() => AddStep("clear messages", textContainer.Clear);
|
||||
|
||||
private void addMessageWithChecks(string text, bool isAction = false, bool isImportant = false, string username = null)
|
||||
{
|
||||
int index = textContainer.Count + 1;
|
||||
var newLine = new ChatLine(new DummyMessage(text, isAction, isImportant, index, username));
|
||||
textContainer.Add(newLine);
|
||||
}
|
||||
|
||||
private void testFormatting()
|
||||
{
|
||||
for (int a = 0; a < 25; a++)
|
||||
addMessageWithChecks($"Wide {a} character username.", username: new string('w', a));
|
||||
addMessageWithChecks("Short name with spaces.", username: "sho rt name");
|
||||
addMessageWithChecks("Long name with spaces.", username: "long name with s p a c e s");
|
||||
}
|
||||
|
||||
private class DummyMessage : Message
|
||||
{
|
||||
private static long messageCounter;
|
||||
|
||||
internal static readonly User TEST_SENDER_BACKGROUND = new User
|
||||
{
|
||||
Username = @"i-am-important",
|
||||
Id = 42,
|
||||
Colour = "#250cc9",
|
||||
};
|
||||
|
||||
internal static readonly User TEST_SENDER = new User
|
||||
{
|
||||
Username = @"Somebody",
|
||||
Id = 1,
|
||||
};
|
||||
|
||||
public new DateTimeOffset Timestamp = DateTimeOffset.Now;
|
||||
|
||||
public DummyMessage(string text, bool isAction = false, bool isImportant = false, int number = 0, string username = null)
|
||||
: base(messageCounter++)
|
||||
{
|
||||
Content = text;
|
||||
IsAction = isAction;
|
||||
Sender = new User
|
||||
{
|
||||
Username = username ?? $"user {number}",
|
||||
Id = number,
|
||||
Colour = isImportant ? "#250cc9" : null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private class TestChatLineContainer : FillFlowContainer<ChatLine>
|
||||
{
|
||||
protected override int Compare(Drawable x, Drawable y)
|
||||
{
|
||||
var xC = (ChatLine)x;
|
||||
var yC = (ChatLine)y;
|
||||
|
||||
return xC.Message.CompareTo(yC.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -127,6 +127,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
addMessageWithChecks("is now playing [https://osu.ppy.sh/b/252238 IMAGE -MATERIAL- <Version 0>]", 1, true, expectedActions: LinkAction.OpenBeatmap);
|
||||
addMessageWithChecks("Let's (try)[https://osu.ppy.sh/home] [https://osu.ppy.sh/b/252238 multiple links] https://osu.ppy.sh/home", 3,
|
||||
expectedActions: new[] { LinkAction.External, LinkAction.OpenBeatmap, LinkAction.External });
|
||||
addMessageWithChecks("[https://osu.ppy.sh/home New link format with escaped [and \\[ paired] braces]", 1, expectedActions: LinkAction.External);
|
||||
addMessageWithChecks("[Markdown link format with escaped [and \\[ paired] braces](https://osu.ppy.sh/home)", 1, expectedActions: LinkAction.External);
|
||||
addMessageWithChecks("(Old link format with escaped (and \\( paired) parentheses)[https://osu.ppy.sh/home] and [[also a rogue wiki link]]", 2, expectedActions: new[] { LinkAction.External, LinkAction.External });
|
||||
// note that there's 0 links here (they get removed if a channel is not found)
|
||||
addMessageWithChecks("#lobby or #osu would be blue (and work) in the ChatDisplay test (when a proper ChatOverlay is present).");
|
||||
addMessageWithChecks("I am important!", 0, false, true);
|
||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
private TestChatOverlay chatOverlay;
|
||||
private ChannelManager channelManager;
|
||||
|
||||
private readonly Channel channel1 = new Channel(new User()) { Name = "test1" };
|
||||
private readonly Channel channel1 = new Channel(new User()) { Name = "test really long username" };
|
||||
private readonly Channel channel2 = new Channel(new User()) { Name = "test2" };
|
||||
|
||||
[SetUp]
|
||||
|
53
osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
Normal file
53
osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs
Normal file
@ -0,0 +1,53 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Comments;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneCommentsContainer : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(CommentsContainer),
|
||||
typeof(CommentsHeader),
|
||||
typeof(DrawableComment),
|
||||
typeof(HeaderButton),
|
||||
typeof(SortTabControl),
|
||||
typeof(ShowChildrenButton),
|
||||
typeof(DeletedChildrenPlaceholder),
|
||||
typeof(VotePill)
|
||||
};
|
||||
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public TestSceneCommentsContainer()
|
||||
{
|
||||
BasicScrollContainer scroll;
|
||||
CommentsContainer comments;
|
||||
|
||||
Add(scroll = new BasicScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = comments = new CommentsContainer()
|
||||
});
|
||||
|
||||
AddStep("Big Black comments", () => comments.ShowComments(CommentableType.Beatmapset, 41823));
|
||||
AddStep("Airman comments", () => comments.ShowComments(CommentableType.Beatmapset, 24313));
|
||||
AddStep("Lazer build comments", () => comments.ShowComments(CommentableType.Build, 4772));
|
||||
AddStep("News comments", () => comments.ShowComments(CommentableType.NewsPost, 715));
|
||||
AddStep("Idle state", () =>
|
||||
{
|
||||
scroll.Clear();
|
||||
scroll.Add(comments = new CommentsContainer());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
39
osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs
Normal file
39
osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs
Normal file
@ -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;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Overlays.Comments;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneCommentsHeader : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(CommentsHeader),
|
||||
typeof(HeaderButton),
|
||||
typeof(SortTabControl),
|
||||
};
|
||||
|
||||
private readonly Bindable<CommentsSortCriteria> sort = new Bindable<CommentsSortCriteria>();
|
||||
private readonly BindableBool showDeleted = new BindableBool();
|
||||
|
||||
public TestSceneCommentsHeader()
|
||||
{
|
||||
Add(new CommentsHeader
|
||||
{
|
||||
Sort = { BindTarget = sort },
|
||||
ShowDeleted = { BindTarget = showDeleted }
|
||||
});
|
||||
|
||||
AddStep("Trigger ShowDeleted", () => showDeleted.Value = !showDeleted.Value);
|
||||
AddStep("Select old", () => sort.Value = CommentsSortCriteria.Old);
|
||||
AddStep("Select new", () => sort.Value = CommentsSortCriteria.New);
|
||||
AddStep("Select top", () => sort.Value = CommentsSortCriteria.Top);
|
||||
}
|
||||
}
|
||||
}
|
@ -13,6 +13,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
private DirectOverlay direct;
|
||||
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
@ -9,7 +9,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays.Direct;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
@ -24,7 +23,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(IconPill)
|
||||
};
|
||||
|
||||
private BeatmapSetInfo getUndownloadableBeatmapSet(RulesetInfo ruleset) => new BeatmapSetInfo
|
||||
private BeatmapSetInfo getUndownloadableBeatmapSet() => new BeatmapSetInfo
|
||||
{
|
||||
OnlineBeatmapSetID = 123,
|
||||
Metadata = new BeatmapMetadata
|
||||
@ -56,23 +55,62 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
new BeatmapInfo
|
||||
{
|
||||
Ruleset = ruleset,
|
||||
Ruleset = Ruleset.Value,
|
||||
Version = "Test",
|
||||
StarDifficulty = 6.42,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private BeatmapSetInfo getManyDifficultiesBeatmapSet(RulesetStore rulesets)
|
||||
{
|
||||
var ruleset = new OsuRuleset().RulesetInfo;
|
||||
var beatmaps = new List<BeatmapInfo>();
|
||||
|
||||
var normal = CreateWorkingBeatmap(ruleset).BeatmapSetInfo;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
beatmaps.Add(new BeatmapInfo
|
||||
{
|
||||
Ruleset = rulesets.GetRuleset(i % 4),
|
||||
StarDifficulty = 2 + i % 4 * 2,
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
OverallDifficulty = 3.5f,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return new BeatmapSetInfo
|
||||
{
|
||||
OnlineBeatmapSetID = 1,
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = "many difficulties beatmap",
|
||||
Artist = "test",
|
||||
Author = new User
|
||||
{
|
||||
Username = "BanchoBot",
|
||||
Id = 3,
|
||||
}
|
||||
},
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
{
|
||||
HasVideo = true,
|
||||
HasStoryboard = true,
|
||||
Covers = new BeatmapSetOnlineCovers(),
|
||||
},
|
||||
Beatmaps = beatmaps,
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets)
|
||||
{
|
||||
var normal = CreateWorkingBeatmap(Ruleset.Value).BeatmapSetInfo;
|
||||
normal.OnlineInfo.HasVideo = true;
|
||||
normal.OnlineInfo.HasStoryboard = true;
|
||||
|
||||
var undownloadable = getUndownloadableBeatmapSet(ruleset);
|
||||
var undownloadable = getUndownloadableBeatmapSet();
|
||||
var manyDifficulties = getManyDifficultiesBeatmapSet(rulesets);
|
||||
|
||||
Child = new BasicScrollContainer
|
||||
{
|
||||
@ -81,15 +119,17 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Direction = FillDirection.Full,
|
||||
Padding = new MarginPadding(20),
|
||||
Spacing = new Vector2(0, 20),
|
||||
Spacing = new Vector2(5, 20),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DirectGridPanel(normal),
|
||||
new DirectListPanel(normal),
|
||||
new DirectGridPanel(undownloadable),
|
||||
new DirectGridPanel(manyDifficulties),
|
||||
new DirectListPanel(normal),
|
||||
new DirectListPanel(undownloadable),
|
||||
new DirectListPanel(manyDifficulties),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
54
osu.Game.Tests/Visual/Online/TestSceneFavouriteButton.cs
Normal file
54
osu.Game.Tests/Visual/Online/TestSceneFavouriteButton.cs
Normal file
@ -0,0 +1,54 @@
|
||||
// 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.Beatmaps;
|
||||
using osu.Game.Overlays.BeatmapSet.Buttons;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneFavouriteButton : OsuTestScene
|
||||
{
|
||||
private FavouriteButton favourite;
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("create button", () => Child = favourite = new FavouriteButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Size = new Vector2(50),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLoggedOutIn()
|
||||
{
|
||||
AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new BeatmapSetInfo { OnlineBeatmapSetID = 88 });
|
||||
AddStep("log out", () => API.Logout());
|
||||
checkEnabled(false);
|
||||
AddStep("log in", () => API.Login("test", "test"));
|
||||
checkEnabled(true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBeatmapChange()
|
||||
{
|
||||
AddStep("log in", () => API.Login("test", "test"));
|
||||
AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new BeatmapSetInfo { OnlineBeatmapSetID = 88 });
|
||||
checkEnabled(true);
|
||||
AddStep("set invalid beatmap", () => favourite.BeatmapSet.Value = new BeatmapSetInfo());
|
||||
checkEnabled(false);
|
||||
}
|
||||
|
||||
private void checkEnabled(bool expected)
|
||||
{
|
||||
AddAssert("is " + (expected ? "enabled" : "disabled"), () => favourite.Enabled.Value == expected);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,14 +17,15 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[TestFixture]
|
||||
public class TestSceneHistoricalSection : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes =>
|
||||
new[]
|
||||
{
|
||||
typeof(HistoricalSection),
|
||||
typeof(PaginatedMostPlayedBeatmapContainer),
|
||||
typeof(DrawableMostPlayedRow),
|
||||
typeof(DrawableProfileRow)
|
||||
};
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(HistoricalSection),
|
||||
typeof(PaginatedMostPlayedBeatmapContainer),
|
||||
typeof(DrawableMostPlayedBeatmap),
|
||||
typeof(DrawableProfileRow)
|
||||
};
|
||||
|
||||
public TestSceneHistoricalSection()
|
||||
{
|
||||
|
246
osu.Game.Tests/Visual/Online/TestSceneKudosuHistory.cs
Normal file
246
osu.Game.Tests/Visual/Online/TestSceneKudosuHistory.cs
Normal file
@ -0,0 +1,246 @@
|
||||
// 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.Game.Overlays.Profile.Sections.Kudosu;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneKudosuHistory : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(DrawableKudosuHistoryItem),
|
||||
};
|
||||
|
||||
private readonly Box background;
|
||||
|
||||
public TestSceneKudosuHistory()
|
||||
{
|
||||
FillFlowContainer<DrawableKudosuHistoryItem> content;
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
content = new FillFlowContainer<DrawableKudosuHistoryItem>
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.7f,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
}
|
||||
});
|
||||
|
||||
items.ForEach(t => content.Add(new DrawableKudosuHistoryItem(t)));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
background.Colour = colours.GreySeafoam;
|
||||
}
|
||||
|
||||
private readonly IEnumerable<APIKudosuHistory> items = new[]
|
||||
{
|
||||
new APIKudosuHistory
|
||||
{
|
||||
Amount = 10,
|
||||
CreatedAt = new DateTimeOffset(new DateTime(2011, 11, 11)),
|
||||
Source = KudosuSource.DenyKudosu,
|
||||
Action = KudosuAction.Reset,
|
||||
Post = new APIKudosuHistory.ModdingPost
|
||||
{
|
||||
Title = @"Random post 1",
|
||||
Url = @"https://osu.ppy.sh/b/1234",
|
||||
},
|
||||
Giver = new APIKudosuHistory.KudosuGiver
|
||||
{
|
||||
Username = @"Username1",
|
||||
Url = @"https://osu.ppy.sh/u/1234"
|
||||
}
|
||||
},
|
||||
new APIKudosuHistory
|
||||
{
|
||||
Amount = 5,
|
||||
CreatedAt = new DateTimeOffset(new DateTime(2012, 10, 11)),
|
||||
Source = KudosuSource.Forum,
|
||||
Action = KudosuAction.Give,
|
||||
Post = new APIKudosuHistory.ModdingPost
|
||||
{
|
||||
Title = @"Random post 2",
|
||||
Url = @"https://osu.ppy.sh/b/1234",
|
||||
},
|
||||
Giver = new APIKudosuHistory.KudosuGiver
|
||||
{
|
||||
Username = @"Username2",
|
||||
Url = @"https://osu.ppy.sh/u/1234"
|
||||
}
|
||||
},
|
||||
new APIKudosuHistory
|
||||
{
|
||||
Amount = 8,
|
||||
CreatedAt = new DateTimeOffset(new DateTime(2013, 9, 11)),
|
||||
Source = KudosuSource.Forum,
|
||||
Action = KudosuAction.Reset,
|
||||
Post = new APIKudosuHistory.ModdingPost
|
||||
{
|
||||
Title = @"Random post 3",
|
||||
Url = @"https://osu.ppy.sh/b/1234",
|
||||
},
|
||||
Giver = new APIKudosuHistory.KudosuGiver
|
||||
{
|
||||
Username = @"Username3",
|
||||
Url = @"https://osu.ppy.sh/u/1234"
|
||||
}
|
||||
},
|
||||
new APIKudosuHistory
|
||||
{
|
||||
Amount = 7,
|
||||
CreatedAt = new DateTimeOffset(new DateTime(2014, 8, 11)),
|
||||
Source = KudosuSource.Forum,
|
||||
Action = KudosuAction.Revoke,
|
||||
Post = new APIKudosuHistory.ModdingPost
|
||||
{
|
||||
Title = @"Random post 4",
|
||||
Url = @"https://osu.ppy.sh/b/1234",
|
||||
},
|
||||
Giver = new APIKudosuHistory.KudosuGiver
|
||||
{
|
||||
Username = @"Username4",
|
||||
Url = @"https://osu.ppy.sh/u/1234"
|
||||
}
|
||||
},
|
||||
new APIKudosuHistory
|
||||
{
|
||||
Amount = 100,
|
||||
CreatedAt = new DateTimeOffset(new DateTime(2015, 7, 11)),
|
||||
Source = KudosuSource.Vote,
|
||||
Action = KudosuAction.Give,
|
||||
Post = new APIKudosuHistory.ModdingPost
|
||||
{
|
||||
Title = @"Random post 5",
|
||||
Url = @"https://osu.ppy.sh/b/1234",
|
||||
},
|
||||
Giver = new APIKudosuHistory.KudosuGiver
|
||||
{
|
||||
Username = @"Username5",
|
||||
Url = @"https://osu.ppy.sh/u/1234"
|
||||
}
|
||||
},
|
||||
new APIKudosuHistory
|
||||
{
|
||||
Amount = 20,
|
||||
CreatedAt = new DateTimeOffset(new DateTime(2016, 6, 11)),
|
||||
Source = KudosuSource.Vote,
|
||||
Action = KudosuAction.Reset,
|
||||
Post = new APIKudosuHistory.ModdingPost
|
||||
{
|
||||
Title = @"Random post 6",
|
||||
Url = @"https://osu.ppy.sh/b/1234",
|
||||
},
|
||||
Giver = new APIKudosuHistory.KudosuGiver
|
||||
{
|
||||
Username = @"Username6",
|
||||
Url = @"https://osu.ppy.sh/u/1234"
|
||||
}
|
||||
},
|
||||
new APIKudosuHistory
|
||||
{
|
||||
Amount = 11,
|
||||
CreatedAt = new DateTimeOffset(new DateTime(2016, 6, 11)),
|
||||
Source = KudosuSource.AllowKudosu,
|
||||
Action = KudosuAction.Give,
|
||||
Post = new APIKudosuHistory.ModdingPost
|
||||
{
|
||||
Title = @"Random post 7",
|
||||
Url = @"https://osu.ppy.sh/b/1234",
|
||||
},
|
||||
Giver = new APIKudosuHistory.KudosuGiver
|
||||
{
|
||||
Username = @"Username7",
|
||||
Url = @"https://osu.ppy.sh/u/1234"
|
||||
}
|
||||
},
|
||||
new APIKudosuHistory
|
||||
{
|
||||
Amount = 24,
|
||||
CreatedAt = new DateTimeOffset(new DateTime(2014, 6, 11)),
|
||||
Source = KudosuSource.Delete,
|
||||
Action = KudosuAction.Reset,
|
||||
Post = new APIKudosuHistory.ModdingPost
|
||||
{
|
||||
Title = @"Random post 8",
|
||||
Url = @"https://osu.ppy.sh/b/1234",
|
||||
},
|
||||
Giver = new APIKudosuHistory.KudosuGiver
|
||||
{
|
||||
Username = @"Username8",
|
||||
Url = @"https://osu.ppy.sh/u/1234"
|
||||
}
|
||||
},
|
||||
new APIKudosuHistory
|
||||
{
|
||||
Amount = 12,
|
||||
CreatedAt = new DateTimeOffset(new DateTime(2016, 6, 11)),
|
||||
Source = KudosuSource.Restore,
|
||||
Action = KudosuAction.Give,
|
||||
Post = new APIKudosuHistory.ModdingPost
|
||||
{
|
||||
Title = @"Random post 9",
|
||||
Url = @"https://osu.ppy.sh/b/1234",
|
||||
},
|
||||
Giver = new APIKudosuHistory.KudosuGiver
|
||||
{
|
||||
Username = @"Username9",
|
||||
Url = @"https://osu.ppy.sh/u/1234"
|
||||
}
|
||||
},
|
||||
new APIKudosuHistory
|
||||
{
|
||||
Amount = 2,
|
||||
CreatedAt = new DateTimeOffset(new DateTime(2012, 6, 11)),
|
||||
Source = KudosuSource.Recalculate,
|
||||
Action = KudosuAction.Give,
|
||||
Post = new APIKudosuHistory.ModdingPost
|
||||
{
|
||||
Title = @"Random post 10",
|
||||
Url = @"https://osu.ppy.sh/b/1234",
|
||||
},
|
||||
Giver = new APIKudosuHistory.KudosuGiver
|
||||
{
|
||||
Username = @"Username10",
|
||||
Url = @"https://osu.ppy.sh/u/1234"
|
||||
}
|
||||
},
|
||||
new APIKudosuHistory
|
||||
{
|
||||
Amount = 32,
|
||||
CreatedAt = new DateTimeOffset(new DateTime(2019, 8, 11)),
|
||||
Source = KudosuSource.Recalculate,
|
||||
Action = KudosuAction.Reset,
|
||||
Post = new APIKudosuHistory.ModdingPost
|
||||
{
|
||||
Title = @"Random post 11",
|
||||
Url = @"https://osu.ppy.sh/b/1234",
|
||||
},
|
||||
Giver = new APIKudosuHistory.KudosuGiver
|
||||
{
|
||||
Username = @"Username11",
|
||||
Url = @"https://osu.ppy.sh/u/1234"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
// 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.Game.Overlays.BeatmapSet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneLeaderboardModSelector : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(LeaderboardModSelector),
|
||||
};
|
||||
|
||||
public TestSceneLeaderboardModSelector()
|
||||
{
|
||||
LeaderboardModSelector modSelector;
|
||||
FillFlowContainer<SpriteText> selectedMods;
|
||||
var ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
Add(selectedMods = new FillFlowContainer<SpriteText>
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
});
|
||||
|
||||
Add(modSelector = new LeaderboardModSelector
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Ruleset = { BindTarget = ruleset }
|
||||
});
|
||||
|
||||
modSelector.SelectedMods.ItemsAdded += mods =>
|
||||
{
|
||||
mods.ForEach(mod => selectedMods.Add(new OsuSpriteText
|
||||
{
|
||||
Text = mod.Acronym,
|
||||
}));
|
||||
};
|
||||
|
||||
modSelector.SelectedMods.ItemsRemoved += mods =>
|
||||
{
|
||||
mods.ForEach(mod =>
|
||||
{
|
||||
foreach (var selected in selectedMods)
|
||||
{
|
||||
if (selected.Text == mod.Acronym)
|
||||
{
|
||||
selectedMods.Remove(selected);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
AddStep("osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo);
|
||||
AddStep("mania ruleset", () => ruleset.Value = new ManiaRuleset().RulesetInfo);
|
||||
AddStep("taiko ruleset", () => ruleset.Value = new TaikoRuleset().RulesetInfo);
|
||||
AddStep("catch ruleset", () => ruleset.Value = new CatchRuleset().RulesetInfo);
|
||||
AddStep("Deselect all", () => modSelector.DeselectAll());
|
||||
AddStep("null ruleset", () => ruleset.Value = null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
// 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.Game.Overlays.BeatmapSet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneLeaderboardScopeSelector : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(LeaderboardScopeSelector),
|
||||
};
|
||||
|
||||
public TestSceneLeaderboardScopeSelector()
|
||||
{
|
||||
Bindable<BeatmapLeaderboardScope> scope = new Bindable<BeatmapLeaderboardScope>();
|
||||
|
||||
Add(new LeaderboardScopeSelector
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Current = { BindTarget = scope }
|
||||
});
|
||||
|
||||
AddStep(@"Select global", () => scope.Value = BeatmapLeaderboardScope.Global);
|
||||
AddStep(@"Select country", () => scope.Value = BeatmapLeaderboardScope.Country);
|
||||
AddStep(@"Select friend", () => scope.Value = BeatmapLeaderboardScope.Friend);
|
||||
}
|
||||
}
|
||||
}
|
66
osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
Normal file
66
osu.Game.Tests/Visual/Online/TestSceneNewsOverlay.cs
Normal file
@ -0,0 +1,66 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.News;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneNewsOverlay : OsuTestScene
|
||||
{
|
||||
private TestNewsOverlay news;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Add(news = new TestNewsOverlay());
|
||||
AddStep(@"Show", news.Show);
|
||||
AddStep(@"Hide", news.Hide);
|
||||
|
||||
AddStep(@"Show front page", () => news.ShowFrontPage());
|
||||
AddStep(@"Custom article", () => news.Current.Value = "Test Article 101");
|
||||
|
||||
AddStep(@"Article covers", () => news.LoadAndShowContent(new NewsCoverTest()));
|
||||
}
|
||||
|
||||
private class TestNewsOverlay : NewsOverlay
|
||||
{
|
||||
public new void LoadAndShowContent(NewsContent content) => base.LoadAndShowContent(content);
|
||||
}
|
||||
|
||||
private class NewsCoverTest : NewsContent
|
||||
{
|
||||
public NewsCoverTest()
|
||||
{
|
||||
Spacing = new osuTK.Vector2(0, 10);
|
||||
|
||||
var article = new NewsArticleCover.ArticleInfo
|
||||
{
|
||||
Author = "Ephemeral",
|
||||
CoverUrl = "https://assets.ppy.sh/artists/58/header.jpg",
|
||||
Time = new DateTime(2019, 12, 4),
|
||||
Title = "New Featured Artist: Kurokotei"
|
||||
};
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new NewsArticleCover(article)
|
||||
{
|
||||
Height = 200
|
||||
},
|
||||
new NewsArticleCover(article)
|
||||
{
|
||||
Height = 120
|
||||
},
|
||||
new NewsArticleCover(article)
|
||||
{
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Size = new osuTK.Vector2(400, 200),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
42
osu.Game.Tests/Visual/Online/TestSceneProfileCounterPill.cs
Normal file
42
osu.Game.Tests/Visual/Online/TestSceneProfileCounterPill.cs
Normal file
@ -0,0 +1,42 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Profile.Sections;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneProfileCounterPill : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(CounterPill)
|
||||
};
|
||||
|
||||
private readonly CounterPill pill;
|
||||
private readonly BindableInt value = new BindableInt();
|
||||
|
||||
public TestSceneProfileCounterPill()
|
||||
{
|
||||
Child = pill = new CounterPill
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Current = { BindTarget = value }
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVisibility()
|
||||
{
|
||||
AddStep("Set value to 0", () => value.Value = 0);
|
||||
AddAssert("Check hidden", () => !pill.IsPresent);
|
||||
AddStep("Set value to 10", () => value.Value = 10);
|
||||
AddAssert("Check visible", () => pill.IsPresent);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,8 @@ using osu.Game.Rulesets.Catch;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Users;
|
||||
using osu.Framework.Bindables;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
@ -23,18 +25,25 @@ namespace osu.Game.Tests.Visual.Online
|
||||
public TestSceneProfileRulesetSelector()
|
||||
{
|
||||
ProfileRulesetSelector selector;
|
||||
Bindable<User> user = new Bindable<User>();
|
||||
|
||||
Child = selector = new ProfileRulesetSelector
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
User = { BindTarget = user }
|
||||
};
|
||||
|
||||
AddStep("set osu! as default", () => selector.SetDefaultRuleset(new OsuRuleset().RulesetInfo));
|
||||
AddStep("set mania as default", () => selector.SetDefaultRuleset(new ManiaRuleset().RulesetInfo));
|
||||
AddStep("set taiko as default", () => selector.SetDefaultRuleset(new TaikoRuleset().RulesetInfo));
|
||||
AddStep("set catch as default", () => selector.SetDefaultRuleset(new CatchRuleset().RulesetInfo));
|
||||
AddStep("select default ruleset", selector.SelectDefaultRuleset);
|
||||
|
||||
AddStep("User with osu as default", () => user.Value = new User { PlayMode = "osu" });
|
||||
AddStep("User with mania as default", () => user.Value = new User { PlayMode = "mania" });
|
||||
AddStep("User with taiko as default", () => user.Value = new User { PlayMode = "taiko" });
|
||||
AddStep("User with catch as default", () => user.Value = new User { PlayMode = "fruits" });
|
||||
AddStep("null user", () => user.Value = null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,28 +69,22 @@ namespace osu.Game.Tests.Visual.Online
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("null user", () => graph.User.Value = null);
|
||||
AddStep("null user", () => graph.Statistics.Value = null);
|
||||
AddStep("rank only", () =>
|
||||
{
|
||||
graph.User.Value = new User
|
||||
graph.Statistics.Value = new UserStatistics
|
||||
{
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
Ranks = new UserStatistics.UserRanks { Global = 123456 },
|
||||
PP = 12345,
|
||||
}
|
||||
Ranks = new UserStatistics.UserRanks { Global = 123456 },
|
||||
PP = 12345,
|
||||
};
|
||||
});
|
||||
|
||||
AddStep("with rank history", () =>
|
||||
{
|
||||
graph.User.Value = new User
|
||||
graph.Statistics.Value = new UserStatistics
|
||||
{
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
Ranks = new UserStatistics.UserRanks { Global = 89000 },
|
||||
PP = 12345,
|
||||
},
|
||||
Ranks = new UserStatistics.UserRanks { Global = 89000 },
|
||||
PP = 12345,
|
||||
RankHistory = new User.RankHistoryData
|
||||
{
|
||||
Data = data,
|
||||
@ -100,13 +94,10 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
AddStep("with zero values", () =>
|
||||
{
|
||||
graph.User.Value = new User
|
||||
graph.Statistics.Value = new UserStatistics
|
||||
{
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
Ranks = new UserStatistics.UserRanks { Global = 89000 },
|
||||
PP = 12345,
|
||||
},
|
||||
Ranks = new UserStatistics.UserRanks { Global = 89000 },
|
||||
PP = 12345,
|
||||
RankHistory = new User.RankHistoryData
|
||||
{
|
||||
Data = dataWithZeros,
|
||||
@ -116,13 +107,10 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
AddStep("small amount of data", () =>
|
||||
{
|
||||
graph.User.Value = new User
|
||||
graph.Statistics.Value = new UserStatistics
|
||||
{
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
Ranks = new UserStatistics.UserRanks { Global = 12000 },
|
||||
PP = 12345,
|
||||
},
|
||||
Ranks = new UserStatistics.UserRanks { Global = 12000 },
|
||||
PP = 12345,
|
||||
RankHistory = new User.RankHistoryData
|
||||
{
|
||||
Data = smallData,
|
||||
@ -132,13 +120,10 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
AddStep("graph with edges", () =>
|
||||
{
|
||||
graph.User.Value = new User
|
||||
graph.Statistics.Value = new UserStatistics
|
||||
{
|
||||
Statistics = new UserStatistics
|
||||
{
|
||||
Ranks = new UserStatistics.UserRanks { Global = 12000 },
|
||||
PP = 12345,
|
||||
},
|
||||
Ranks = new UserStatistics.UserRanks { Global = 12000 },
|
||||
PP = 12345,
|
||||
RankHistory = new User.RankHistoryData
|
||||
{
|
||||
Data = edgyData,
|
||||
|
@ -0,0 +1,76 @@
|
||||
// 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 osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays.Rankings;
|
||||
using osu.Game.Users;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osuTK.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneRankingsCountryFilter : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(CountryFilter),
|
||||
typeof(CountryPill)
|
||||
};
|
||||
|
||||
public TestSceneRankingsCountryFilter()
|
||||
{
|
||||
var countryBindable = new Bindable<Country>();
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Gray,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new CountryFilter
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Current = { BindTarget = countryBindable }
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = "Some content",
|
||||
Margin = new MarginPadding { Vertical = 20 }
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var country = new Country
|
||||
{
|
||||
FlagName = "BY",
|
||||
FullName = "Belarus"
|
||||
};
|
||||
var unknownCountry = new Country
|
||||
{
|
||||
FlagName = "CK",
|
||||
FullName = "Cook Islands"
|
||||
};
|
||||
|
||||
AddStep("Set country", () => countryBindable.Value = country);
|
||||
AddStep("Set null country", () => countryBindable.Value = null);
|
||||
AddStep("Set country with no flag", () => countryBindable.Value = unknownCountry);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays.Rankings;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneRankingsDismissableFlag : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(DismissableFlag),
|
||||
};
|
||||
|
||||
public TestSceneRankingsDismissableFlag()
|
||||
{
|
||||
DismissableFlag flag;
|
||||
SpriteText text;
|
||||
|
||||
var countryA = new Country
|
||||
{
|
||||
FlagName = "BY",
|
||||
FullName = "Belarus"
|
||||
};
|
||||
|
||||
var countryB = new Country
|
||||
{
|
||||
FlagName = "US",
|
||||
FullName = "United States"
|
||||
};
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
flag = new DismissableFlag
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(30, 20),
|
||||
Country = countryA,
|
||||
},
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = "Invoked",
|
||||
Font = OsuFont.GetFont(size: 30),
|
||||
Alpha = 0,
|
||||
}
|
||||
});
|
||||
|
||||
flag.Action += () => text.FadeIn().Then().FadeOut(1000, Easing.OutQuint);
|
||||
|
||||
AddStep("Trigger click", () => flag.Click());
|
||||
AddStep("Change to country 2", () => flag.Country = countryB);
|
||||
AddStep("Change to country 1", () => flag.Country = countryA);
|
||||
}
|
||||
}
|
||||
}
|
75
osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs
Normal file
75
osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs
Normal file
@ -0,0 +1,75 @@
|
||||
// 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 osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Rankings;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneRankingsHeader : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(DismissableFlag),
|
||||
typeof(HeaderTitle),
|
||||
typeof(RankingsRulesetSelector),
|
||||
typeof(RankingsScopeSelector),
|
||||
typeof(RankingsHeader),
|
||||
};
|
||||
|
||||
public TestSceneRankingsHeader()
|
||||
{
|
||||
var countryBindable = new Bindable<Country>();
|
||||
var ruleset = new Bindable<RulesetInfo>();
|
||||
var scope = new Bindable<RankingsScope>();
|
||||
|
||||
Add(new RankingsHeader
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Scope = { BindTarget = scope },
|
||||
Country = { BindTarget = countryBindable },
|
||||
Ruleset = { BindTarget = ruleset },
|
||||
Spotlights = new[]
|
||||
{
|
||||
new Spotlight
|
||||
{
|
||||
Id = 1,
|
||||
Text = "Spotlight 1"
|
||||
},
|
||||
new Spotlight
|
||||
{
|
||||
Id = 2,
|
||||
Text = "Spotlight 2"
|
||||
},
|
||||
new Spotlight
|
||||
{
|
||||
Id = 3,
|
||||
Text = "Spotlight 3"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var country = new Country
|
||||
{
|
||||
FlagName = "BY",
|
||||
FullName = "Belarus"
|
||||
};
|
||||
|
||||
var unknownCountry = new Country
|
||||
{
|
||||
FlagName = "CK",
|
||||
FullName = "Cook Islands"
|
||||
};
|
||||
|
||||
AddStep("Set country", () => countryBindable.Value = country);
|
||||
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
|
||||
AddStep("Set country with no flag", () => countryBindable.Value = unknownCountry);
|
||||
}
|
||||
}
|
||||
}
|
55
osu.Game.Tests/Visual/Online/TestSceneRankingsHeaderTitle.cs
Normal file
55
osu.Game.Tests/Visual/Online/TestSceneRankingsHeaderTitle.cs
Normal file
@ -0,0 +1,55 @@
|
||||
// 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 osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Rankings;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneRankingsHeaderTitle : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(DismissableFlag),
|
||||
typeof(HeaderTitle),
|
||||
};
|
||||
|
||||
public TestSceneRankingsHeaderTitle()
|
||||
{
|
||||
var countryBindable = new Bindable<Country>();
|
||||
var scope = new Bindable<RankingsScope>();
|
||||
|
||||
Add(new HeaderTitle
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Country = { BindTarget = countryBindable },
|
||||
Scope = { BindTarget = scope },
|
||||
});
|
||||
|
||||
var countryA = new Country
|
||||
{
|
||||
FlagName = "BY",
|
||||
FullName = "Belarus"
|
||||
};
|
||||
|
||||
var countryB = new Country
|
||||
{
|
||||
FlagName = "US",
|
||||
FullName = "United States"
|
||||
};
|
||||
|
||||
AddStep("Set country 1", () => countryBindable.Value = countryA);
|
||||
AddStep("Set country 2", () => countryBindable.Value = countryB);
|
||||
AddStep("Set null country", () => countryBindable.Value = null);
|
||||
AddStep("Set scope to Performance", () => scope.Value = RankingsScope.Performance);
|
||||
AddStep("Set scope to Spotlights", () => scope.Value = RankingsScope.Spotlights);
|
||||
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
|
||||
AddStep("Set scope to Country", () => scope.Value = RankingsScope.Country);
|
||||
}
|
||||
}
|
||||
}
|
86
osu.Game.Tests/Visual/Online/TestSceneRankingsOverlay.cs
Normal file
86
osu.Game.Tests/Visual/Online/TestSceneRankingsOverlay.cs
Normal file
@ -0,0 +1,86 @@
|
||||
// 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 osu.Game.Overlays.Rankings.Tables;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Overlays;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Users;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Overlays.Rankings;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneRankingsOverlay : OsuTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(PerformanceTable),
|
||||
typeof(ScoresTable),
|
||||
typeof(CountriesTable),
|
||||
typeof(TableRowBackground),
|
||||
typeof(UserBasedTable),
|
||||
typeof(RankingsTable<>),
|
||||
typeof(RankingsOverlay)
|
||||
};
|
||||
|
||||
[Cached]
|
||||
private RankingsOverlay rankingsOverlay;
|
||||
|
||||
private readonly Bindable<Country> countryBindable = new Bindable<Country>();
|
||||
private readonly Bindable<RankingsScope> scope = new Bindable<RankingsScope>();
|
||||
|
||||
public TestSceneRankingsOverlay()
|
||||
{
|
||||
Add(rankingsOverlay = new TestRankingsOverlay
|
||||
{
|
||||
Country = { BindTarget = countryBindable },
|
||||
Scope = { BindTarget = scope },
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShow()
|
||||
{
|
||||
AddStep("Show", rankingsOverlay.Show);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFlagScopeDependency()
|
||||
{
|
||||
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
|
||||
AddAssert("Check country is Null", () => countryBindable.Value == null);
|
||||
AddStep("Set country", () => countryBindable.Value = us_country);
|
||||
AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestShowCountry()
|
||||
{
|
||||
AddStep("Show US", () => rankingsOverlay.ShowCountry(us_country));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHide()
|
||||
{
|
||||
AddStep("Hide", rankingsOverlay.Hide);
|
||||
}
|
||||
|
||||
private static readonly Country us_country = new Country
|
||||
{
|
||||
FlagName = "US",
|
||||
FullName = "United States"
|
||||
};
|
||||
|
||||
private class TestRankingsOverlay : RankingsOverlay
|
||||
{
|
||||
public new Bindable<Country> Country => base.Country;
|
||||
|
||||
public new Bindable<RankingsScope> Scope => base.Scope;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
// 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 osu.Game.Overlays.Rankings;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneRankingsRulesetSelector : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(RankingsRulesetSelector),
|
||||
};
|
||||
|
||||
public TestSceneRankingsRulesetSelector()
|
||||
{
|
||||
var current = new Bindable<RulesetInfo>();
|
||||
|
||||
Add(new RankingsRulesetSelector
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Current = { BindTarget = current }
|
||||
});
|
||||
|
||||
AddStep("Select osu!", () => current.Value = new OsuRuleset().RulesetInfo);
|
||||
AddStep("Select mania", () => current.Value = new ManiaRuleset().RulesetInfo);
|
||||
AddStep("Select taiko", () => current.Value = new TaikoRuleset().RulesetInfo);
|
||||
AddStep("Select catch", () => current.Value = new CatchRuleset().RulesetInfo);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays.Rankings;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneRankingsScopeSelector : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(RankingsScopeSelector),
|
||||
};
|
||||
|
||||
private readonly Box background;
|
||||
|
||||
public TestSceneRankingsScopeSelector()
|
||||
{
|
||||
var scope = new Bindable<RankingsScope>();
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
new RankingsScopeSelector
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Current = scope,
|
||||
}
|
||||
});
|
||||
|
||||
AddStep(@"Select country", () => scope.Value = RankingsScope.Country);
|
||||
AddStep(@"Select performance", () => scope.Value = RankingsScope.Performance);
|
||||
AddStep(@"Select score", () => scope.Value = RankingsScope.Score);
|
||||
AddStep(@"Select spotlights", () => scope.Value = RankingsScope.Spotlights);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
background.Colour = colours.GreySeafoam;
|
||||
}
|
||||
}
|
||||
}
|
129
osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs
Normal file
129
osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs
Normal file
@ -0,0 +1,129 @@
|
||||
// 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 osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays.Rankings.Tables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using System.Threading;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneRankingsTables : OsuTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(PerformanceTable),
|
||||
typeof(ScoresTable),
|
||||
typeof(CountriesTable),
|
||||
typeof(TableRowBackground),
|
||||
typeof(UserBasedTable),
|
||||
typeof(RankingsTable<>)
|
||||
};
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private readonly BasicScrollContainer scrollFlow;
|
||||
private readonly DimmedLoadingLayer loading;
|
||||
private CancellationTokenSource cancellationToken;
|
||||
private APIRequest request;
|
||||
|
||||
public TestSceneRankingsTables()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
scrollFlow = new BasicScrollContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 0.8f,
|
||||
},
|
||||
loading = new DimmedLoadingLayer(),
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
AddStep("Osu performance", () => createPerformanceTable(new OsuRuleset().RulesetInfo, null));
|
||||
AddStep("Mania scores", () => createScoreTable(new ManiaRuleset().RulesetInfo));
|
||||
AddStep("Taiko country scores", () => createCountryTable(new TaikoRuleset().RulesetInfo));
|
||||
AddStep("Catch US performance page 10", () => createPerformanceTable(new CatchRuleset().RulesetInfo, "US", 10));
|
||||
}
|
||||
|
||||
private void createCountryTable(RulesetInfo ruleset, int page = 1)
|
||||
{
|
||||
onLoadStarted();
|
||||
|
||||
request = new GetCountryRankingsRequest(ruleset, page);
|
||||
((GetCountryRankingsRequest)request).Success += rankings => Schedule(() =>
|
||||
{
|
||||
var table = new CountriesTable(page, rankings.Countries);
|
||||
loadTable(table);
|
||||
});
|
||||
|
||||
api.Queue(request);
|
||||
}
|
||||
|
||||
private void createPerformanceTable(RulesetInfo ruleset, string country, int page = 1)
|
||||
{
|
||||
onLoadStarted();
|
||||
|
||||
request = new GetUserRankingsRequest(ruleset, country: country, page: page);
|
||||
((GetUserRankingsRequest)request).Success += rankings => Schedule(() =>
|
||||
{
|
||||
var table = new PerformanceTable(page, rankings.Users);
|
||||
loadTable(table);
|
||||
});
|
||||
|
||||
api.Queue(request);
|
||||
}
|
||||
|
||||
private void createScoreTable(RulesetInfo ruleset, int page = 1)
|
||||
{
|
||||
onLoadStarted();
|
||||
|
||||
request = new GetUserRankingsRequest(ruleset, UserRankingsType.Score, page);
|
||||
((GetUserRankingsRequest)request).Success += rankings => Schedule(() =>
|
||||
{
|
||||
var table = new ScoresTable(page, rankings.Users);
|
||||
loadTable(table);
|
||||
});
|
||||
|
||||
api.Queue(request);
|
||||
}
|
||||
|
||||
private void onLoadStarted()
|
||||
{
|
||||
loading.Show();
|
||||
request?.Cancel();
|
||||
cancellationToken?.Cancel();
|
||||
cancellationToken = new CancellationTokenSource();
|
||||
}
|
||||
|
||||
private void loadTable(Drawable table)
|
||||
{
|
||||
LoadComponentAsync(table, t =>
|
||||
{
|
||||
scrollFlow.Clear();
|
||||
scrollFlow.Add(t);
|
||||
loading.Hide();
|
||||
}, cancellationToken.Token);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +1,18 @@
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.BeatmapSet.Scores;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
@ -30,11 +27,9 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(ScoreTableRowBackground),
|
||||
};
|
||||
|
||||
private readonly Box background;
|
||||
|
||||
public TestSceneScoresContainer()
|
||||
{
|
||||
ScoresContainer scoresContainer;
|
||||
TestScoresContainer scoresContainer;
|
||||
|
||||
Child = new Container
|
||||
{
|
||||
@ -44,108 +39,137 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Width = 0.8f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Box { RelativeSizeAxes = Axes.Both },
|
||||
scoresContainer = new ScoresContainer(),
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
scoresContainer = new TestScoresContainer(),
|
||||
}
|
||||
};
|
||||
|
||||
var scores = new List<ScoreInfo>
|
||||
var allScores = new APILegacyScores
|
||||
{
|
||||
new ScoreInfo
|
||||
Scores = new List<APILegacyScoreInfo>
|
||||
{
|
||||
User = new User
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
Id = 6602580,
|
||||
Username = @"waaiiru",
|
||||
Country = new Country
|
||||
User = new User
|
||||
{
|
||||
FullName = @"Spain",
|
||||
FlagName = @"ES",
|
||||
Id = 6602580,
|
||||
Username = @"waaiiru",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Spain",
|
||||
FlagName = @"ES",
|
||||
},
|
||||
},
|
||||
},
|
||||
Mods = new Mod[]
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModHidden(),
|
||||
new OsuModFlashlight(),
|
||||
new OsuModHardRock(),
|
||||
},
|
||||
Rank = ScoreRank.XH,
|
||||
PP = 200,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234567890,
|
||||
Accuracy = 1,
|
||||
},
|
||||
new ScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 4608074,
|
||||
Username = @"Skycries",
|
||||
Country = new Country
|
||||
Mods = new[]
|
||||
{
|
||||
FullName = @"Brazil",
|
||||
FlagName = @"BR",
|
||||
new OsuModDoubleTime().Acronym,
|
||||
new OsuModHidden().Acronym,
|
||||
new OsuModFlashlight().Acronym,
|
||||
new OsuModHardRock().Acronym,
|
||||
},
|
||||
Rank = ScoreRank.XH,
|
||||
PP = 200,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234567890,
|
||||
Accuracy = 1,
|
||||
},
|
||||
Mods = new Mod[]
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModHidden(),
|
||||
new OsuModFlashlight(),
|
||||
},
|
||||
Rank = ScoreRank.S,
|
||||
PP = 190,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234789,
|
||||
Accuracy = 0.9997,
|
||||
},
|
||||
new ScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 1014222,
|
||||
Username = @"eLy",
|
||||
Country = new Country
|
||||
User = new User
|
||||
{
|
||||
FullName = @"Japan",
|
||||
FlagName = @"JP",
|
||||
Id = 4608074,
|
||||
Username = @"Skycries",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Brazil",
|
||||
FlagName = @"BR",
|
||||
},
|
||||
},
|
||||
},
|
||||
Mods = new Mod[]
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModHidden(),
|
||||
},
|
||||
Rank = ScoreRank.B,
|
||||
PP = 180,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 12345678,
|
||||
Accuracy = 0.9854,
|
||||
},
|
||||
new ScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 1541390,
|
||||
Username = @"Toukai",
|
||||
Country = new Country
|
||||
Mods = new[]
|
||||
{
|
||||
FullName = @"Canada",
|
||||
FlagName = @"CA",
|
||||
new OsuModDoubleTime().Acronym,
|
||||
new OsuModHidden().Acronym,
|
||||
new OsuModFlashlight().Acronym,
|
||||
},
|
||||
Rank = ScoreRank.S,
|
||||
PP = 190,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234789,
|
||||
Accuracy = 0.9997,
|
||||
},
|
||||
Mods = new Mod[]
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
new OsuModDoubleTime(),
|
||||
User = new User
|
||||
{
|
||||
Id = 1014222,
|
||||
Username = @"eLy",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Japan",
|
||||
FlagName = @"JP",
|
||||
},
|
||||
},
|
||||
Mods = new[]
|
||||
{
|
||||
new OsuModDoubleTime().Acronym,
|
||||
new OsuModHidden().Acronym,
|
||||
},
|
||||
Rank = ScoreRank.B,
|
||||
PP = 180,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 12345678,
|
||||
Accuracy = 0.9854,
|
||||
},
|
||||
Rank = ScoreRank.C,
|
||||
PP = 170,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234567,
|
||||
Accuracy = 0.8765,
|
||||
},
|
||||
new ScoreInfo
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 1541390,
|
||||
Username = @"Toukai",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Canada",
|
||||
FlagName = @"CA",
|
||||
},
|
||||
},
|
||||
Mods = new[]
|
||||
{
|
||||
new OsuModDoubleTime().Acronym,
|
||||
},
|
||||
Rank = ScoreRank.C,
|
||||
PP = 170,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234567,
|
||||
Accuracy = 0.8765,
|
||||
},
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 7151382,
|
||||
Username = @"Mayuri Hana",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Thailand",
|
||||
FlagName = @"TH",
|
||||
},
|
||||
},
|
||||
Rank = ScoreRank.D,
|
||||
PP = 160,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 123456,
|
||||
Accuracy = 0.6543,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var myBestScore = new APILegacyUserTopScoreInfo
|
||||
{
|
||||
Score = new APILegacyScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -163,25 +187,72 @@ namespace osu.Game.Tests.Visual.Online
|
||||
TotalScore = 123456,
|
||||
Accuracy = 0.6543,
|
||||
},
|
||||
Position = 1337,
|
||||
};
|
||||
|
||||
foreach (var s in scores)
|
||||
var oneScore = new APILegacyScores
|
||||
{
|
||||
s.Statistics.Add(HitResult.Great, RNG.Next(2000));
|
||||
s.Statistics.Add(HitResult.Good, RNG.Next(2000));
|
||||
s.Statistics.Add(HitResult.Meh, RNG.Next(2000));
|
||||
s.Statistics.Add(HitResult.Miss, RNG.Next(2000));
|
||||
Scores = new List<APILegacyScoreInfo>
|
||||
{
|
||||
new APILegacyScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Id = 6602580,
|
||||
Username = @"waaiiru",
|
||||
Country = new Country
|
||||
{
|
||||
FullName = @"Spain",
|
||||
FlagName = @"ES",
|
||||
},
|
||||
},
|
||||
Mods = new[]
|
||||
{
|
||||
new OsuModDoubleTime().Acronym,
|
||||
new OsuModHidden().Acronym,
|
||||
new OsuModFlashlight().Acronym,
|
||||
new OsuModHardRock().Acronym,
|
||||
},
|
||||
Rank = ScoreRank.XH,
|
||||
PP = 200,
|
||||
MaxCombo = 1234,
|
||||
TotalScore = 1234567890,
|
||||
Accuracy = 1,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
foreach (var s in allScores.Scores)
|
||||
{
|
||||
s.Statistics = new Dictionary<string, int>
|
||||
{
|
||||
{ "count_300", RNG.Next(2000) },
|
||||
{ "count_100", RNG.Next(2000) },
|
||||
{ "count_50", RNG.Next(2000) },
|
||||
{ "count_miss", RNG.Next(2000) }
|
||||
};
|
||||
}
|
||||
|
||||
AddStep("Load all scores", () => scoresContainer.Scores = scores);
|
||||
AddStep("Load all scores", () =>
|
||||
{
|
||||
allScores.UserScore = null;
|
||||
scoresContainer.Scores = allScores;
|
||||
});
|
||||
AddStep("Load null scores", () => scoresContainer.Scores = null);
|
||||
AddStep("Load only one score", () => scoresContainer.Scores = new[] { scores.First() });
|
||||
AddStep("Load only one score", () => scoresContainer.Scores = oneScore);
|
||||
AddStep("Load scores with my best", () =>
|
||||
{
|
||||
allScores.UserScore = myBestScore;
|
||||
scoresContainer.Scores = allScores;
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private class TestScoresContainer : ScoresContainer
|
||||
{
|
||||
background.Colour = colours.Gray2;
|
||||
public new APILegacyScores Scores
|
||||
{
|
||||
set => base.Scores = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
// 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.Game.Overlays.Profile.Sections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
@ -17,11 +19,11 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
public TestSceneShowMoreButton()
|
||||
{
|
||||
ShowMoreButton button = null;
|
||||
TestButton button = null;
|
||||
|
||||
int fireCount = 0;
|
||||
|
||||
Add(button = new ShowMoreButton
|
||||
Add(button = new TestButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -51,5 +53,16 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddAssert("action fired twice", () => fireCount == 2);
|
||||
AddAssert("is in loading state", () => button.IsLoading);
|
||||
}
|
||||
|
||||
private class TestButton : ShowMoreButton
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colors)
|
||||
{
|
||||
IdleColour = colors.YellowDark;
|
||||
HoverColour = colors.Yellow;
|
||||
ChevronIconColour = colors.Red;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[TestFixture]
|
||||
public class TestSceneSocialOverlay : OsuTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(UserPanel),
|
||||
|
@ -6,6 +6,11 @@ using osu.Framework.Graphics;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays.Chat;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
@ -32,17 +37,23 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Id = 4,
|
||||
};
|
||||
|
||||
private readonly User longUsernameUser = new User
|
||||
{
|
||||
Username = "Very Long Long Username",
|
||||
Id = 5,
|
||||
};
|
||||
|
||||
[Cached]
|
||||
private ChannelManager channelManager = new ChannelManager();
|
||||
|
||||
private readonly StandAloneChatDisplay chatDisplay;
|
||||
private readonly StandAloneChatDisplay chatDisplay2;
|
||||
private readonly TestStandAloneChatDisplay chatDisplay;
|
||||
private readonly TestStandAloneChatDisplay chatDisplay2;
|
||||
|
||||
public TestSceneStandAloneChatDisplay()
|
||||
{
|
||||
Add(channelManager);
|
||||
|
||||
Add(chatDisplay = new StandAloneChatDisplay
|
||||
Add(chatDisplay = new TestStandAloneChatDisplay
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
@ -50,7 +61,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Size = new Vector2(400, 80)
|
||||
});
|
||||
|
||||
Add(chatDisplay2 = new StandAloneChatDisplay(true)
|
||||
Add(chatDisplay2 = new TestStandAloneChatDisplay(true)
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
@ -99,6 +110,66 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Sender = admin,
|
||||
Content = "Okay okay, calm down guys. Let's do this!"
|
||||
}));
|
||||
|
||||
AddStep("message from long username", () => testChannel.AddNewMessages(new Message(sequence++)
|
||||
{
|
||||
Sender = longUsernameUser,
|
||||
Content = "Hi guys, my new username is lit!"
|
||||
}));
|
||||
|
||||
AddStep("message with new date", () => testChannel.AddNewMessages(new Message(sequence++)
|
||||
{
|
||||
Sender = longUsernameUser,
|
||||
Content = "Message from the future!",
|
||||
Timestamp = DateTimeOffset.Now
|
||||
}));
|
||||
|
||||
AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom);
|
||||
|
||||
const int messages_per_call = 10;
|
||||
AddRepeatStep("add many messages", () =>
|
||||
{
|
||||
for (int i = 0; i < messages_per_call; i++)
|
||||
{
|
||||
testChannel.AddNewMessages(new Message(sequence++)
|
||||
{
|
||||
Sender = longUsernameUser,
|
||||
Content = "Many messages! " + Guid.NewGuid(),
|
||||
Timestamp = DateTimeOffset.Now
|
||||
});
|
||||
}
|
||||
}, Channel.MAX_HISTORY / messages_per_call + 5);
|
||||
|
||||
AddAssert("Ensure no adjacent day separators", () =>
|
||||
{
|
||||
var indices = chatDisplay.FillFlow.OfType<DrawableChannel.DaySeparator>().Select(ds => chatDisplay.FillFlow.IndexOf(ds));
|
||||
|
||||
foreach (var i in indices)
|
||||
{
|
||||
if (i < chatDisplay.FillFlow.Count && chatDisplay.FillFlow[i + 1] is DrawableChannel.DaySeparator)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
AddUntilStep("ensure still scrolled to bottom", () => chatDisplay.ScrolledToBottom);
|
||||
}
|
||||
|
||||
private class TestStandAloneChatDisplay : StandAloneChatDisplay
|
||||
{
|
||||
public TestStandAloneChatDisplay(bool textbox = false)
|
||||
: base(textbox)
|
||||
{
|
||||
}
|
||||
|
||||
protected DrawableChannel DrawableChannel => InternalChildren.OfType<DrawableChannel>().First();
|
||||
|
||||
protected OsuScrollContainer ScrollContainer => (OsuScrollContainer)((Container)DrawableChannel.Child).Child;
|
||||
|
||||
public FillFlowContainer FillFlow => (FillFlowContainer)ScrollContainer.Child;
|
||||
|
||||
public bool ScrolledToBottom => ScrollContainer.IsScrolledToEnd(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Overlays.Comments;
|
||||
using osu.Framework.Utils;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneTotalCommentsCounter : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(TotalCommentsCounter),
|
||||
};
|
||||
|
||||
public TestSceneTotalCommentsCounter()
|
||||
{
|
||||
var count = new BindableInt();
|
||||
|
||||
Add(new TotalCommentsCounter
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Current = { BindTarget = count }
|
||||
});
|
||||
|
||||
AddStep(@"Set 100", () => count.Value = 100);
|
||||
AddStep(@"Set 0", () => count.Value = 0);
|
||||
AddStep(@"Set random", () => count.Value = RNG.Next(0, int.MaxValue));
|
||||
}
|
||||
}
|
||||
}
|
@ -17,12 +17,14 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneUserProfileHeader : OsuTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ProfileHeader),
|
||||
typeof(RankGraph),
|
||||
typeof(LineGraph),
|
||||
typeof(OverlayHeaderTabControl),
|
||||
typeof(TabControlOverlayHeader.OverlayHeaderTabControl),
|
||||
typeof(CentreHeaderContainer),
|
||||
typeof(BottomHeaderContainer),
|
||||
typeof(DetailHeaderContainer),
|
||||
|
@ -19,6 +19,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[TestFixture]
|
||||
public class TestSceneUserProfileOverlay : OsuTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
private readonly TestUserProfileOverlay profile;
|
||||
|
||||
[Resolved]
|
||||
@ -50,12 +52,12 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
Current = 727,
|
||||
Progress = 69,
|
||||
}
|
||||
},
|
||||
RankHistory = new User.RankHistoryData
|
||||
{
|
||||
Mode = @"osu",
|
||||
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
|
||||
},
|
||||
RankHistory = new User.RankHistoryData
|
||||
{
|
||||
Mode = @"osu",
|
||||
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
|
||||
},
|
||||
},
|
||||
Badges = new[]
|
||||
{
|
||||
@ -68,7 +70,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
Title = "osu!volunteer",
|
||||
Colour = "ff0000",
|
||||
Achievements = new User.UserAchievement[0],
|
||||
Achievements = Array.Empty<User.UserAchievement>(),
|
||||
};
|
||||
|
||||
public TestSceneUserProfileOverlay()
|
||||
@ -105,6 +107,15 @@ namespace osu.Game.Tests.Visual.Online
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
|
||||
}, api.IsLoggedIn));
|
||||
|
||||
AddStep("Show bancho", () => profile.ShowUser(new User
|
||||
{
|
||||
Username = @"BanchoBot",
|
||||
Id = 3,
|
||||
IsBot = true,
|
||||
Country = new Country { FullName = @"Saint Helena", FlagName = @"SH" },
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg"
|
||||
}, api.IsLoggedIn));
|
||||
|
||||
AddStep("Hide", profile.Hide);
|
||||
AddStep("Show without reload", profile.Show);
|
||||
}
|
||||
|
@ -0,0 +1,69 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Overlays.Profile.Header.Components;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneUserProfilePreviousUsernames : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(PreviousUsernames)
|
||||
};
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private readonly Bindable<User> user = new Bindable<User>();
|
||||
|
||||
public TestSceneUserProfilePreviousUsernames()
|
||||
{
|
||||
Child = new PreviousUsernames
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
User = { BindTarget = user },
|
||||
};
|
||||
|
||||
User[] users =
|
||||
{
|
||||
new User { PreviousUsernames = new[] { "username1" } },
|
||||
new User { PreviousUsernames = new[] { "longusername", "longerusername" } },
|
||||
new User { PreviousUsernames = new[] { "test", "angelsim", "verylongusername" } },
|
||||
new User { PreviousUsernames = new[] { "ihavenoidea", "howcani", "makethistext", "anylonger" } },
|
||||
new User { PreviousUsernames = Array.Empty<string>() },
|
||||
null
|
||||
};
|
||||
|
||||
AddStep("single username", () => user.Value = users[0]);
|
||||
AddStep("two usernames", () => user.Value = users[1]);
|
||||
AddStep("three usernames", () => user.Value = users[2]);
|
||||
AddStep("four usernames", () => user.Value = users[3]);
|
||||
AddStep("no username", () => user.Value = users[4]);
|
||||
AddStep("null user", () => user.Value = users[5]);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
AddStep("online user (Angelsim)", () =>
|
||||
{
|
||||
var request = new GetUserRequest(1777162);
|
||||
request.Success += user => this.user.Value = user;
|
||||
api.Queue(request);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -18,6 +18,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[TestFixture]
|
||||
public class TestSceneUserRanks : OsuTestScene
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(DrawableProfileScore), typeof(RanksSection) };
|
||||
|
||||
public TestSceneUserRanks()
|
||||
|
109
osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs
Normal file
109
osu.Game.Tests/Visual/Online/TestSceneUserRequest.cs
Normal file
@ -0,0 +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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Users;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneUserRequest : OsuTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private readonly Bindable<User> user = new Bindable<User>();
|
||||
private GetUserRequest request;
|
||||
private readonly DimmedLoadingLayer loading;
|
||||
|
||||
public TestSceneUserRequest()
|
||||
{
|
||||
Add(new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new UserTestContainer
|
||||
{
|
||||
User = { BindTarget = user }
|
||||
},
|
||||
loading = new DimmedLoadingLayer
|
||||
{
|
||||
Alpha = 0
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
AddStep(@"local user", () => getUser());
|
||||
AddStep(@"local user with taiko ruleset", () => getUser(ruleset: new TaikoRuleset().RulesetInfo));
|
||||
AddStep(@"cookiezi", () => getUser(124493));
|
||||
AddStep(@"cookiezi with mania ruleset", () => getUser(124493, new ManiaRuleset().RulesetInfo));
|
||||
}
|
||||
|
||||
private void getUser(long? userId = null, RulesetInfo ruleset = null)
|
||||
{
|
||||
loading.Show();
|
||||
|
||||
request?.Cancel();
|
||||
request = new GetUserRequest(userId, ruleset);
|
||||
request.Success += user =>
|
||||
{
|
||||
this.user.Value = user;
|
||||
loading.Hide();
|
||||
};
|
||||
api.Queue(request);
|
||||
}
|
||||
|
||||
private class UserTestContainer : FillFlowContainer
|
||||
{
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
public UserTestContainer()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Direction = FillDirection.Vertical;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
User.BindValueChanged(onUserUpdate, true);
|
||||
}
|
||||
|
||||
private void onUserUpdate(ValueChangedEvent<User> user)
|
||||
{
|
||||
Clear();
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = $@"Username: {user.NewValue?.Username}"
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = $@"RankedScore: {user.NewValue?.Statistics.RankedScore}"
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
76
osu.Game.Tests/Visual/Online/TestSceneVotePill.cs
Normal file
76
osu.Game.Tests/Visual/Online/TestSceneVotePill.cs
Normal file
@ -0,0 +1,76 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Comments;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneVotePill : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(VotePill)
|
||||
};
|
||||
|
||||
private VotePill votePill;
|
||||
|
||||
[Test]
|
||||
public void TestUserCommentPill()
|
||||
{
|
||||
AddStep("Log in", logIn);
|
||||
AddStep("User comment", () => addVotePill(getUserComment()));
|
||||
AddStep("Click", () => votePill.Click());
|
||||
AddAssert("Not loading", () => !votePill.IsLoading);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRandomCommentPill()
|
||||
{
|
||||
AddStep("Log in", logIn);
|
||||
AddStep("Random comment", () => addVotePill(getRandomComment()));
|
||||
AddStep("Click", () => votePill.Click());
|
||||
AddAssert("Loading", () => votePill.IsLoading);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOfflineRandomCommentPill()
|
||||
{
|
||||
AddStep("Log out", API.Logout);
|
||||
AddStep("Random comment", () => addVotePill(getRandomComment()));
|
||||
AddStep("Click", () => votePill.Click());
|
||||
AddAssert("Not loading", () => !votePill.IsLoading);
|
||||
}
|
||||
|
||||
private void logIn() => API.Login("localUser", "password");
|
||||
|
||||
private Comment getUserComment() => new Comment
|
||||
{
|
||||
IsVoted = false,
|
||||
UserId = API.LocalUser.Value.Id,
|
||||
VotesCount = 10,
|
||||
};
|
||||
|
||||
private Comment getRandomComment() => new Comment
|
||||
{
|
||||
IsVoted = false,
|
||||
UserId = 4444,
|
||||
VotesCount = 2,
|
||||
};
|
||||
|
||||
private void addVotePill(Comment comment)
|
||||
{
|
||||
Clear();
|
||||
Add(votePill = new VotePill(comment)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
65
osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs
Normal file
65
osu.Game.Tests/Visual/Settings/TestSceneSettingsSource.cs
Normal file
@ -0,0 +1,65 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Configuration;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Settings
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneSettingsSource : OsuTestScene
|
||||
{
|
||||
public TestSceneSettingsSource()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(20),
|
||||
Width = 0.5f,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Padding = new MarginPadding(50),
|
||||
ChildrenEnumerable = new TestTargetClass().CreateSettingsControls()
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private class TestTargetClass
|
||||
{
|
||||
[SettingSource("Sample bool", "Clicking this changes a setting")]
|
||||
public BindableBool TickBindable { get; } = new BindableBool();
|
||||
|
||||
[SettingSource("Sample float", "Change something for a mod")]
|
||||
public BindableFloat SliderBindable { get; } = new BindableFloat
|
||||
{
|
||||
MinValue = 0,
|
||||
MaxValue = 10,
|
||||
Default = 5,
|
||||
Value = 7
|
||||
};
|
||||
|
||||
[SettingSource("Sample enum", "Change something for a mod")]
|
||||
public Bindable<TestEnum> EnumBindable { get; } = new Bindable<TestEnum>
|
||||
{
|
||||
Default = TestEnum.Value1,
|
||||
Value = TestEnum.Value2
|
||||
};
|
||||
|
||||
[SettingSource("Sample string", "Change something for a mod")]
|
||||
public Bindable<string> StringBindable { get; } = new Bindable<string>();
|
||||
}
|
||||
|
||||
private enum TestEnum
|
||||
{
|
||||
Value1,
|
||||
Value2
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets;
|
||||
@ -43,7 +44,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
private readonly Stack<BeatmapSetInfo> selectedSets = new Stack<BeatmapSetInfo>();
|
||||
private readonly HashSet<int> eagerSelectedIDs = new HashSet<int>();
|
||||
|
||||
private BeatmapInfo currentSelection;
|
||||
private BeatmapInfo currentSelection => carousel.SelectedBeatmap;
|
||||
|
||||
private const int set_count = 5;
|
||||
|
||||
@ -51,50 +52,433 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
private void load(RulesetStore rulesets)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
|
||||
Add(carousel = new TestBeatmapCarousel
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
});
|
||||
|
||||
List<BeatmapSetInfo> beatmapSets = new List<BeatmapSetInfo>();
|
||||
|
||||
for (int i = 1; i <= set_count; i++)
|
||||
beatmapSets.Add(createTestBeatmapSet(i));
|
||||
|
||||
carousel.SelectionChanged = s => currentSelection = s;
|
||||
|
||||
loadBeatmaps(beatmapSets);
|
||||
|
||||
testTraversal();
|
||||
testFiltering();
|
||||
testRandom();
|
||||
testAddRemove();
|
||||
testSorting();
|
||||
|
||||
testRemoveAll();
|
||||
testEmptyTraversal();
|
||||
testHiding();
|
||||
testSelectingFilteredRuleset();
|
||||
testCarouselRootIsRandom();
|
||||
}
|
||||
|
||||
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets)
|
||||
/// <summary>
|
||||
/// Test keyboard traversal
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestTraversal()
|
||||
{
|
||||
loadBeatmaps();
|
||||
|
||||
advanceSelection(direction: 1, diff: false);
|
||||
waitForSelection(1, 1);
|
||||
|
||||
advanceSelection(direction: 1, diff: true);
|
||||
waitForSelection(1, 2);
|
||||
|
||||
advanceSelection(direction: -1, diff: false);
|
||||
waitForSelection(set_count, 1);
|
||||
|
||||
advanceSelection(direction: -1, diff: true);
|
||||
waitForSelection(set_count - 1, 3);
|
||||
|
||||
advanceSelection(diff: false);
|
||||
advanceSelection(diff: false);
|
||||
waitForSelection(1, 2);
|
||||
|
||||
advanceSelection(direction: -1, diff: true);
|
||||
advanceSelection(direction: -1, diff: true);
|
||||
waitForSelection(set_count, 3);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test filtering
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestFiltering()
|
||||
{
|
||||
loadBeatmaps();
|
||||
|
||||
// basic filtering
|
||||
|
||||
setSelected(1, 1);
|
||||
|
||||
AddStep("Filter", () => carousel.Filter(new FilterCriteria { SearchText = "set #3!" }, false));
|
||||
checkVisibleItemCount(diff: false, count: 1);
|
||||
checkVisibleItemCount(diff: true, count: 3);
|
||||
waitForSelection(3, 1);
|
||||
|
||||
advanceSelection(diff: true, count: 4);
|
||||
waitForSelection(3, 2);
|
||||
|
||||
AddStep("Un-filter (debounce)", () => carousel.Filter(new FilterCriteria()));
|
||||
AddUntilStep("Wait for debounce", () => !carousel.PendingFilterTask);
|
||||
checkVisibleItemCount(diff: false, count: set_count);
|
||||
checkVisibleItemCount(diff: true, count: 3);
|
||||
|
||||
// test filtering some difficulties (and keeping current beatmap set selected).
|
||||
|
||||
setSelected(1, 2);
|
||||
AddStep("Filter some difficulties", () => carousel.Filter(new FilterCriteria { SearchText = "Normal" }, false));
|
||||
waitForSelection(1, 1);
|
||||
|
||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||
waitForSelection(1, 1);
|
||||
|
||||
AddStep("Filter all", () => carousel.Filter(new FilterCriteria { SearchText = "Dingo" }, false));
|
||||
|
||||
checkVisibleItemCount(false, 0);
|
||||
checkVisibleItemCount(true, 0);
|
||||
AddAssert("Selection is null", () => currentSelection == null);
|
||||
|
||||
advanceSelection(true);
|
||||
AddAssert("Selection is null", () => currentSelection == null);
|
||||
|
||||
advanceSelection(false);
|
||||
AddAssert("Selection is null", () => currentSelection == null);
|
||||
|
||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||
|
||||
AddAssert("Selection is non-null", () => currentSelection != null);
|
||||
|
||||
setSelected(1, 3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFilterRange()
|
||||
{
|
||||
loadBeatmaps();
|
||||
|
||||
// buffer the selection
|
||||
setSelected(3, 2);
|
||||
|
||||
setSelected(1, 3);
|
||||
|
||||
AddStep("Apply a range filter", () => carousel.Filter(new FilterCriteria
|
||||
{
|
||||
SearchText = "#3",
|
||||
StarDifficulty = new FilterCriteria.OptionalRange<double>
|
||||
{
|
||||
Min = 2,
|
||||
Max = 5.5,
|
||||
IsLowerInclusive = true
|
||||
}
|
||||
}, false));
|
||||
|
||||
// should reselect the buffered selection.
|
||||
waitForSelection(3, 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test random non-repeating algorithm
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestRandom()
|
||||
{
|
||||
loadBeatmaps();
|
||||
|
||||
setSelected(1, 1);
|
||||
|
||||
nextRandom();
|
||||
ensureRandomDidntRepeat();
|
||||
nextRandom();
|
||||
ensureRandomDidntRepeat();
|
||||
nextRandom();
|
||||
ensureRandomDidntRepeat();
|
||||
|
||||
prevRandom();
|
||||
ensureRandomFetchSuccess();
|
||||
prevRandom();
|
||||
ensureRandomFetchSuccess();
|
||||
|
||||
nextRandom();
|
||||
ensureRandomDidntRepeat();
|
||||
nextRandom();
|
||||
ensureRandomDidntRepeat();
|
||||
|
||||
nextRandom();
|
||||
AddAssert("ensure repeat", () => selectedSets.Contains(carousel.SelectedBeatmapSet));
|
||||
|
||||
AddStep("Add set with 100 difficulties", () => carousel.UpdateBeatmapSet(createTestBeatmapSetWithManyDifficulties(set_count + 1)));
|
||||
AddStep("Filter Extra", () => carousel.Filter(new FilterCriteria { SearchText = "Extra 10" }, false));
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test adding and removing beatmap sets
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestAddRemove()
|
||||
{
|
||||
loadBeatmaps();
|
||||
|
||||
AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 1)));
|
||||
AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 2)));
|
||||
|
||||
checkVisibleItemCount(false, set_count + 2);
|
||||
|
||||
AddStep("Remove set", () => carousel.RemoveBeatmapSet(createTestBeatmapSet(set_count + 2)));
|
||||
|
||||
checkVisibleItemCount(false, set_count + 1);
|
||||
|
||||
setSelected(set_count + 1, 1);
|
||||
|
||||
AddStep("Remove set", () => carousel.RemoveBeatmapSet(createTestBeatmapSet(set_count + 1)));
|
||||
|
||||
checkVisibleItemCount(false, set_count);
|
||||
|
||||
waitForSelection(set_count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test sorting
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestSorting()
|
||||
{
|
||||
loadBeatmaps();
|
||||
|
||||
AddStep("Sort by author", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Author }, false));
|
||||
AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.AuthorString == "zzzzz");
|
||||
AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false));
|
||||
AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSortingStability()
|
||||
{
|
||||
var sets = new List<BeatmapSetInfo>();
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
var set = createTestBeatmapSet(i);
|
||||
set.Metadata.Artist = "same artist";
|
||||
set.Metadata.Title = "same title";
|
||||
sets.Add(set);
|
||||
}
|
||||
|
||||
loadBeatmaps(sets);
|
||||
|
||||
AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false));
|
||||
AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.ID == index).All(b => b));
|
||||
|
||||
AddStep("Sort by title", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Title }, false));
|
||||
AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.ID == index).All(b => b));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSortingWithFiltered()
|
||||
{
|
||||
List<BeatmapSetInfo> sets = new List<BeatmapSetInfo>();
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
var set = createTestBeatmapSet(i);
|
||||
set.Beatmaps[0].StarDifficulty = 3 - i;
|
||||
set.Beatmaps[2].StarDifficulty = 6 + i;
|
||||
sets.Add(set);
|
||||
}
|
||||
|
||||
loadBeatmaps(sets);
|
||||
|
||||
AddStep("Filter to normal", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Normal" }, false));
|
||||
AddAssert("Check first set at end", () => carousel.BeatmapSets.First() == sets.Last());
|
||||
AddAssert("Check last set at start", () => carousel.BeatmapSets.Last() == sets.First());
|
||||
|
||||
AddStep("Filter to insane", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Insane" }, false));
|
||||
AddAssert("Check first set at start", () => carousel.BeatmapSets.First() == sets.First());
|
||||
AddAssert("Check last set at end", () => carousel.BeatmapSets.Last() == sets.Last());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRemoveAll()
|
||||
{
|
||||
loadBeatmaps();
|
||||
|
||||
setSelected(2, 1);
|
||||
AddAssert("Selection is non-null", () => currentSelection != null);
|
||||
|
||||
AddStep("Remove selected", () => carousel.RemoveBeatmapSet(carousel.SelectedBeatmapSet));
|
||||
waitForSelection(2);
|
||||
|
||||
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
|
||||
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
|
||||
waitForSelection(1);
|
||||
|
||||
AddUntilStep("Remove all", () =>
|
||||
{
|
||||
if (!carousel.BeatmapSets.Any()) return true;
|
||||
|
||||
carousel.RemoveBeatmapSet(carousel.BeatmapSets.Last());
|
||||
return false;
|
||||
});
|
||||
|
||||
checkNoSelection();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmptyTraversal()
|
||||
{
|
||||
loadBeatmaps(new List<BeatmapSetInfo>());
|
||||
|
||||
advanceSelection(direction: 1, diff: false);
|
||||
checkNoSelection();
|
||||
|
||||
advanceSelection(direction: 1, diff: true);
|
||||
checkNoSelection();
|
||||
|
||||
advanceSelection(direction: -1, diff: false);
|
||||
checkNoSelection();
|
||||
|
||||
advanceSelection(direction: -1, diff: true);
|
||||
checkNoSelection();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHiding()
|
||||
{
|
||||
BeatmapSetInfo hidingSet = null;
|
||||
List<BeatmapSetInfo> hiddenList = new List<BeatmapSetInfo>();
|
||||
|
||||
AddStep("create hidden set", () =>
|
||||
{
|
||||
hidingSet = createTestBeatmapSet(1);
|
||||
hidingSet.Beatmaps[1].Hidden = true;
|
||||
|
||||
hiddenList.Clear();
|
||||
hiddenList.Add(hidingSet);
|
||||
});
|
||||
|
||||
loadBeatmaps(hiddenList);
|
||||
|
||||
setSelected(1, 1);
|
||||
|
||||
checkVisibleItemCount(true, 2);
|
||||
advanceSelection(true);
|
||||
waitForSelection(1, 3);
|
||||
|
||||
setHidden(3);
|
||||
waitForSelection(1, 1);
|
||||
|
||||
setHidden(2, false);
|
||||
advanceSelection(true);
|
||||
waitForSelection(1, 2);
|
||||
|
||||
setHidden(1);
|
||||
waitForSelection(1, 2);
|
||||
|
||||
setHidden(2);
|
||||
checkNoSelection();
|
||||
|
||||
void setHidden(int diff, bool hidden = true)
|
||||
{
|
||||
AddStep((hidden ? "" : "un") + $"hide diff {diff}", () =>
|
||||
{
|
||||
hidingSet.Beatmaps[diff - 1].Hidden = hidden;
|
||||
carousel.UpdateBeatmapSet(hidingSet);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectingFilteredRuleset()
|
||||
{
|
||||
BeatmapSetInfo testMixed = null;
|
||||
|
||||
createCarousel();
|
||||
|
||||
AddStep("add mixed ruleset beatmapset", () =>
|
||||
{
|
||||
testMixed = createTestBeatmapSet(set_count + 1);
|
||||
|
||||
for (int i = 0; i <= 2; i++)
|
||||
{
|
||||
testMixed.Beatmaps[i].Ruleset = rulesets.AvailableRulesets.ElementAt(i);
|
||||
testMixed.Beatmaps[i].RulesetID = i;
|
||||
}
|
||||
|
||||
carousel.UpdateBeatmapSet(testMixed);
|
||||
});
|
||||
AddStep("filter to ruleset 0", () =>
|
||||
carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false));
|
||||
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testMixed.Beatmaps[1], false));
|
||||
AddAssert("unfiltered beatmap selected", () => carousel.SelectedBeatmap.Equals(testMixed.Beatmaps[0]));
|
||||
|
||||
AddStep("remove mixed set", () =>
|
||||
{
|
||||
carousel.RemoveBeatmapSet(testMixed);
|
||||
testMixed = null;
|
||||
});
|
||||
var testSingle = createTestBeatmapSet(set_count + 2);
|
||||
testSingle.Beatmaps.ForEach(b =>
|
||||
{
|
||||
b.Ruleset = rulesets.AvailableRulesets.ElementAt(1);
|
||||
b.RulesetID = b.Ruleset.ID ?? 1;
|
||||
});
|
||||
AddStep("add single ruleset beatmapset", () => carousel.UpdateBeatmapSet(testSingle));
|
||||
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testSingle.Beatmaps[0], false));
|
||||
checkNoSelection();
|
||||
AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCarouselRootIsRandom()
|
||||
{
|
||||
List<BeatmapSetInfo> manySets = new List<BeatmapSetInfo>();
|
||||
|
||||
for (int i = 1; i <= 50; i++)
|
||||
manySets.Add(createTestBeatmapSet(i));
|
||||
|
||||
loadBeatmaps(manySets);
|
||||
|
||||
advanceSelection(direction: 1, diff: false);
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
AddAssert("Selection was random", () => eagerSelectedIDs.Count > 1);
|
||||
}
|
||||
|
||||
private void loadBeatmaps(List<BeatmapSetInfo> beatmapSets = null)
|
||||
{
|
||||
createCarousel();
|
||||
|
||||
if (beatmapSets == null)
|
||||
{
|
||||
beatmapSets = new List<BeatmapSetInfo>();
|
||||
|
||||
for (int i = 1; i <= set_count; i++)
|
||||
beatmapSets.Add(createTestBeatmapSet(i));
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
AddStep($"Load {beatmapSets.Count} Beatmaps", () =>
|
||||
{
|
||||
carousel.Filter(new FilterCriteria());
|
||||
carousel.BeatmapSetsChanged = () => changed = true;
|
||||
carousel.BeatmapSets = beatmapSets;
|
||||
});
|
||||
|
||||
AddUntilStep("Wait for load", () => changed);
|
||||
}
|
||||
|
||||
private void createCarousel(Container target = null)
|
||||
{
|
||||
AddStep("Create carousel", () =>
|
||||
{
|
||||
selectedSets.Clear();
|
||||
eagerSelectedIDs.Clear();
|
||||
|
||||
(target ?? this).Child = carousel = new TestBeatmapCarousel
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void ensureRandomFetchSuccess() =>
|
||||
AddAssert("ensure prev random fetch worked", () => selectedSets.Peek() == carousel.SelectedBeatmapSet);
|
||||
|
||||
private void checkSelected(int set, int? diff = null) =>
|
||||
AddAssert($"selected is set{set}{(diff.HasValue ? $" diff{diff.Value}" : "")}", () =>
|
||||
private void waitForSelection(int set, int? diff = null) =>
|
||||
AddUntilStep($"selected is set{set}{(diff.HasValue ? $" diff{diff.Value}" : "")}", () =>
|
||||
{
|
||||
if (diff != null)
|
||||
return carousel.SelectedBeatmap == carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Skip(diff.Value - 1).First();
|
||||
@ -109,8 +493,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
private void advanceSelection(bool diff, int direction = 1, int count = 1)
|
||||
{
|
||||
if (count == 1)
|
||||
{
|
||||
AddStep($"select {(direction > 0 ? "next" : "prev")} {(diff ? "diff" : "set")}", () =>
|
||||
carousel.SelectNext(direction, !diff));
|
||||
}
|
||||
else
|
||||
{
|
||||
AddRepeatStep($"select {(direction > 0 ? "next" : "prev")} {(diff ? "diff" : "set")}", () =>
|
||||
@ -170,275 +556,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test keyboard traversal
|
||||
/// </summary>
|
||||
private void testTraversal()
|
||||
{
|
||||
advanceSelection(direction: 1, diff: false);
|
||||
checkSelected(1, 1);
|
||||
|
||||
advanceSelection(direction: 1, diff: true);
|
||||
checkSelected(1, 2);
|
||||
|
||||
advanceSelection(direction: -1, diff: false);
|
||||
checkSelected(set_count, 1);
|
||||
|
||||
advanceSelection(direction: -1, diff: true);
|
||||
checkSelected(set_count - 1, 3);
|
||||
|
||||
advanceSelection(diff: false);
|
||||
advanceSelection(diff: false);
|
||||
checkSelected(1, 2);
|
||||
|
||||
advanceSelection(direction: -1, diff: true);
|
||||
advanceSelection(direction: -1, diff: true);
|
||||
checkSelected(set_count, 3);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test filtering
|
||||
/// </summary>
|
||||
private void testFiltering()
|
||||
{
|
||||
// basic filtering
|
||||
|
||||
setSelected(1, 1);
|
||||
|
||||
AddStep("Filter", () => carousel.Filter(new FilterCriteria { SearchText = "set #3!" }, false));
|
||||
checkVisibleItemCount(diff: false, count: 1);
|
||||
checkVisibleItemCount(diff: true, count: 3);
|
||||
checkSelected(3, 1);
|
||||
|
||||
advanceSelection(diff: true, count: 4);
|
||||
checkSelected(3, 2);
|
||||
|
||||
AddStep("Un-filter (debounce)", () => carousel.Filter(new FilterCriteria()));
|
||||
AddUntilStep("Wait for debounce", () => !carousel.PendingFilterTask);
|
||||
checkVisibleItemCount(diff: false, count: set_count);
|
||||
checkVisibleItemCount(diff: true, count: 3);
|
||||
|
||||
// test filtering some difficulties (and keeping current beatmap set selected).
|
||||
|
||||
setSelected(1, 2);
|
||||
AddStep("Filter some difficulties", () => carousel.Filter(new FilterCriteria { SearchText = "Normal" }, false));
|
||||
checkSelected(1, 1);
|
||||
|
||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||
checkSelected(1, 1);
|
||||
|
||||
AddStep("Filter all", () => carousel.Filter(new FilterCriteria { SearchText = "Dingo" }, false));
|
||||
|
||||
checkVisibleItemCount(false, 0);
|
||||
checkVisibleItemCount(true, 0);
|
||||
AddAssert("Selection is null", () => currentSelection == null);
|
||||
|
||||
advanceSelection(true);
|
||||
AddAssert("Selection is null", () => currentSelection == null);
|
||||
|
||||
advanceSelection(false);
|
||||
AddAssert("Selection is null", () => currentSelection == null);
|
||||
|
||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||
|
||||
AddAssert("Selection is non-null", () => currentSelection != null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test random non-repeating algorithm
|
||||
/// </summary>
|
||||
private void testRandom()
|
||||
{
|
||||
setSelected(1, 1);
|
||||
|
||||
nextRandom();
|
||||
ensureRandomDidntRepeat();
|
||||
nextRandom();
|
||||
ensureRandomDidntRepeat();
|
||||
nextRandom();
|
||||
ensureRandomDidntRepeat();
|
||||
|
||||
prevRandom();
|
||||
ensureRandomFetchSuccess();
|
||||
prevRandom();
|
||||
ensureRandomFetchSuccess();
|
||||
|
||||
nextRandom();
|
||||
ensureRandomDidntRepeat();
|
||||
nextRandom();
|
||||
ensureRandomDidntRepeat();
|
||||
|
||||
nextRandom();
|
||||
AddAssert("ensure repeat", () => selectedSets.Contains(carousel.SelectedBeatmapSet));
|
||||
|
||||
AddStep("Add set with 100 difficulties", () => carousel.UpdateBeatmapSet(createTestBeatmapSetWithManyDifficulties(set_count + 1)));
|
||||
AddStep("Filter Extra", () => carousel.Filter(new FilterCriteria { SearchText = "Extra 10" }, false));
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
checkInvisibleDifficultiesUnselectable();
|
||||
AddStep("Un-filter", () => carousel.Filter(new FilterCriteria(), false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test adding and removing beatmap sets
|
||||
/// </summary>
|
||||
private void testAddRemove()
|
||||
{
|
||||
AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 1)));
|
||||
AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 2)));
|
||||
|
||||
checkVisibleItemCount(false, set_count + 2);
|
||||
|
||||
AddStep("Remove set", () => carousel.RemoveBeatmapSet(createTestBeatmapSet(set_count + 2)));
|
||||
|
||||
checkVisibleItemCount(false, set_count + 1);
|
||||
|
||||
setSelected(set_count + 1, 1);
|
||||
|
||||
AddStep("Remove set", () => carousel.RemoveBeatmapSet(createTestBeatmapSet(set_count + 1)));
|
||||
|
||||
checkVisibleItemCount(false, set_count);
|
||||
|
||||
checkSelected(set_count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test sorting
|
||||
/// </summary>
|
||||
private void testSorting()
|
||||
{
|
||||
AddStep("Sort by author", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Author }, false));
|
||||
AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.AuthorString == "zzzzz");
|
||||
AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false));
|
||||
AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!"));
|
||||
}
|
||||
|
||||
private void testRemoveAll()
|
||||
{
|
||||
setSelected(2, 1);
|
||||
AddAssert("Selection is non-null", () => currentSelection != null);
|
||||
|
||||
AddStep("Remove selected", () => carousel.RemoveBeatmapSet(carousel.SelectedBeatmapSet));
|
||||
checkSelected(2);
|
||||
|
||||
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
|
||||
AddStep("Remove first", () => carousel.RemoveBeatmapSet(carousel.BeatmapSets.First()));
|
||||
checkSelected(1);
|
||||
|
||||
AddUntilStep("Remove all", () =>
|
||||
{
|
||||
if (!carousel.BeatmapSets.Any()) return true;
|
||||
|
||||
carousel.RemoveBeatmapSet(carousel.BeatmapSets.Last());
|
||||
return false;
|
||||
});
|
||||
|
||||
checkNoSelection();
|
||||
}
|
||||
|
||||
private void testEmptyTraversal()
|
||||
{
|
||||
advanceSelection(direction: 1, diff: false);
|
||||
checkNoSelection();
|
||||
|
||||
advanceSelection(direction: 1, diff: true);
|
||||
checkNoSelection();
|
||||
|
||||
advanceSelection(direction: -1, diff: false);
|
||||
checkNoSelection();
|
||||
|
||||
advanceSelection(direction: -1, diff: true);
|
||||
checkNoSelection();
|
||||
}
|
||||
|
||||
private void testHiding()
|
||||
{
|
||||
var hidingSet = createTestBeatmapSet(1);
|
||||
hidingSet.Beatmaps[1].Hidden = true;
|
||||
AddStep("Add set with diff 2 hidden", () => carousel.UpdateBeatmapSet(hidingSet));
|
||||
setSelected(1, 1);
|
||||
|
||||
checkVisibleItemCount(true, 2);
|
||||
advanceSelection(true);
|
||||
checkSelected(1, 3);
|
||||
|
||||
setHidden(3);
|
||||
checkSelected(1, 1);
|
||||
|
||||
setHidden(2, false);
|
||||
advanceSelection(true);
|
||||
checkSelected(1, 2);
|
||||
|
||||
setHidden(1);
|
||||
checkSelected(1, 2);
|
||||
|
||||
setHidden(2);
|
||||
checkNoSelection();
|
||||
|
||||
void setHidden(int diff, bool hidden = true)
|
||||
{
|
||||
AddStep((hidden ? "" : "un") + $"hide diff {diff}", () =>
|
||||
{
|
||||
hidingSet.Beatmaps[diff - 1].Hidden = hidden;
|
||||
carousel.UpdateBeatmapSet(hidingSet);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void testSelectingFilteredRuleset()
|
||||
{
|
||||
var testMixed = createTestBeatmapSet(set_count + 1);
|
||||
AddStep("add mixed ruleset beatmapset", () =>
|
||||
{
|
||||
for (int i = 0; i <= 2; i++)
|
||||
{
|
||||
testMixed.Beatmaps[i].Ruleset = rulesets.AvailableRulesets.ElementAt(i);
|
||||
testMixed.Beatmaps[i].RulesetID = i;
|
||||
}
|
||||
|
||||
carousel.UpdateBeatmapSet(testMixed);
|
||||
});
|
||||
AddStep("filter to ruleset 0", () =>
|
||||
carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false));
|
||||
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testMixed.Beatmaps[1], false));
|
||||
AddAssert("unfiltered beatmap selected", () => carousel.SelectedBeatmap.Equals(testMixed.Beatmaps[0]));
|
||||
|
||||
AddStep("remove mixed set", () =>
|
||||
{
|
||||
carousel.RemoveBeatmapSet(testMixed);
|
||||
testMixed = null;
|
||||
});
|
||||
var testSingle = createTestBeatmapSet(set_count + 2);
|
||||
testSingle.Beatmaps.ForEach(b =>
|
||||
{
|
||||
b.Ruleset = rulesets.AvailableRulesets.ElementAt(1);
|
||||
b.RulesetID = b.Ruleset.ID ?? 1;
|
||||
});
|
||||
AddStep("add single ruleset beatmapset", () => carousel.UpdateBeatmapSet(testSingle));
|
||||
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testSingle.Beatmaps[0], false));
|
||||
checkNoSelection();
|
||||
AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle));
|
||||
}
|
||||
|
||||
private void testCarouselRootIsRandom()
|
||||
{
|
||||
List<BeatmapSetInfo> beatmapSets = new List<BeatmapSetInfo>();
|
||||
|
||||
for (int i = 1; i <= 50; i++)
|
||||
beatmapSets.Add(createTestBeatmapSet(i));
|
||||
|
||||
loadBeatmaps(beatmapSets);
|
||||
advanceSelection(direction: 1, diff: false);
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
AddAssert("Selection was random", () => eagerSelectedIDs.Count > 1);
|
||||
}
|
||||
|
||||
private BeatmapSetInfo createTestBeatmapSet(int id)
|
||||
{
|
||||
return new BeatmapSetInfo
|
||||
@ -516,6 +633,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
OnlineBeatmapID = b * 10,
|
||||
Path = $"extra{b}.osu",
|
||||
Version = $"Extra {b}",
|
||||
Ruleset = rulesets.GetRuleset((b - 1) % 4),
|
||||
StarDifficulty = 2,
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
|
@ -1,168 +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.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Screens.Select;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.SongSelect
|
||||
{
|
||||
[TestFixture]
|
||||
[System.ComponentModel.Description("PlaySongSelect leaderboard/details area")]
|
||||
public class TestSceneBeatmapDetailArea : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(BeatmapDetails) };
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase game)
|
||||
{
|
||||
BeatmapDetailArea detailsArea;
|
||||
Add(detailsArea = new BeatmapDetailArea
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(550f, 450f),
|
||||
});
|
||||
|
||||
AddStep("all metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
|
||||
{
|
||||
BeatmapSetInfo =
|
||||
{
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Version = "All Metrics",
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Source = "osu!lazer",
|
||||
Tags = "this beatmap has all the metrics",
|
||||
},
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
CircleSize = 7,
|
||||
DrainRate = 1,
|
||||
OverallDifficulty = 5.7f,
|
||||
ApproachRate = 3.5f,
|
||||
},
|
||||
StarDifficulty = 5.3f,
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
AddStep("all except source", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
|
||||
{
|
||||
BeatmapSetInfo =
|
||||
{
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Version = "All Metrics",
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Tags = "this beatmap has all the metrics",
|
||||
},
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
CircleSize = 7,
|
||||
DrainRate = 1,
|
||||
OverallDifficulty = 5.7f,
|
||||
ApproachRate = 3.5f,
|
||||
},
|
||||
StarDifficulty = 5.3f,
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("ratings", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
|
||||
{
|
||||
BeatmapSetInfo =
|
||||
{
|
||||
Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }
|
||||
},
|
||||
BeatmapInfo =
|
||||
{
|
||||
Version = "Only Ratings",
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Source = "osu!lazer",
|
||||
Tags = "this beatmap has ratings metrics but not retries or fails",
|
||||
},
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
CircleSize = 6,
|
||||
DrainRate = 9,
|
||||
OverallDifficulty = 6,
|
||||
ApproachRate = 6,
|
||||
},
|
||||
StarDifficulty = 4.8f
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("fails+retries", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Version = "Only Retries and Fails",
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Source = "osu!lazer",
|
||||
Tags = "this beatmap has retries and fails but no ratings",
|
||||
},
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
CircleSize = 3.7f,
|
||||
DrainRate = 6,
|
||||
OverallDifficulty = 6,
|
||||
ApproachRate = 7,
|
||||
},
|
||||
StarDifficulty = 2.91f,
|
||||
Metrics = new BeatmapMetrics
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(),
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("null metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
Version = "No Metrics",
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Source = "osu!lazer",
|
||||
Tags = "this beatmap has no metrics",
|
||||
},
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
CircleSize = 5,
|
||||
DrainRate = 5,
|
||||
OverallDifficulty = 5.5f,
|
||||
ApproachRate = 6.5f,
|
||||
},
|
||||
StarDifficulty = 1.97f,
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("null beatmap", () => detailsArea.Beatmap = null);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,8 +3,14 @@
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Select;
|
||||
|
||||
namespace osu.Game.Tests.Visual.SongSelect
|
||||
@ -174,5 +180,27 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
OnlineBeatmapID = 162,
|
||||
});
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
[Test]
|
||||
public void TestModAdjustments()
|
||||
{
|
||||
TestAllMetrics();
|
||||
|
||||
Ruleset ruleset = rulesets.AvailableRulesets.First().CreateInstance();
|
||||
|
||||
AddStep("with EZ mod", () => SelectedMods.Value = new[] { ruleset.GetAllMods().First(m => m is ModEasy) });
|
||||
|
||||
AddAssert("first bar coloured blue", () => details.ChildrenOfType<Bar>().Skip(1).First().AccentColour == colours.BlueDark);
|
||||
|
||||
AddStep("with HR mod", () => SelectedMods.Value = new[] { ruleset.GetAllMods().First(m => m is ModHardRock) });
|
||||
|
||||
AddAssert("first bar coloured red", () => details.ChildrenOfType<Bar>().Skip(1).First().AccentColour == colours.Red);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
testBeatmapLabels(instance);
|
||||
|
||||
// TODO: adjust cases once more info is shown for other gamemodes
|
||||
switch (instance)
|
||||
{
|
||||
case OsuRuleset _:
|
||||
@ -99,8 +98,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
testNullBeatmap();
|
||||
}
|
||||
|
||||
private void testBeatmapLabels(Ruleset ruleset)
|
||||
@ -117,7 +114,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddAssert("check info labels count", () => infoWedge.Info.InfoLabelContainer.Children.Count == expectedCount);
|
||||
}
|
||||
|
||||
private void testNullBeatmap()
|
||||
[Test]
|
||||
public void TestNullBeatmap()
|
||||
{
|
||||
selectBeatmap(null);
|
||||
AddAssert("check empty version", () => string.IsNullOrEmpty(infoWedge.Info.VersionLabel.Text));
|
||||
@ -127,6 +125,12 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddAssert("check no info labels", () => !infoWedge.Info.InfoLabelContainer.Children.Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTruncation()
|
||||
{
|
||||
selectBeatmap(createLongMetadata());
|
||||
}
|
||||
|
||||
private void selectBeatmap([CanBeNull] IBeatmap b)
|
||||
{
|
||||
BeatmapInfoWedge.BufferedWedgeInfo infoBefore = null;
|
||||
@ -166,6 +170,25 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
};
|
||||
}
|
||||
|
||||
private IBeatmap createLongMetadata()
|
||||
{
|
||||
return new Beatmap
|
||||
{
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
AuthorString = "WWWWWWWWWWWWWWW",
|
||||
Artist = "Verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long Artist",
|
||||
Source = "Verrrrry long Source",
|
||||
Title = "Verrrrry long Title"
|
||||
},
|
||||
Version = "Verrrrrrrrrrrrrrrrrrrrrrrrrrrrry long Version",
|
||||
Status = BeatmapSetOnlineStatus.Graveyard,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private class TestBeatmapInfoWedge : BeatmapInfoWedge
|
||||
{
|
||||
public new BufferedWedgeInfo Info => base.Info;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user