From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- testfiles/src/style-elem-test.cpp | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 testfiles/src/style-elem-test.cpp (limited to 'testfiles/src/style-elem-test.cpp') diff --git a/testfiles/src/style-elem-test.cpp b/testfiles/src/style-elem-test.cpp new file mode 100644 index 0000000..edf448e --- /dev/null +++ b/testfiles/src/style-elem-test.cpp @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Test the API to the style element, access, read and write functions. + *//* + * + * Authors: + * Martin Owens + * + * Copyright (C) 2018 Authors + * + * Released under GNU GPL version 2 or later, read the file 'COPYING' for more information + */ + +#include +#include + +#include +#include +#include + +using namespace Inkscape; +using namespace Inkscape::XML; + +class ObjectTest: public DocPerCaseTest { +public: + ObjectTest() { + char const *docString = "\ +\ +\ +\ +"; + doc.reset(SPDocument::createNewDocFromMem(docString, static_cast(strlen(docString)), false)); + } + + ~ObjectTest() override = default; + + std::unique_ptr doc; +}; + +/* + * Test sp-style-element objects created in document. + */ +TEST_F(ObjectTest, StyleElems) { + ASSERT_TRUE(doc != nullptr); + ASSERT_TRUE(doc->getRoot() != nullptr); + + SPRoot *root = doc->getRoot(); + ASSERT_TRUE(root->getRepr() != nullptr); + + SPStyleElem *one = dynamic_cast(doc->getObjectById("style01")); + ASSERT_TRUE(one != nullptr); + + for (auto &style : one->get_styles()) { + EXPECT_EQ(style->fill.get_value(), Glib::ustring("#ff0000")); + } + + SPStyleElem *two = dynamic_cast(doc->getObjectById("style02")); + ASSERT_TRUE(one != nullptr); + + for (auto &style : two->get_styles()) { + EXPECT_EQ(style->fill.get_value(), Glib::ustring("#008000")); + } +} -- cgit v1.2.3