四个方向 分块渲染
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
#include <tuple>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
@@ -346,10 +347,11 @@ TEST(RenderiveWebGallery, AdminiveResourcesPatchTheRealRenderableState) {
|
||||
|
||||
response = response_json(session.handle(gallery_request(
|
||||
Gallery_Request_Kind::Patch,
|
||||
R"({"category":"event","type":"gallery_patch","target":"spectrum","patch":{"frequency_point_size":1024,"frequency_range":{"origin":90000000},"current_pen":{"color":"#ff8844"},"interpolation_mode":"Cubic_Value"}})")));
|
||||
R"({"category":"event","type":"gallery_patch","target":"spectrum","patch":{"frequency_point_size":1024,"partition_count":4,"frequency_range":{"origin":90000000},"current_pen":{"color":"#ff8844"},"interpolation_mode":"Cubic_Value"}})")));
|
||||
ASSERT_EQ(response.at("type"), "case_state");
|
||||
const auto& updated = find_resource(response, "spectrum").at("data");
|
||||
EXPECT_EQ(updated.at("frequency_point_size"), 1024);
|
||||
EXPECT_EQ(updated.at("partition_count"), 4);
|
||||
EXPECT_EQ(updated.at("frequency_range").at("origin"), 90'000'000);
|
||||
EXPECT_EQ(updated.at("current_pen").at("color"), "#ff8844");
|
||||
EXPECT_EQ(updated.at("interpolation_mode"), "Cubic_Value");
|
||||
@@ -365,6 +367,88 @@ TEST(RenderiveWebGallery, AdminiveResourcesPatchTheRealRenderableState) {
|
||||
EXPECT_EQ(foreign.at("type"), "error");
|
||||
}
|
||||
|
||||
TEST(RenderiveWebGallery, AxisSwapAndEveryPlotDirectionAreEditableAndRenderable) {
|
||||
const auto patch = [](Gallery_Plot_Session& session, std::string_view target,
|
||||
nlohmann::json value) {
|
||||
nlohmann::json request{{"category", "event"}, {"type", "gallery_patch"},
|
||||
{"target", target}, {"patch", std::move(value)}};
|
||||
return response_json(session.handle(gallery_request(
|
||||
Gallery_Request_Kind::Patch, request.dump())));
|
||||
};
|
||||
const auto resource_data = [](const nlohmann::json& state, std::string_view target)
|
||||
-> const nlohmann::json& {
|
||||
const auto& resources = state.at("controls").at("resources");
|
||||
const auto found = std::find_if(resources.begin(), resources.end(),
|
||||
[target](const auto& resource) {
|
||||
return resource.at("target").template get<std::string>() == target;
|
||||
});
|
||||
if (found == resources.end())
|
||||
throw std::out_of_range("missing gallery resource");
|
||||
return found->at("data");
|
||||
};
|
||||
|
||||
for (const std::string_view case_id : {"spectrum", "afterglow"}) {
|
||||
Gallery_Plot_Session session;
|
||||
auto state = response_json(session.handle(gallery_request(
|
||||
Gallery_Request_Kind::Open, open_message(case_id, "manual"))));
|
||||
ASSERT_EQ(state.at("type"), "case_state");
|
||||
state = patch(session, "frequency_axis",
|
||||
{{"orientation", "Vertical"},
|
||||
{"coordinates", {{"origin", 108'000'000.0},
|
||||
{"target", 88'000'000.0}}}});
|
||||
ASSERT_EQ(state.at("type"), "case_state");
|
||||
state = patch(session, "value_axis",
|
||||
{{"orientation", "Horizontal"},
|
||||
{"coordinates", {{"origin", -20.0}, {"target", -120.0}}}});
|
||||
ASSERT_EQ(state.at("type"), "case_state");
|
||||
state = patch(session, case_id, {{"partition_count", 4}});
|
||||
ASSERT_EQ(state.at("type"), "case_state");
|
||||
EXPECT_EQ(resource_data(state, "frequency_axis").at("orientation"), "Vertical");
|
||||
EXPECT_EQ(resource_data(state, "value_axis").at("orientation"), "Horizontal");
|
||||
EXPECT_EQ(resource_data(state, case_id).at("partition_count"), 4);
|
||||
}
|
||||
|
||||
Gallery_Plot_Session waterfall;
|
||||
auto state = response_json(waterfall.handle(gallery_request(
|
||||
Gallery_Request_Kind::Open, open_message("waterfall", "manual"))));
|
||||
ASSERT_EQ(state.at("type"), "case_state");
|
||||
state = patch(waterfall, "frequency_axis",
|
||||
{{"orientation", "Vertical"},
|
||||
{"coordinates", {{"origin", 108'000'000.0},
|
||||
{"target", 88'000'000.0}}}});
|
||||
ASSERT_EQ(state.at("type"), "case_state");
|
||||
state = patch(waterfall, "time_axis",
|
||||
{{"orientation", "Horizontal"}, {"newest_at_start", true}});
|
||||
ASSERT_EQ(state.at("type"), "case_state");
|
||||
state = patch(waterfall, "waterfall", {{"partition_count", 4}});
|
||||
ASSERT_EQ(state.at("type"), "case_state");
|
||||
EXPECT_EQ(resource_data(state, "frequency_axis").at("orientation"), "Vertical");
|
||||
EXPECT_EQ(resource_data(state, "time_axis").at("orientation"), "Horizontal");
|
||||
EXPECT_TRUE(resource_data(state, "time_axis").at("newest_at_start"));
|
||||
EXPECT_EQ(resource_data(state, "waterfall").at("partition_count"), 4);
|
||||
|
||||
for (const auto& [frequency_orientation, time_orientation, newest_at_start] :
|
||||
std::array{
|
||||
std::tuple{"Horizontal", "Vertical", false},
|
||||
std::tuple{"Horizontal", "Vertical", true},
|
||||
std::tuple{"Vertical", "Horizontal", false},
|
||||
std::tuple{"Vertical", "Horizontal", true}}) {
|
||||
state = patch(waterfall, "frequency_axis",
|
||||
{{"orientation", frequency_orientation}});
|
||||
ASSERT_EQ(state.at("type"), "case_state");
|
||||
state = patch(waterfall, "time_axis",
|
||||
{{"orientation", time_orientation},
|
||||
{"newest_at_start", newest_at_start}});
|
||||
ASSERT_EQ(state.at("type"), "case_state");
|
||||
EXPECT_EQ(resource_data(state, "frequency_axis").at("orientation"),
|
||||
frequency_orientation);
|
||||
EXPECT_EQ(resource_data(state, "time_axis").at("orientation"),
|
||||
time_orientation);
|
||||
EXPECT_EQ(resource_data(state, "time_axis").at("newest_at_start"),
|
||||
newest_at_start);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(RenderiveWebGallery, EveryPublishedActionDispatchesToItsCanvasAndFrameMode) {
|
||||
constexpr std::array<std::string_view, 8> cases{
|
||||
"axis_lab", "spectrum", "afterglow", "sweep_spectrum",
|
||||
|
||||
Reference in New Issue
Block a user