From c853ffb5b2f75f5a889ed2e3ef89b818a736e87a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:50:49 +0200 Subject: Adding upstream version 1.3+ds. Signed-off-by: Daniel Baumann --- testfiles/src/cairo-utils-test.cpp | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 testfiles/src/cairo-utils-test.cpp (limited to 'testfiles/src/cairo-utils-test.cpp') diff --git a/testfiles/src/cairo-utils-test.cpp b/testfiles/src/cairo-utils-test.cpp new file mode 100644 index 0000000..3412c4a --- /dev/null +++ b/testfiles/src/cairo-utils-test.cpp @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Tests for classes like Pixbuf from cairo-utils + *//* + * Authors: see git history + * + * Copyright (C) 2020 Authors + * + * Released under GNU GPL version 2 or later, read the file 'COPYING' for more information + */ + +#include +#include +#include + + +class PixbufTest : public ::testing::Test { + public: + static std::string base64of(const std::string &s) + { + gchar *encoded = g_base64_encode(reinterpret_cast(s.c_str()), s.size()); + std::string r(encoded); + g_free(encoded); + return r; + } + + protected: + void SetUp() override + { + // setup hidden dependency + Inkscape::Application::create(false); + } +}; + +TEST_F(PixbufTest, creatingFromSvgBufferWithoutViewboxOrWidthAndHeightReturnsNull) +{ + std::string svg_buffer( + ""); + double default_dpi = 96.0; + std::string filename_with_svg_extension("malformed.svg"); + + ASSERT_EQ(Inkscape::Pixbuf::create_from_buffer(svg_buffer, default_dpi, filename_with_svg_extension), nullptr); +} + +TEST_F(PixbufTest, creatingFromSvgUriWithoutViewboxOrWidthAndHeightReturnsNull) +{ + std::string uri_data = "image/svg+xml;base64," + base64of(""); + double default_dpi = 96.0; + + ASSERT_EQ(Inkscape::Pixbuf::create_from_data_uri(uri_data.c_str(), default_dpi), nullptr); +} \ No newline at end of file -- cgit v1.2.3