1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 03:12:54 +08:00
osu-lazer/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditor.cs

87 lines
2.9 KiB
C#
Raw Normal View History

2021-04-27 17:03:49 +08:00
// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
2021-04-27 17:03:49 +08:00
using osu.Framework.Testing;
using osu.Game.Overlays;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Play.HUD.HitErrorMeters;
2022-07-28 16:58:07 +08:00
using osu.Game.Skinning;
using osu.Game.Skinning.Editor;
using osuTK.Input;
2021-04-27 17:03:49 +08:00
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneSkinEditor : PlayerTestScene
2021-04-27 17:03:49 +08:00
{
private SkinEditor skinEditor;
2021-05-13 13:54:52 +08:00
protected override bool Autoplay => true;
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
2021-04-27 17:03:49 +08:00
[SetUpSteps]
public override void SetUpSteps()
2021-04-27 17:03:49 +08:00
{
base.SetUpSteps();
2021-04-27 17:03:49 +08:00
2022-07-28 16:58:07 +08:00
AddUntilStep("wait for hud load", () => Player.ChildrenOfType<SkinnableTargetContainer>().All(c => c.ComponentsLoaded));
AddStep("reload skin editor", () =>
{
skinEditor?.Expire();
Player.ScaleTo(0.4f);
LoadComponentAsync(skinEditor = new SkinEditor(Player), Add);
2021-04-27 17:03:49 +08:00
});
AddUntilStep("wait for loaded", () => skinEditor.IsLoaded);
2021-04-27 17:03:49 +08:00
}
[Test]
public void TestToggleEditor()
{
2022-06-24 20:25:23 +08:00
AddToggleStep("toggle editor visibility", _ => skinEditor.ToggleVisibility());
}
[Test]
public void TestEditComponent()
{
BarHitErrorMeter hitErrorMeter = null;
AddStep("select bar hit error blueprint", () =>
{
var blueprint = skinEditor.ChildrenOfType<SkinBlueprint>().First(b => b.Item is BarHitErrorMeter);
hitErrorMeter = (BarHitErrorMeter)blueprint.Item;
skinEditor.SelectedComponents.Clear();
skinEditor.SelectedComponents.Add(blueprint.Item);
});
AddAssert("value is default", () => hitErrorMeter.JudgementLineThickness.IsDefault);
AddStep("hover first slider", () =>
{
InputManager.MoveMouseTo(
skinEditor.ChildrenOfType<SkinSettingsToolbox>().First()
.ChildrenOfType<SettingsSlider<float>>().First()
.ChildrenOfType<SliderBar<float>>().First()
);
});
AddStep("adjust slider via keyboard", () => InputManager.Key(Key.Left));
AddAssert("value is less than default", () => hitErrorMeter.JudgementLineThickness.Value < hitErrorMeter.JudgementLineThickness.Default);
}
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
2021-04-27 17:03:49 +08:00
}
}