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