2023-03-23 01:44:28 +08:00
|
|
|
#include "CppUnitTest.h"
|
|
|
|
#include "Editor/LayerStyle.h"
|
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QtWidgets/QApplication>
|
|
|
|
|
|
|
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
|
|
|
|
|
|
namespace UnitTest
|
|
|
|
{
|
|
|
|
TEST_CLASS(LayerStyleContainerTest)
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
char* argv[1];
|
|
|
|
int argc;
|
|
|
|
LayerStyleContainer containerParent, containerChild;
|
|
|
|
public:
|
|
|
|
LayerStyleContainerTest() :
|
|
|
|
argv{ const_cast<char*>("") }, argc(1),
|
|
|
|
containerParent(LayerStyleContainer::TYPE_ALL),
|
|
|
|
containerChild(LayerStyleContainer::TYPE_UNCLOSED)
|
|
|
|
{
|
|
|
|
QApplication app(argc, argv);
|
|
|
|
Assert::IsTrue(containerParent.empty());
|
|
|
|
Assert::IsTrue(containerChild.empty());
|
|
|
|
|
|
|
|
auto fillStyle = containerParent.makeUnusedStyle(FillElementLayerStyle::displayName());
|
|
|
|
Assert::IsTrue(containerParent.useStyle(std::shared_ptr(std::move(fillStyle))));
|
|
|
|
Assert::IsFalse(containerParent.empty());
|
|
|
|
Assert::IsFalse(containerParent.full());
|
|
|
|
|
|
|
|
auto strokeStyle = containerParent.makeUnusedStyle(StrokeElementLayerStyle::displayName());
|
|
|
|
containerParent.useStyle(std::shared_ptr(std::move(strokeStyle)));
|
|
|
|
|
|
|
|
auto childStrokeStyle = containerChild.makeUnusedStyle(StrokeElementLayerStyle::displayName());
|
|
|
|
containerChild.useStyle(std::shared_ptr(std::move(childStrokeStyle)));
|
|
|
|
Assert::IsTrue(containerChild.full());
|
|
|
|
|
|
|
|
containerParent.computeNewHash();
|
|
|
|
containerChild.computeNewHash();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(ContainerCoverTest)
|
|
|
|
{
|
2023-03-23 15:02:44 +08:00
|
|
|
const auto& newContainer = containerParent | containerChild;
|
2023-03-23 01:44:28 +08:00
|
|
|
Assert::IsTrue(newContainer.full());
|
|
|
|
Assert::AreEqual(newContainer.getHash(), containerChild.getHash());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|