#include "CppUnitTest.h" #include #include #include "ElementRendererTest.h" #include "Renderer/Painting/ElementStyle.h" using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace Renderer; namespace UnitTest { void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg); TEST_CLASS(ElementRendererStokeTypeTest) { private: char* argv[1]; int argc; public: ElementRendererStokeTypeTest() :argv{ (char*)"" }, argc(1) {} TEST_METHOD_INITIALIZE(initialize) { qInstallMessageHandler(messageHandler); QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); } TEST_METHOD(TestBothSidesRound) { QApplication a(argc, argv); class StyleStrokeRadialGradient : public Renderer::ElementStyle { virtual std::vector toBaseStyles() const override { std::map materialMap = { {0.20, Material{QColor(255,255,255)}}, {0.60, Material{QColor(165,176,207)}}, {1.00, Material{QColor(58,64,151)}} }; return { BaseStyle(std::make_shared(), std::make_shared(60, StrokeType::kBothSides, StrokeEndType::kRound, std::make_shared(materialMap, false))) }; } } style; TestGLWidget w(style); w.show(); a.exec(); } TEST_METHOD(TestBothSidesFlat) { QApplication a(argc, argv); class StyleStrokeRadialGradient : public Renderer::ElementStyle { virtual std::vector toBaseStyles() const override { std::map materialMap = { {0.20, Material{QColor(255,255,255)}}, {0.60, Material{QColor(165,176,207)}}, {1.00, Material{QColor(58,64,151)}} }; return { BaseStyle(std::make_shared(), std::make_shared(60, StrokeType::kBothSides, StrokeEndType::kFlat, std::make_shared(materialMap, false))) }; } } style; TestGLWidget w(style); w.show(); a.exec(); } TEST_METHOD(TestLeftSideRound) { QApplication a(argc, argv); class StyleStrokeRadialGradient : public Renderer::ElementStyle { virtual std::vector toBaseStyles() const override { std::map materialMap = { {0.20, Material{QColor(255,255,255)}}, {0.60, Material{QColor(165,176,207)}}, {1.00, Material{QColor(58,64,151)}} }; return { BaseStyle(std::make_shared(), std::make_shared(60, StrokeType::kLeftSide, StrokeEndType::kRound, std::make_shared(materialMap, false))) }; } } style; TestGLWidget w(style); w.show(); a.exec(); } TEST_METHOD(TestLeftSideFlat) { QApplication a(argc, argv); class StyleStrokeRadialGradient : public Renderer::ElementStyle { virtual std::vector toBaseStyles() const override { std::map materialMap = { {0.20, Material{QColor(255,255,255)}}, {0.60, Material{QColor(165,176,207)}}, {1.00, Material{QColor(58,64,151)}} }; return { BaseStyle(std::make_shared(), std::make_shared(60, StrokeType::kLeftSide, StrokeEndType::kFlat, std::make_shared(materialMap, false))) }; } } style; TestGLWidget w(style); w.show(); a.exec(); } TEST_METHOD(TestRightSideFlat) { QApplication a(argc, argv); class StyleStrokeRadialGradient : public Renderer::ElementStyle { virtual std::vector toBaseStyles() const override { std::map materialMap = { {0.20, Material{QColor(255,255,255)}}, {0.60, Material{QColor(165,176,207)}}, {1.00, Material{QColor(58,64,151)}} }; return { BaseStyle(std::make_shared(), std::make_shared(200, StrokeType::kRightSide, StrokeEndType::kFlat, std::make_shared(materialMap, false))) }; } } style; TestGLWidget w(style); w.show(); a.exec(); } }; TEST_CLASS(ElementRendererStokeMaterialTest) { private: char* argv[1]; int argc; public: ElementRendererStokeMaterialTest() :argv{ (char*)"" }, argc(1) {} TEST_METHOD(TestStrokePlain) { QApplication a(argc, argv); class StyleStrokePlain : public Renderer::ElementStyle { virtual std::vector toBaseStyles() const override { return { BaseStyle(std::make_shared(), std::make_shared(60, StrokeType::kBothSides, StrokeEndType::kRound, std::make_shared(QColor(255,255,255),1,1))) }; } } style; TestGLWidget w(style); w.show(); a.exec(); } TEST_METHOD(TestStrokeRadialGradient1) { QApplication a(argc, argv); class StyleStrokeRadialGradient : public Renderer::ElementStyle { virtual std::vector toBaseStyles() const override { std::map materialMap = { {0.20, Material{QColor(255,255,255)}}, {0.60, Material{QColor(165,176,207)}}, {1.00, Material{QColor(58,64,151)}} }; return { BaseStyle(std::make_shared(), std::make_shared(60, StrokeType::kBothSides, StrokeEndType::kRound, std::make_shared(materialMap, false))) }; } } style; TestGLWidget w(style); w.show(); a.exec(); } TEST_METHOD(TestStrokeRadialGradient2) { QApplication a(argc, argv); class StyleStrokeRadialGradient : public Renderer::ElementStyle { virtual std::vector toBaseStyles() const override { std::map materialMap = { {0.00, Material{QColor(255,255,255)}}, {0.50, Material{QColor(165,176,207)}}, {1.00, Material{QColor(58,64,151)}} }; return { BaseStyle(std::make_shared(), std::make_shared(30, StrokeType::kBothSides, StrokeEndType::kRound, std::make_shared(materialMap, true))) }; } } style; TestGLWidget w(style); w.show(); a.exec(); } }; }