mirror of
https://github.com/ppy/osu
synced 2025-01-12 00:59:35 +00:00
Add test
This commit is contained in:
parent
852e622f02
commit
431b1489b9
@ -1,9 +1,11 @@
|
||||
// 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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
@ -12,11 +14,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[TestFixture]
|
||||
public class TestSceneBreadcrumbControl : OsuTestScene
|
||||
{
|
||||
private readonly BreadcrumbControl<BreadcrumbTab> breadcrumbs;
|
||||
private readonly TestBreadcrumbControl breadcrumbs;
|
||||
|
||||
public TestSceneBreadcrumbControl()
|
||||
{
|
||||
Add(breadcrumbs = new BreadcrumbControl<BreadcrumbTab>
|
||||
Add(breadcrumbs = new TestBreadcrumbControl
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -25,8 +27,13 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
});
|
||||
|
||||
AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click);
|
||||
assertVisible(1);
|
||||
|
||||
AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The);
|
||||
assertVisible(2);
|
||||
|
||||
AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles);
|
||||
assertVisible(3);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -35,11 +42,27 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
breadcrumbs.StripColour = colours.Blue;
|
||||
}
|
||||
|
||||
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;
|
||||
});
|
||||
|
||||
private enum BreadcrumbTab
|
||||
{
|
||||
Click,
|
||||
The,
|
||||
Circles,
|
||||
}
|
||||
|
||||
private class TestBreadcrumbControl : BreadcrumbControl<BreadcrumbTab>
|
||||
{
|
||||
public BreadcrumbTabItem GetDrawable(BreadcrumbTab tab) => (BreadcrumbTabItem)TabContainer.First(t => t.Value == tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
};
|
||||
}
|
||||
|
||||
protected class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
|
||||
public class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
|
||||
{
|
||||
protected virtual float ChevronSize => 10;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user