display test nodes v1
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
24
src/SharpIDE.Godot/Features/TestExplorer/TestNodeEntry.cs
Normal file
24
src/SharpIDE.Godot/Features/TestExplorer/TestNodeEntry.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cnfayblofyjwn
|
||||
22
src/SharpIDE.Godot/Features/TestExplorer/TestNodeEntry.tscn
Normal file
22
src/SharpIDE.Godot/Features/TestExplorer/TestNodeEntry.tscn
Normal 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"
|
||||
Reference in New Issue
Block a user