mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add test
This commit is contained in:
@ -1,9 +1,11 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
@ -12,11 +14,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneBreadcrumbControl : OsuTestScene
|
public class TestSceneBreadcrumbControl : OsuTestScene
|
||||||
{
|
{
|
||||||
private readonly BreadcrumbControl<BreadcrumbTab> breadcrumbs;
|
private readonly TestBreadcrumbControl breadcrumbs;
|
||||||
|
|
||||||
public TestSceneBreadcrumbControl()
|
public TestSceneBreadcrumbControl()
|
||||||
{
|
{
|
||||||
Add(breadcrumbs = new BreadcrumbControl<BreadcrumbTab>
|
Add(breadcrumbs = new TestBreadcrumbControl
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -25,8 +27,13 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click);
|
AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click);
|
||||||
|
assertVisible(1);
|
||||||
|
|
||||||
AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The);
|
AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The);
|
||||||
|
assertVisible(2);
|
||||||
|
|
||||||
AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles);
|
AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles);
|
||||||
|
assertVisible(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -35,11 +42,27 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
breadcrumbs.StripColour = colours.Blue;
|
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
|
private enum BreadcrumbTab
|
||||||
{
|
{
|
||||||
Click,
|
Click,
|
||||||
The,
|
The,
|
||||||
Circles,
|
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;
|
protected virtual float ChevronSize => 10;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user