LCOV - code coverage report
Current view: top level - filter/qa/cppunit - filters-pict-test.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 31 31 100.0 %
Date: 2014-11-03 Functions: 13 14 92.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <unotest/filters-test.hxx>
      11             : #include <test/bootstrapfixture.hxx>
      12             : #include <vcl/FilterConfigItem.hxx>
      13             : #include <test/mtfxmldump.hxx>
      14             : #include <test/xmltesttools.hxx>
      15             : #include <tools/stream.hxx>
      16             : #include <vcl/graph.hxx>
      17             : #include <vcl/metaactiontypes.hxx>
      18             : 
      19             : #include <osl/file.hxx>
      20             : #include <osl/process.h>
      21             : 
      22             : #include "../../source/graphicfilter/ipict/ipict.hxx"
      23             : 
      24             : extern "C"
      25             : {
      26             :     SAL_DLLPUBLIC_EXPORT bool SAL_CALL
      27             :         GraphicImport(SvStream & rStream, Graphic & rGraphic,
      28             :         FilterConfigItem*);
      29             : }
      30             : 
      31             : using namespace ::com::sun::star;
      32             : 
      33             : /* Implementation of Filters test */
      34             : 
      35           8 : class PictFilterTest
      36             :     : public test::FiltersTest
      37             :     , public test::BootstrapFixture
      38             :     , public XmlTestTools
      39             : {
      40             : public:
      41           4 :     PictFilterTest() : BootstrapFixture(true, false) {}
      42             : 
      43             :     virtual bool load(const OUString &,
      44             :         const OUString &rURL, const OUString &,
      45             :         unsigned int, unsigned int, unsigned int) SAL_OVERRIDE;
      46             : 
      47           4 :     OUString pictURL()
      48             :     {
      49           4 :         return getURLFromSrc("/filter/qa/cppunit/data/pict/");
      50             :     }
      51             : 
      52             :     /**
      53             :      * Ensure CVEs remain unbroken
      54             :      */
      55             :     void testCVEs();
      56             : 
      57             :     void testDontClipTooMuch();
      58             : 
      59           4 :     CPPUNIT_TEST_SUITE(PictFilterTest);
      60           2 :     CPPUNIT_TEST(testCVEs);
      61           2 :     CPPUNIT_TEST(testDontClipTooMuch);
      62           4 :     CPPUNIT_TEST_SUITE_END();
      63             : };
      64             : 
      65          10 : bool PictFilterTest::load(const OUString &,
      66             :     const OUString &rURL, const OUString &,
      67             :     unsigned int, unsigned int, unsigned int)
      68             : {
      69          10 :     SvFileStream aFileStream(rURL, STREAM_READ);
      70          20 :     Graphic aGraphic;
      71          20 :     return GraphicImport(aFileStream, aGraphic, NULL);
      72             : }
      73             : 
      74           2 : void PictFilterTest::testCVEs()
      75             : {
      76             :     testDir(OUString(),
      77             :         pictURL(),
      78           2 :         OUString());
      79           2 : }
      80             : 
      81           2 : void PictFilterTest::testDontClipTooMuch()
      82             : {
      83           2 :     SvFileStream aFileStream(pictURL() + "clipping-problem.pct", STREAM_READ);
      84           4 :     GDIMetaFile aGDIMetaFile;
      85           2 :     pict::ReadPictFile(aFileStream, aGDIMetaFile);
      86             : 
      87           4 :     MetafileXmlDump dumper;
      88           2 :     dumper.filterAllActionTypes();
      89           2 :     dumper.filterActionType(META_CLIPREGION_ACTION, false);
      90           2 :     xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
      91             : 
      92           2 :     CPPUNIT_ASSERT (pDoc);
      93             : 
      94           2 :     assertXPath(pDoc, "/metafile/clipregion[5]", "top", "0");
      95           2 :     assertXPath(pDoc, "/metafile/clipregion[5]", "left", "0");
      96           2 :     assertXPath(pDoc, "/metafile/clipregion[5]", "bottom", "-32767");
      97           4 :     assertXPath(pDoc, "/metafile/clipregion[5]", "right", "-32767");
      98           2 : }
      99             : 
     100           2 : CPPUNIT_TEST_SUITE_REGISTRATION(PictFilterTest);
     101             : 
     102           8 : CPPUNIT_PLUGIN_IMPLEMENT();
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10