1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Make toolbar testable and add the most basic of visual tests

This commit is contained in:
Dean Herbert 2017-12-26 01:12:46 +09:00
parent 45e4c09cb8
commit dff082ed94
10 changed files with 42 additions and 10 deletions

View File

@ -0,0 +1,25 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays.Toolbar;
namespace osu.Game.Tests.Visual
{
public class TestCaseToolbar : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ToolbarButton),
typeof(ToolbarModeSelector),
typeof(ToolbarModeButton),
};
public TestCaseToolbar()
{
Add(new Toolbar { State = Visibility.Visible });
}
}
}

View File

@ -148,6 +148,7 @@
<Compile Include="Visual\TestCaseStoryboard.cs" />
<Compile Include="Visual\TestCaseTabControl.cs" />
<Compile Include="Visual\TestCaseTextAwesome.cs" />
<Compile Include="Visual\TestCaseToolbar.cs" />
<Compile Include="Visual\TestCaseTwoLayerButton.cs" />
<Compile Include="Visual\TestCaseUserPanel.cs" />
<Compile Include="Visual\TestCaseUserProfile.cs" />

View File

@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar
SetIcon(FontAwesome.fa_comments);
}
[BackgroundDependencyLoader]
[BackgroundDependencyLoader(true)]
private void load(ChatOverlay chat)
{
StateContainer = chat;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar
SetIcon(FontAwesome.fa_osu_chevron_down_o);
}
[BackgroundDependencyLoader]
[BackgroundDependencyLoader(true)]
private void load(DirectOverlay direct)
{
StateContainer = direct;

View File

@ -64,7 +64,7 @@ namespace osu.Game.Overlays.Toolbar
};
}
[BackgroundDependencyLoader]
[BackgroundDependencyLoader(true)]
private void load(RulesetStore rulesets, OsuGame game)
{
foreach (var r in rulesets.AvailableRulesets)
@ -81,7 +81,10 @@ namespace osu.Game.Overlays.Toolbar
ruleset.ValueChanged += rulesetChanged;
ruleset.DisabledChanged += disabledChanged;
ruleset.BindTo(game.Ruleset);
if (game != null)
ruleset.BindTo(game.Ruleset);
else
ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault();
}
public override bool HandleInput => !ruleset.Disabled;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar
Icon = FontAwesome.fa_music;
}
[BackgroundDependencyLoader]
[BackgroundDependencyLoader(true)]
private void load(MusicController music)
{
StateContainer = music;

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Toolbar
TooltipSub = "Waiting for 'ya";
}
[BackgroundDependencyLoader]
[BackgroundDependencyLoader(true)]
private void load(NotificationOverlay notificationOverlay)
{
StateContainer = notificationOverlay;

View File

@ -21,8 +21,11 @@ namespace osu.Game.Overlays.Toolbar
set
{
stateContainer = value;
Action = stateContainer.ToggleVisibility;
stateContainer.StateChanged += stateChanged;
if (stateContainer != null)
{
Action = stateContainer.ToggleVisibility;
stateContainer.StateChanged += stateChanged;
}
}
}

View File

@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Toolbar
TooltipSub = "Change your settings";
}
[BackgroundDependencyLoader]
[BackgroundDependencyLoader(true)]
private void load(SettingsOverlay settings)
{
StateContainer = settings;

View File

@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Toolbar
Icon = FontAwesome.fa_users;
}
[BackgroundDependencyLoader]
[BackgroundDependencyLoader(true)]
private void load(SocialOverlay chat)
{
StateContainer = chat;