display test nodes v1

This commit is contained in:
Matt Parker
2025-11-04 19:56:28 +10:00
parent 908495d2dd
commit d5e76011b2
6 changed files with 85 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ public class TestRunnerService
{
public async Task<List<TestNode>> DiscoverTests(SharpIdeSolutionModel solutionModel)
{
await Task.WhenAll(solutionModel.AllProjects.Select(s => s.MsBuildEvaluationProjectTask));
var testProjects = solutionModel.AllProjects.Where(p => p.IsMtpTestProject).ToList();
List<TestNode> allDiscoveredTestNodes = [];
foreach (var testProject in testProjects)

View File

@@ -1,7 +1,42 @@
using Godot;
using SharpIDE.Application.Features.Testing;
namespace SharpIDE.Godot.Features.TestExplorer;
public partial class TestExplorerPanel : Control
{
[Inject] private readonly SharpIdeSolutionAccessor _solutionAccessor = null!;
[Inject] private readonly TestRunnerService _testRunnerService = null!;
private readonly PackedScene _testNodeEntryScene = ResourceLoader.Load<PackedScene>("uid://dt50f2of66dlt");
private VBoxContainer _testNodesVBoxContainer = null!;
public override void _Ready()
{
_testNodesVBoxContainer = GetNode<VBoxContainer>("%TestNodesVBoxContainer");
_ = Task.GodotRun(AsyncReady);
}
private async Task AsyncReady()
{
await _solutionAccessor.SolutionReadyTcs.Task;
var solution = _solutionAccessor.SolutionModel!;
var testNodes = await _testRunnerService.DiscoverTests(solution);
testNodes.ForEach(s => GD.Print(s.DisplayName));
var scenes = testNodes.Select(s =>
{
var entry = _testNodeEntryScene.Instantiate<TestNodeEntry>();
entry.TestNode = s;
return entry;
});
await this.InvokeAsync(() =>
{
_testNodesVBoxContainer.QueueFreeChildren();
foreach (var scene in scenes)
{
_testNodesVBoxContainer.AddChild(scene);
}
});
}
}

View File

@@ -61,7 +61,8 @@ placeholder_text = "Search for a test"
layout_mode = 2
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/MarginContainer2/HSplitContainer/VBoxContainer/ScrollContainer"]
[node name="TestNodesVBoxContainer" type="VBoxContainer" parent="VBoxContainer/MarginContainer2/HSplitContainer/VBoxContainer/ScrollContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3

View File

@@ -0,0 +1,24 @@
using Godot;
using SharpIDE.Application.Features.Testing.Client.Dtos;
namespace SharpIDE.Godot.Features.TestExplorer;
public partial class TestNodeEntry : MarginContainer
{
private Label _testNameLabel = null!;
public TestNode TestNode { get; set; } = null!;
public override void _Ready()
{
_testNameLabel = GetNode<Label>("%TestNameLabel");
_testNameLabel.Text = string.Empty;
SetValues();
}
public void SetValues()
{
if (TestNode == null) return;
_testNameLabel.Text = TestNode.DisplayName;
}
}

View File

@@ -0,0 +1 @@
uid://cnfayblofyjwn

View File

@@ -0,0 +1,22 @@
[gd_scene load_steps=2 format=3 uid="uid://dt50f2of66dlt"]
[ext_resource type="Script" uid="uid://cnfayblofyjwn" path="res://Features/TestExplorer/TestNodeEntry.cs" id="1_p16jw"]
[node name="TestNodeEntry" type="MarginContainer"]
anchors_preset = 14
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_top = -11.5
offset_bottom = 11.5
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_p16jw")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="TestNameLabel" type="Label" parent="HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Test Name"