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

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

71 lines
2.0 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.
2018-04-13 09:19:50 +00:00
2022-06-17 07:37:17 +00:00
#nullable disable
2020-01-27 04:16:36 +00:00
using System.Linq;
2018-03-02 06:34:31 +00:00
using NUnit.Framework;
using osu.Framework.Allocation;
2017-09-18 13:32:49 +00:00
using osu.Framework.Graphics;
2020-01-27 04:16:36 +00:00
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
2017-09-18 13:32:49 +00:00
using osu.Game.Graphics.UserInterface;
2018-04-13 09:19:50 +00:00
2019-03-24 16:02:36 +00:00
namespace osu.Game.Tests.Visual.UserInterface
2017-09-18 13:32:49 +00:00
{
2018-03-02 06:34:31 +00:00
[TestFixture]
2020-01-02 05:24:58 +00:00
public partial class TestSceneBreadcrumbControl : OsuTestScene
2017-09-18 13:32:49 +00:00
{
2020-01-27 04:16:36 +00:00
private readonly TestBreadcrumbControl breadcrumbs;
2018-04-13 09:19:50 +00:00
2020-01-02 05:24:58 +00:00
public TestSceneBreadcrumbControl()
2017-09-18 13:32:49 +00:00
{
2020-01-27 04:16:36 +00:00
Add(breadcrumbs = new TestBreadcrumbControl
2017-09-18 13:32:49 +00:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Width = 0.5f,
});
2018-04-13 09:19:50 +00:00
AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click);
2020-01-27 04:16:36 +00:00
assertVisible(1);
AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The);
2020-01-27 04:16:36 +00:00
assertVisible(2);
AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles);
2020-01-27 04:16:36 +00:00
assertVisible(3);
}
2018-04-13 09:19:50 +00:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
breadcrumbs.StripColour = colours.Blue;
2017-09-18 13:32:49 +00:00
}
2018-04-13 09:19:50 +00:00
2020-01-27 04:16:36 +00:00
private void assertVisible(int count) => AddAssert($"first {count} item(s) visible", () =>
{
for (int i = 0; i < count; i++)
{
if (breadcrumbs.GetDrawable((BreadcrumbTab)i).State != Visibility.Visible)
return false;
}
return true;
});
2017-09-18 13:32:49 +00:00
private enum BreadcrumbTab
{
Click,
The,
Circles,
}
2020-01-27 04:16:36 +00:00
private partial class TestBreadcrumbControl : BreadcrumbControl<BreadcrumbTab>
{
public BreadcrumbTabItem GetDrawable(BreadcrumbTab tab) => (BreadcrumbTabItem)TabContainer.First(t => t.Value == tab);
}
2017-09-18 13:32:49 +00:00
}
}