// SPDX-License-Identifier: MPL-2.0 #include "sequa/3d/null_adapter.hpp" #include 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(outcome)); const auto& result = std::get(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(outcome)); CHECK(std::get(outcome).code == Error::Code::unsupported); }