LCOV - code coverage report
Current view: top level - filter/qa/cppunit - filters-pict-test.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 31 31 100.0 %
Date: 2015-06-13 12:38:46 Functions: 16 17 94.1 %
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           4 : class PictFilterTest
      36             :     : public test::FiltersTest
      37             :     , public test::BootstrapFixture
      38             :     , public XmlTestTools
      39             : {
      40             : public:
      41           2 :     PictFilterTest() : BootstrapFixture(true, false) {}
      42             : 
      43             :     virtual bool load(const OUString &,
      44             :         const OUString &rURL, const OUString &,
      45             :         SfxFilterFlags, SotClipboardFormatId, unsigned int) SAL_OVERRIDE;
      46             : 
      47           2 :     OUString pictURL()
      48             :     {
      49           2 :         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           2 :     CPPUNIT_TEST_SUITE(PictFilterTest);
      60           1 :     CPPUNIT_TEST(testCVEs);
      61           1 :     CPPUNIT_TEST(testDontClipTooMuch);
      62           5 :     CPPUNIT_TEST_SUITE_END();
      63             : };
      64             : 
      65           5 : bool PictFilterTest::load(const OUString &,
      66             :     const OUString &rURL, const OUString &,
      67             :     SfxFilterFlags, SotClipboardFormatId, unsigned int)
      68             : {
      69           5 :     SvFileStream aFileStream(rURL, StreamMode::READ);
      70          10 :     Graphic aGraphic;
      71          10 :     return GraphicImport(aFileStream, aGraphic, NULL);
      72             : }
      73             : 
      74           1 : void PictFilterTest::testCVEs()
      75             : {
      76             :     testDir(OUString(),
      77             :         pictURL(),
      78           1 :         OUString());
      79           1 : }
      80             : 
      81           1 : void PictFilterTest::testDontClipTooMuch()
      82             : {
      83           1 :     SvFileStream aFileStream(pictURL() + "clipping-problem.pct", StreamMode::READ);
      84           2 :     GDIMetaFile aGDIMetaFile;
      85           1 :     pict::ReadPictFile(aFileStream, aGDIMetaFile);
      86             : 
      87           2 :     MetafileXmlDump dumper;
      88           1 :     dumper.filterAllActionTypes();
      89           1 :     dumper.filterActionType(MetaActionType::CLIPREGION, false);
      90           1 :     xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
      91             : 
      92           1 :     CPPUNIT_ASSERT (pDoc);
      93             : 
      94           1 :     assertXPath(pDoc, "/metafile/clipregion[5]", "top", "0");
      95           1 :     assertXPath(pDoc, "/metafile/clipregion[5]", "left", "0");
      96           1 :     assertXPath(pDoc, "/metafile/clipregion[5]", "bottom", "-32767");
      97           2 :     assertXPath(pDoc, "/metafile/clipregion[5]", "right", "-32767");
      98           1 : }
      99             : 
     100           1 : CPPUNIT_TEST_SUITE_REGISTRATION(PictFilterTest);
     101             : 
     102           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11