This commit is contained in:
2026-08-12 01:44:13 +08:00
parent 75795e43bf
commit 2fff357dff
17 changed files with 717 additions and 505 deletions
+29 -1
View File
@@ -23,6 +23,26 @@
namespace renderive::web {
namespace {
struct Spatial_Test_Event {
int layer{};
};
struct Spatial_Test_Decoder {
using event_type = Spatial_Test_Event;
static std::optional<event_type> decode(const Json::Value& root, std::string_view) {
if (root["type"].asString() != "spatial_test" || !root["layer"].isInt())
return std::nullopt;
return Spatial_Test_Event{root["layer"].asInt()};
}
};
using Extended_Web_Event = Basic_Web_Event<Event, Pointer_Event, Wheel_Event,
Key_Event, Spatial_Test_Event>;
using Extended_Web_Event_Adapter = Basic_Web_Event_Adapter<
Extended_Web_Event, Web_Transport_Event_Decoder, Render_2D_Web_Event_Decoder,
Web_Demo_Control_Decoder, Spatial_Test_Decoder>;
std::uint32_t read_u32_le(const std::string& value, std::size_t offset) {
return static_cast<std::uint8_t>(value[offset]) |
(static_cast<std::uint32_t>(static_cast<std::uint8_t>(value[offset + 1])) << 8U) |
@@ -247,6 +267,14 @@ TEST(RenderiveWebGallery, CatalogOwnsDashboardFieldsAndDynamicBehavior) {
EXPECT_TRUE(action->at("request_frame"));
}
TEST(RenderiveWebBridge, ComposesAdditionalEventDecoders) {
const auto event = Extended_Web_Event_Adapter::decode(
R"({"category":"event","type":"spatial_test","layer":7})");
ASSERT_TRUE(event.has_value());
ASSERT_TRUE(std::holds_alternative<Spatial_Test_Event>(*event));
EXPECT_EQ(std::get<Spatial_Test_Event>(*event).layer, 7);
}
TEST(RenderiveWebGallery, AdminiveResourcesPatchTheRealRenderableState) {
Gallery_Plot_Session session;
auto response = response_json(session.handle(gallery_request(
@@ -265,7 +293,7 @@ TEST(RenderiveWebGallery, AdminiveResourcesPatchTheRealRenderableState) {
};
const auto& spectrum = find_resource(response, "spectrum");
EXPECT_EQ(spectrum.at("descriptor").at("name"), "Spectrum_Properties");
EXPECT_EQ(spectrum.at("descriptor").at("name"), "Gallery_Spectrum");
EXPECT_TRUE(spectrum.at("data").at("frequency_range").is_object());
EXPECT_EQ(spectrum.at("data").at("frequency_point_size"), 512);