// 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); }