#include "CppUnitTest.h" #include #include #include "Renderer/Painting/ElementStyle.h" #include using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace Renderer; namespace UnitTest { TEST_CLASS(StyleTest) { public: TEST_METHOD(TestEncodeDecode) { std::map materialMap = { {0.20, Material{QColor(255,255,255)}}, {0.60, Material{QColor(165,176,207)}}, {1.00, Material{QColor(58,64,151)}} }; auto style = std::make_unique( 30, StrokeType::kBothSides, StrokeEndType::kRound, std::make_shared(materialMap, false) ); /* auto style = std::make_shared( 30, StrokeType::kBothSides, StrokeEndType::kRound, std::make_shared(Material(QColor(255, 255, 255))) );*/ std::shared_ptr decoded = MaterialStyle::decoded(style->encoded()); /* Assert::IsTrue(decoded->type() == MaterialStyleType::kStroke); Assert::IsTrue(std::static_pointer_cast(decoded)->halfWidth == 30); Assert::IsTrue(std::static_pointer_cast(decoded)->strokeType == StrokeType::kBothSides); Assert::IsTrue(std::static_pointer_cast(decoded)->endType == StrokeEndType::kRound); std::shared_ptr materialStroke = std::static_pointer_cast(decoded)->materialStroke; Assert::IsTrue(materialStroke->type() == MaterialStrokeType::kPlain); Material material = std::static_pointer_cast(materialStroke)->material; Assert::IsTrue(material == Material(QColor(255, 255, 255))); Logger::WriteMessage(std::format("({} {} {} {}), ({} {})\n", material.color.red(), material.color.green(), material.color.blue(), material.color.alpha(), material.metallic, material.roughness ).c_str());*/ Assert::IsTrue(*style == *decoded); } }; }