#include "CppUnitTest.h" #include #include #include "ElementRendererTest.h" #include "Renderer/Painting/ElementStyle.h" #include using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace Renderer; namespace UnitTest { TEST_CLASS(ElementRendererStokeTypeTest) { public: TEST_METHOD(TestFile) { QFile file("D:\\BigC2022\\temp\\ArchitectureColoredPainting\\README.md"); Logger::WriteMessage(file.open(QIODevice::ReadOnly)? "True":"False"); } TEST_METHOD(TestBothSidesRound) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); char* argv[] = { (char*)"" }; int argc = 1; 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) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); char* argv[] = { (char*)"" }; int argc = 1; 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) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); char* argv[] = { (char*)"" }; int argc = 1; 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) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); char* argv[] = { (char*)"" }; int argc = 1; 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_CLASS(ElementRendererStokeMaterialTest) { public: TEST_METHOD(TestStrokePlain) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); char* argv[] = { (char*)"" }; int argc = 1; 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) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); char* argv[] = { (char*)"" }; int argc = 1; 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) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); char* argv[] = { (char*)"" }; int argc = 1; 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(); } }; }