osu/osu.Game.Tests/Visual/UserInterface/TestSceneOsuAnimatedButton.cs

123 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.
using System;
2021-12-24 02:28:36 +00: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 02:28:36 +00:00
public class TestSceneOsuAnimatedButton : OsuTestScene
{
2021-12-24 02:28:36 +00:00
[Test]
public void TestRelativeSized()
{
2021-12-24 02:28:36 +00:00
AddStep("add button", () => Child = new BaseContainer("relative sized")
{
RelativeSizeAxes = Axes.Both,
2021-12-24 02:28:36 +00:00
Action = () => { }
});
2021-12-24 02:28:36 +00:00
}
2021-12-24 02:28:36 +00:00
[Test]
public void TestAutoSized()
{
AddStep("add button", () => Child = new BaseContainer("auto sized")
{
2021-12-24 02:28:36 +00:00
AutoSizeAxes = Axes.Both,
Action = () => { }
});
2021-12-24 02:28:36 +00:00
}
2021-12-24 02:28:36 +00:00
[Test]
public void TestRelativeYAutoX()
{
AddStep("add button", () => Child = new BaseContainer("relative Y auto X")
{
RelativeSizeAxes = Axes.Y,
2021-12-24 02:28:36 +00:00
AutoSizeAxes = Axes.X,
Action = () => { }
});
2021-12-24 02:28:36 +00:00
}
2021-12-24 02:28:36 +00:00
[Test]
public void TestRelativeXAutoY()
{
AddStep("add button", () => Child = new BaseContainer("relative X auto Y")
{
RelativeSizeAxes = Axes.X,
2021-12-24 02:28:36 +00:00
AutoSizeAxes = Axes.Y,
Action = () => { }
});
2021-12-24 02:28:36 +00:00
}
2021-12-24 02:28:36 +00:00
[Test]
public void TestFixed1()
{
AddStep("add button", () => Child = new BaseContainer("fixed")
{
Size = new Vector2(100),
2021-12-24 02:28:36 +00:00
Action = () => { }
});
2021-12-24 02:28:36 +00:00
}
2021-12-24 02:28:36 +00:00
[Test]
public void TestFixed2()
{
AddStep("add button", () => Child = new BaseContainer("fixed")
{
Size = new Vector2(100, 50),
2021-12-24 02:28:36 +00: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 02:28:36 +00: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
});
}
}
}
}