1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 13:22:57 +08:00
osu-lazer/osu.Game.Tests/Visual/UserInterface/TestSceneOsuAnimatedButton.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

125 lines
3.2 KiB
C#
Raw Normal View History

// 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;
2021-12-24 10:28:36 +08:00
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osuTK;
namespace osu.Game.Tests.Visual.UserInterface
{
2021-12-24 10:28:36 +08:00
public class TestSceneOsuAnimatedButton : OsuTestScene
{
2021-12-24 10:28:36 +08:00
[Test]
public void TestRelativeSized()
{
2021-12-24 10:28:36 +08:00
AddStep("add button", () => Child = new BaseContainer("relative sized")
{
RelativeSizeAxes = Axes.Both,
2021-12-24 10:28:36 +08:00
Action = () => { }
});
2021-12-24 10:28:36 +08:00
}
2021-12-24 10:28:36 +08:00
[Test]
public void TestAutoSized()
{
AddStep("add button", () => Child = new BaseContainer("auto sized")
{
2021-12-24 10:28:36 +08:00
AutoSizeAxes = Axes.Both,
Action = () => { }
});
2021-12-24 10:28:36 +08:00
}
2021-12-24 10:28:36 +08:00
[Test]
public void TestRelativeYAutoX()
{
AddStep("add button", () => Child = new BaseContainer("relative Y auto X")
{
RelativeSizeAxes = Axes.Y,
2021-12-24 10:28:36 +08:00
AutoSizeAxes = Axes.X,
Action = () => { }
});
2021-12-24 10:28:36 +08:00
}
2021-12-24 10:28:36 +08:00
[Test]
public void TestRelativeXAutoY()
{
AddStep("add button", () => Child = new BaseContainer("relative X auto Y")
{
RelativeSizeAxes = Axes.X,
2021-12-24 10:28:36 +08:00
AutoSizeAxes = Axes.Y,
Action = () => { }
});
2021-12-24 10:28:36 +08:00
}
2021-12-24 10:28:36 +08:00
[Test]
public void TestFixed1()
{
AddStep("add button", () => Child = new BaseContainer("fixed")
{
Size = new Vector2(100),
2021-12-24 10:28:36 +08:00
Action = () => { }
});
2021-12-24 10:28:36 +08:00
}
2021-12-24 10:28:36 +08:00
[Test]
public void TestFixed2()
{
AddStep("add button", () => Child = new BaseContainer("fixed")
{
Size = new Vector2(100, 50),
2021-12-24 10:28:36 +08:00
Action = () => { }
});
}
[Test]
public void TestToggleEnabled()
{
BaseContainer button = null;
AddStep("add button", () => Child = button = new BaseContainer("fixed")
{
Size = new Vector2(200),
});
AddToggleStep("toggle enabled", toggle =>
{
for (int i = 0; i < 6; i++)
2021-12-24 10:28:36 +08:00
button.Action = toggle ? () => { } : (Action)null;
});
}
[Test]
public void TestInitiallyDisabled()
{
AddStep("add disabled button", () =>
{
Child = new BaseContainer("disabled")
{
Size = new Vector2(100)
};
});
}
public class BaseContainer : OsuAnimatedButton
{
public BaseContainer(string text)
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Add(new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = text
});
}
}
}
}