Files
SEQUA-Engine/3d/tests/test_null_adapter.cpp
Ange-Marie MAURIN - A2M Systèmes 3f36b98c71 feat(3d): contrat SEQUA 3D, I3DEngineAdapter et négociation des capacités
Bibliothèque sequa::3d (espace de noms sequa::three_d), sans dépendance à un moteur : interface I3DEngineAdapter, tampons et négociation des capacités, synchronisation de la scène par deltas versionnés tout ou rien (SceneState, snapshot), demandes d'image et mesures communes. NullEngineAdapter (SIMULÉ) pour les tests. Types provisoires en attendant le format du schéma.
2026-11-07 04:37:15 +01:00

62 lines
2.0 KiB
C++

// SPDX-License-Identifier: MPL-2.0
#include "sequa/3d/null_adapter.hpp"
#include <doctest/doctest.h>
using namespace sequa::three_d;
TEST_CASE("NullEngineAdapter : cycle de vie")
{
NullEngineAdapter adapter;
CHECK_FALSE(adapter.running());
CHECK(adapter.apply({1, {}})->code == Error::Code::not_started);
EngineConfig config;
config.headless = true;
REQUIRE_FALSE(adapter.start(config));
CHECK(adapter.running());
CHECK(adapter.start(config)->code == Error::Code::already_started);
adapter.stop();
CHECK_FALSE(adapter.running());
}
TEST_CASE("NullEngineAdapter : image rendue avec la version de scene courante")
{
NullEngineAdapter adapter;
EngineConfig config;
config.headless = true;
REQUIRE_FALSE(adapter.start(config));
REQUIRE_FALSE(adapter.apply({3, {CreateObject{1, {}, {}}}}));
FrameRequest request;
request.frame_index = 42;
request.width = 640;
request.height = 360;
request.buffers = {FrameBuffer::color, FrameBuffer::depth};
const FrameOutcome outcome = adapter.render_frame(request);
REQUIRE(std::holds_alternative<FrameResult>(outcome));
const auto& result = std::get<FrameResult>(outcome);
CHECK(result.frame_index == 42);
CHECK(result.world_version == 3);
CHECK(result.produced == request.buffers);
}
TEST_CASE("NullEngineAdapter : capacites restreintes respectees")
{
NullEngineAdapter adapter(EngineCapabilities{"restreint", "0", {FrameBuffer::color}, true, false, 0, 0});
EngineConfig config;
config.headless = true;
CHECK(adapter.start(config)->code == Error::Code::unsupported);
config.headless = false;
REQUIRE_FALSE(adapter.start(config));
FrameRequest request;
request.width = 64;
request.height = 64;
request.buffers = {FrameBuffer::object_ids};
const FrameOutcome outcome = adapter.render_frame(request);
REQUIRE(std::holds_alternative<Error>(outcome));
CHECK(std::get<Error>(outcome).code == Error::Code::unsupported);
}