some other tests
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 20s
Create tag and build when new code gets to main / Export (push) Successful in 5m5s

This commit is contained in:
2026-02-23 15:22:57 +01:00
parent a4873f183c
commit de41bbeb8d
5 changed files with 109 additions and 5 deletions

9
.gitignore vendored
View File

@@ -15,4 +15,11 @@
# Imported translations (automatically generated from CSV files)
*.translation
.output.txt
.output.txt
*.suo
*.user
_ReSharper.*
bin
obj
packages

View File

@@ -0,0 +1,50 @@
using System.Threading.Tasks;
using Godot;
using GodotStateCharts;
namespace Movementtests.tests;
using GdUnit4;
using static GdUnit4.Assertions;
[TestSuite, RequireGodotRuntime]
public class PlayerInteractionsTest
{
private ISceneRunner _runner;
private Node _scene;
private PlayerController _player;
private readonly float _tolerance = 0.01f;
private readonly Vector3 _vectorTolerance = new Vector3(0.01f, 0.01f, 0.01f);
[BeforeTest]
public void SetupTest()
{
_runner = ISceneRunner.Load("res://tests/player/interactions/player_interactions_scene.tscn");
_scene = _runner.Scene()!;
var player = _scene.FindChild("Player") as PlayerController;
_player = player!;
}
[AfterTest]
public void CleanupTest() {}
[TestCase("BaseLocation")]
public async Task PlayerMoveForward(string markerName)
{
var marker = _scene.FindChild(markerName) as Marker3D;
AssertObject(marker).IsNotNull();
_player.GlobalPosition = marker!.GlobalPosition;
await _runner.AwaitIdleFrame();
var startPos = _player.GlobalPosition;
_runner.SimulateKeyPress(Key.W);
await _runner.AwaitMillis(300);
_runner.SimulateKeyRelease(Key.W);
var endPos = _player.GlobalPosition;
var direction = startPos.DirectionTo(endPos);
AssertVector(direction).IsEqualApprox(Vector3.Forward, _vectorTolerance);
}
}

View File

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

View File

@@ -0,0 +1,35 @@
[gd_scene format=3 uid="uid://l0lflvsjbyvs"]
[ext_resource type="Material" uid="uid://31aulub2nqov" path="res://assets/materials/greybox/m_greybox.tres" id="1_dv0re"]
[ext_resource type="PackedScene" uid="uid://bei4nhkf8lwdo" path="res://scenes/player_controller/PlayerController.tscn" id="2_52d52"]
[node name="PlayerMovementScene" type="Node3D" unique_id=231040688]
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="." unique_id=241909240]
use_collision = true
collision_layer = 256
collision_mask = 65553
[node name="Ground" type="CSGBox3D" parent="CSGCombiner3D" unique_id=432200143]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, -0.5, -3.25)
use_collision = true
collision_layer = 256
collision_mask = 65553
size = Vector3(1000, 1, 1000)
material = ExtResource("1_dv0re")
[node name="Ground2" type="CSGBox3D" parent="CSGCombiner3D" unique_id=854660236]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.75, 0.5, -1.75)
use_collision = true
collision_layer = 256
collision_mask = 65553
size = Vector3(1.5, 1, 1.5)
material = ExtResource("1_dv0re")
[node name="Player" parent="." unique_id=709076448 instance=ExtResource("2_52d52")]
TutorialDone = true
[node name="BaseLocation" type="Marker3D" parent="." unique_id=1793710692]
[node name="MantleLocation1" type="Marker3D" parent="." unique_id=550080845]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.75, 0, 0)

View File

@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Godot;
using GodotStateCharts;
namespace Movementtests.tests;
@@ -44,7 +45,7 @@ public class PlayerMovementTest
var startPos = _player.GlobalPosition;
_runner.SimulateKeyPress(Key.W);
await _runner.AwaitMillis(300);
await _runner.AwaitMillis(100);
_runner.SimulateKeyRelease(Key.W);
var endPos = _player.GlobalPosition;
@@ -63,17 +64,24 @@ public class PlayerMovementTest
var startPos = _player.GlobalPosition;
_runner.SimulateKeyPress(Key.Space);
await _runner.AwaitMillis(100);
_runner.SimulateKeyRelease(Key.Space);
await _runner.AwaitIdleFrame();
var jumping = StateChartState.Of(_player.GetNode("StateChart/Root/Movement/Jump"));
AssertBool(jumping.Active).IsTrue();
_runner.SimulateKeyRelease(Key.Space);
await _runner.AwaitIdleFrame();
var endPos = _player.GlobalPosition;
var direction = startPos.DirectionTo(endPos);
AssertVector(direction).IsEqualApprox(Vector3.Up, _vectorTolerance);
AssertVector(_player.Velocity.Normalized()).IsEqualApprox(Vector3.Up, _vectorTolerance);
await _runner.AwaitMillis(500);
await _runner.AwaitMillis(600);
endPos = _player.GlobalPosition;
AssertVector(endPos - startPos).IsEqualApprox(Vector3.Zero, _vectorTolerance);
var grounded = StateChartState.Of(_player.GetNode("StateChart/Root/Movement/Grounded"));
AssertBool(grounded.Active).IsTrue();
}
[TestCase("MantleLocation1")]
@@ -88,6 +96,9 @@ public class PlayerMovementTest
_runner.SimulateKeyPress(Key.Space);
await _runner.AwaitMillis(100);
var mantling = StateChartState.Of(_player.GetNode("StateChart/Root/Movement/Mantling"));
AssertBool(mantling.Active).IsTrue();
_runner.SimulateKeyRelease(Key.Space);
await _runner.AwaitMillis(500);