Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BUI ctor tests #31463

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Content.Client/UserInterface/Controls/ProgressTextureRect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ public sealed class ProgressTextureRect : TextureRect
{
public float Progress;

private readonly ProgressColorSystem _progressColor = IoCManager.Resolve<IEntityManager>().System<ProgressColorSystem>();
private readonly ProgressColorSystem _progressColor;

public ProgressTextureRect()
{
_progressColor = IoCManager.Resolve<IEntityManager>().System<ProgressColorSystem>();
}

protected override void Draw(DrawingHandleScreen handle)
{
Expand Down
58 changes: 58 additions & 0 deletions Content.IntegrationTests/Tests/UserInterface/UiControlTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Linq;
using Content.Client.Chat.UI;
using Content.Client.LateJoin;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.ContentPack;
using Robust.Shared.IoC;
using Robust.Shared.Reflection;

namespace Content.IntegrationTests.Tests.UserInterface;

[TestFixture]
public sealed class UiControlTest
{
// You should not be adding to this.
private Type[] _ignored = new Type[]
{
typeof(EmotesMenu),
typeof(LateJoinGui),
};

/// <summary>
/// Tests that all windows can be instantiated successfully.
/// </summary>
[Test]
public async Task TestWindows()
{
var pair = await PoolManager.GetServerClient(new PoolSettings()
{
Connected = true,
});
var activator = pair.Client.ResolveDependency<IDynamicTypeFactory>();
var refManager = pair.Client.ResolveDependency<IReflectionManager>();
var loader = pair.Client.ResolveDependency<IModLoader>();

await pair.Client.WaitAssertion(() =>
{
foreach (var type in refManager.GetAllChildren(typeof(BaseWindow)))
{
if (type.IsAbstract || _ignored.Contains(type))
continue;

if (!loader.IsContentType(type))
continue;

// If it has no empty ctor then skip it instead of figuring out what args it needs.
var ctor = type.GetConstructor(Type.EmptyTypes);

if (ctor == null)
continue;

// Don't inject because the control themselves have to do it.
activator.CreateInstance(type, oneOff: true, inject: false);
}
});

await pair.CleanReturnAsync();
}
}
Loading