/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include #include #include #include #include #include #include #include #include #include #include namespace { using namespace css::uno; using namespace css::io; using namespace css::graphic; using namespace drawinglayer; using namespace drawinglayer::primitive2d; class Test : public test::BootstrapFixture { void testStyles(); Primitive2DSequence parseSvg(const char* aSource); public: virtual void setUp() SAL_OVERRIDE; virtual void tearDown() SAL_OVERRIDE; CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testStyles); CPPUNIT_TEST_SUITE_END(); }; Primitive2DSequence Test::parseSvg(const char* aSource) { const Reference xSvgParser = SvgTools::create(m_xContext); OUString aUrl = getURLFromSrc(aSource); OUString aPath = getPathFromSrc(aSource); SvFileStream aFileStream(aUrl, STREAM_READ); sal_Size nSize = aFileStream.remainingSize(); boost::scoped_array pBuffer(new sal_Int8[nSize + 1]); aFileStream.Read(pBuffer.get(), nSize); pBuffer[nSize] = 0; Sequence aData(pBuffer.get(), nSize + 1); Reference aInputStream(new comphelper::SequenceInputStream(aData)); return xSvgParser->getDecomposition(aInputStream, aPath); } void Test::setUp() { BootstrapFixture::setUp(); } void Test::tearDown() { BootstrapFixture::tearDown(); } void Test::testStyles() { Primitive2DSequence maSequenceRect = parseSvg("/svgio/qa/cppunit/data/Rect.svg"); CPPUNIT_ASSERT_EQUAL(1, (int) maSequenceRect.getLength()); Primitive2DSequence maSequenceRectWithStyle = parseSvg("/svgio/qa/cppunit/data/RectWithStyles.svg"); CPPUNIT_ASSERT_EQUAL(1, (int) maSequenceRectWithStyle.getLength()); Primitive2DSequence maSequenceRectWithParentStyle = parseSvg("/svgio/qa/cppunit/data/RectWithParentStyles.svg"); CPPUNIT_ASSERT_EQUAL(1, (int) maSequenceRectWithParentStyle.getLength()); Primitive2DSequence maSequenceRectWithStylesByGroup = parseSvg("/svgio/qa/cppunit/data/RectWithStylesByGroup.svg"); CPPUNIT_ASSERT_EQUAL(1, (int) maSequenceRectWithStylesByGroup.getLength()); CPPUNIT_ASSERT_EQUAL(true, (bool) arePrimitive2DSequencesEqual(maSequenceRect, maSequenceRectWithStyle)); CPPUNIT_ASSERT_EQUAL(true, (bool) arePrimitive2DSequencesEqual(maSequenceRect, maSequenceRectWithParentStyle)); } CPPUNIT_TEST_SUITE_REGISTRATION(Test); } CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */