2023-02-08 16:34:16 +08:00
|
|
|
#include "CppUnitTest.h"
|
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QtWidgets/QApplication>
|
|
|
|
#include "ElementRendererTest.h"
|
2023-02-10 13:48:30 +08:00
|
|
|
#include "Renderer/Painting/ElementStyle.h"
|
2023-02-25 13:34:24 +08:00
|
|
|
|
2023-02-08 16:34:16 +08:00
|
|
|
|
|
|
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
2023-02-10 13:48:30 +08:00
|
|
|
using namespace Renderer;
|
2023-02-08 16:34:16 +08:00
|
|
|
|
|
|
|
namespace UnitTest
|
|
|
|
{
|
2023-03-14 23:39:56 +08:00
|
|
|
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg);
|
|
|
|
|
2023-02-15 15:37:30 +08:00
|
|
|
TEST_CLASS(ElementRendererStokeTypeTest)
|
|
|
|
{
|
2023-03-07 16:22:44 +08:00
|
|
|
private:
|
|
|
|
char* argv[1];
|
|
|
|
int argc;
|
2023-02-15 15:37:30 +08:00
|
|
|
public:
|
2023-03-07 16:22:44 +08:00
|
|
|
ElementRendererStokeTypeTest() :argv{ (char*)"" }, argc(1) {}
|
|
|
|
|
|
|
|
TEST_METHOD_INITIALIZE(initialize)
|
2023-02-15 15:37:30 +08:00
|
|
|
{
|
2023-03-14 23:39:56 +08:00
|
|
|
qInstallMessageHandler(messageHandler);
|
2023-02-15 15:37:30 +08:00
|
|
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
|
|
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
2023-03-07 16:22:44 +08:00
|
|
|
}
|
|
|
|
TEST_METHOD(TestBothSidesRound)
|
|
|
|
{
|
2023-02-15 15:37:30 +08:00
|
|
|
QApplication a(argc, argv);
|
|
|
|
class StyleStrokeRadialGradient : public Renderer::ElementStyle
|
|
|
|
{
|
|
|
|
virtual std::vector<Renderer::BaseStyle> toBaseStyles() const override
|
|
|
|
{
|
|
|
|
std::map<float, Material> 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<TransformStyle>(),
|
2023-03-16 14:48:28 +08:00
|
|
|
std::make_shared<MaterialStyleStroke>(30, StrokeType::kBothSides, StrokeEndType::kRound,
|
2023-02-15 15:37:30 +08:00
|
|
|
std::make_shared<StrokeRadialGradient>(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<Renderer::BaseStyle> toBaseStyles() const override
|
|
|
|
{
|
|
|
|
std::map<float, Material> 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<TransformStyle>(),
|
2023-03-16 14:48:28 +08:00
|
|
|
std::make_shared<MaterialStyleStroke>(30, StrokeType::kBothSides, StrokeEndType::kFlat,
|
2023-02-15 15:37:30 +08:00
|
|
|
std::make_shared<StrokeRadialGradient>(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<Renderer::BaseStyle> toBaseStyles() const override
|
|
|
|
{
|
|
|
|
std::map<float, Material> 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<TransformStyle>(),
|
2023-03-16 14:48:28 +08:00
|
|
|
std::make_shared<MaterialStyleStroke>(30, StrokeType::kLeftSide, StrokeEndType::kRound,
|
2023-02-15 15:37:30 +08:00
|
|
|
std::make_shared<StrokeRadialGradient>(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<Renderer::BaseStyle> toBaseStyles() const override
|
|
|
|
{
|
|
|
|
std::map<float, Material> 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<TransformStyle>(),
|
2023-03-16 14:48:28 +08:00
|
|
|
std::make_shared<MaterialStyleStroke>(30, StrokeType::kLeftSide, StrokeEndType::kFlat,
|
2023-02-15 15:37:30 +08:00
|
|
|
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
|
|
|
}
|
|
|
|
} style;
|
|
|
|
TestGLWidget w(style);
|
|
|
|
w.show();
|
|
|
|
a.exec();
|
|
|
|
}
|
2023-03-15 00:09:30 +08:00
|
|
|
TEST_METHOD(TestRightSideFlatRound)
|
2023-03-14 22:44:23 +08:00
|
|
|
{
|
|
|
|
QApplication a(argc, argv);
|
|
|
|
class StyleStrokeRadialGradient : public Renderer::ElementStyle
|
|
|
|
{
|
|
|
|
virtual std::vector<Renderer::BaseStyle> toBaseStyles() const override
|
|
|
|
{
|
|
|
|
std::map<float, Material> 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<TransformStyle>(),
|
2023-03-16 14:48:28 +08:00
|
|
|
std::make_shared<MaterialStyleStroke>(80, StrokeType::kRightSide, StrokeEndType::kFlatRound,
|
2023-03-14 22:44:23 +08:00
|
|
|
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
|
|
|
}
|
|
|
|
} style;
|
|
|
|
TestGLWidget w(style);
|
|
|
|
w.show();
|
|
|
|
a.exec();
|
|
|
|
}
|
2023-02-15 15:37:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
TEST_CLASS(ElementRendererStokeMaterialTest)
|
2023-02-10 13:48:30 +08:00
|
|
|
{
|
2023-03-07 16:22:44 +08:00
|
|
|
private:
|
|
|
|
char* argv[1];
|
|
|
|
int argc;
|
2023-02-10 13:48:30 +08:00
|
|
|
public:
|
2023-03-07 16:22:44 +08:00
|
|
|
ElementRendererStokeMaterialTest() :argv{ (char*)"" }, argc(1) {}
|
2023-02-10 13:48:30 +08:00
|
|
|
TEST_METHOD(TestStrokePlain)
|
|
|
|
{
|
|
|
|
QApplication a(argc, argv);
|
2023-02-15 15:37:30 +08:00
|
|
|
class StyleStrokePlain : public Renderer::ElementStyle
|
|
|
|
{
|
|
|
|
virtual std::vector<Renderer::BaseStyle> toBaseStyles() const override
|
|
|
|
{
|
|
|
|
return { BaseStyle(std::make_shared<TransformStyle>(),
|
2023-03-16 14:48:28 +08:00
|
|
|
std::make_shared<MaterialStyleStroke>(30, StrokeType::kBothSides, StrokeEndType::kRound,
|
2023-02-15 15:37:30 +08:00
|
|
|
std::make_shared<StrokePlain>(QColor(255,255,255),1,1))) };
|
|
|
|
}
|
|
|
|
} style;
|
2023-02-10 13:48:30 +08:00
|
|
|
TestGLWidget w(style);
|
|
|
|
w.show();
|
|
|
|
a.exec();
|
|
|
|
}
|
|
|
|
TEST_METHOD(TestStrokeRadialGradient1)
|
|
|
|
{
|
|
|
|
QApplication a(argc, argv);
|
|
|
|
class StyleStrokeRadialGradient : public Renderer::ElementStyle
|
|
|
|
{
|
|
|
|
virtual std::vector<Renderer::BaseStyle> toBaseStyles() const override
|
|
|
|
{
|
2023-02-15 15:37:30 +08:00
|
|
|
std::map<float, Material> materialMap = {
|
|
|
|
{0.20, Material{QColor(255,255,255)}},
|
|
|
|
{0.60, Material{QColor(165,176,207)}},
|
|
|
|
{1.00, Material{QColor(58,64,151)}}
|
2023-02-10 13:48:30 +08:00
|
|
|
};
|
|
|
|
return { BaseStyle(std::make_shared<TransformStyle>(),
|
2023-03-16 14:48:28 +08:00
|
|
|
std::make_shared<MaterialStyleStroke>(30, StrokeType::kBothSides, StrokeEndType::kRound,
|
2023-02-10 13:48:30 +08:00
|
|
|
std::make_shared<StrokeRadialGradient>(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<Renderer::BaseStyle> toBaseStyles() const override
|
|
|
|
{
|
|
|
|
std::map<float, Material> materialMap = {
|
2023-02-15 15:37:30 +08:00
|
|
|
{0.00, Material{QColor(255,255,255)}},
|
|
|
|
{0.50, Material{QColor(165,176,207)}},
|
|
|
|
{1.00, Material{QColor(58,64,151)}}
|
2023-02-10 13:48:30 +08:00
|
|
|
};
|
|
|
|
return { BaseStyle(std::make_shared<TransformStyle>(),
|
2023-02-15 15:37:30 +08:00
|
|
|
std::make_shared<MaterialStyleStroke>(30, StrokeType::kBothSides, StrokeEndType::kRound,
|
2023-02-10 13:48:30 +08:00
|
|
|
std::make_shared<StrokeRadialGradient>(materialMap, true))) };
|
|
|
|
}
|
|
|
|
} style;
|
|
|
|
TestGLWidget w(style);
|
|
|
|
w.show();
|
|
|
|
a.exec();
|
|
|
|
}
|
|
|
|
};
|
2023-02-25 10:47:27 +08:00
|
|
|
|
2023-02-08 16:34:16 +08:00
|
|
|
}
|