mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-25 23:01:09 -05:00
A slice requested after an MCP slice finished no longer marks it superseded, a slice already running when MCP asks counts as its own, and Slice All reports an invalid plate's validation message. The Preview tab shows after an MCP slice, as after the Slice button. Point settings accept [x, y] pairs, a ui_mouse move drags while a button is held, a tab can be captured, and dialog rules a client sets after the server is turned off are refused.
44 lines
1.7 KiB
C++
44 lines
1.7 KiB
C++
#include <catch2/catch_test_macros.hpp>
|
|
|
|
#include "slic3r/GUI/Mcp/McpTools.hpp"
|
|
#include "slic3r/GUI/Mcp/McpTypes.hpp"
|
|
|
|
#include "libslic3r/Config.hpp"
|
|
#include "libslic3r/Point.hpp"
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
using namespace Slic3r::GUI::Mcp;
|
|
using nlohmann::json;
|
|
|
|
TEST_CASE("setting values serialize the way their options read them back", "[Mcp]")
|
|
{
|
|
CHECK(to_config_string(json(3)) == "3");
|
|
CHECK(to_config_string(json(0.2)) == "0.2");
|
|
CHECK(to_config_string(json(true)) == "1");
|
|
CHECK(to_config_string(json("15%")) == "15%");
|
|
CHECK(to_config_string(json::array({0.4, 0.6}), "nozzle_diameter") == "0.4,0.6");
|
|
|
|
// A list of strings whose entries contain the separators survives the round trip.
|
|
const std::vector<std::string> scripts{"/usr/bin/fix --mode=a,b", "second; with a semicolon"};
|
|
Slic3r::ConfigOptionStrings parsed;
|
|
parsed.deserialize(to_config_string(json(scripts), "post_process"));
|
|
CHECK(parsed.values == scripts);
|
|
|
|
// Points as [x, y] pairs, or already in OrcaSlicer's "XxY" form.
|
|
const json area = json::array({json::array({0, 0}), json::array({220.5, 0}), "220x220", json::array({0, 220})});
|
|
Slic3r::ConfigOptionPoints points;
|
|
REQUIRE(points.deserialize(to_config_string(area, "printable_area")));
|
|
REQUIRE(points.values.size() == 4);
|
|
CHECK(points.values[1] == Slic3r::Vec2d(220.5, 0));
|
|
CHECK(points.values[2] == Slic3r::Vec2d(220, 220));
|
|
CHECK(to_config_string(json::array({10, 20}), "bed_mesh_min") == "10x20");
|
|
// A string is already in OrcaSlicer's format, list options included.
|
|
CHECK(to_config_string(json("a.py;b.py"), "post_process") == "a.py;b.py");
|
|
|
|
CHECK_THROWS_AS(to_config_string(json::object()), ToolFailure);
|
|
}
|