LCOV - code coverage report
Current view: top level - vcl/qa/cppunit/wmf - wmfimporttest.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 87 87 100.0 %
Date: 2014-11-03 Functions: 14 15 93.3 %
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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <test/bootstrapfixture.hxx>
      21             : #include <test/xmltesttools.hxx>
      22             : #include <test/mtfxmldump.hxx>
      23             : #include <vcl/wmf.hxx>
      24             : #include <vcl/metaact.hxx>
      25             : 
      26             : using namespace css;
      27             : 
      28          16 : class WmfTest : public test::BootstrapFixture, public XmlTestTools
      29             : {
      30             :     OUString maDataUrl;
      31             : 
      32           8 :     OUString getFullUrl(const OUString& sFileName)
      33             :     {
      34           8 :         return getURLFromSrc(maDataUrl) + sFileName;
      35             :     }
      36             : 
      37             : public:
      38           8 :     WmfTest() :
      39             :         BootstrapFixture(true, false),
      40           8 :         maDataUrl("/vcl/qa/cppunit/wmf/data/")
      41           8 :     {}
      42             : 
      43             :     void testNonPlaceableWmf();
      44             :     void testSine();
      45             :     void testEmfProblem();
      46             :     void testWorldTransformFontSize();
      47             : 
      48           4 :     CPPUNIT_TEST_SUITE(WmfTest);
      49           2 :     CPPUNIT_TEST(testNonPlaceableWmf);
      50           2 :     CPPUNIT_TEST(testSine);
      51           2 :     CPPUNIT_TEST(testEmfProblem);
      52           2 :     CPPUNIT_TEST(testWorldTransformFontSize);
      53             : 
      54           4 :     CPPUNIT_TEST_SUITE_END();
      55             : };
      56             : 
      57           2 : void WmfTest::testNonPlaceableWmf()
      58             : {
      59           2 :     SvFileStream aFileStream(getFullUrl("visio_import_source.wmf"), STREAM_READ);
      60           4 :     GDIMetaFile aGDIMetaFile;
      61           2 :     ReadWindowMetafile(aFileStream, aGDIMetaFile);
      62             : 
      63           4 :     MetafileXmlDump dumper;
      64           2 :     dumper.filterAllActionTypes();
      65           2 :     dumper.filterActionType(META_POLYLINE_ACTION, false);
      66           2 :     xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
      67             : 
      68           2 :     CPPUNIT_ASSERT (pDoc);
      69             : 
      70           2 :     assertXPath(pDoc, "/metafile/polyline[1]/point[1]", "x", "16798");
      71           2 :     assertXPath(pDoc, "/metafile/polyline[1]/point[1]", "y", "1003");
      72             : 
      73           2 :     assertXPath(pDoc, "/metafile/polyline[1]/point[2]", "x", "16798");
      74           2 :     assertXPath(pDoc, "/metafile/polyline[1]/point[2]", "y", "7507");
      75             : 
      76           2 :     assertXPath(pDoc, "/metafile/polyline[1]/point[3]", "x", "26090");
      77           2 :     assertXPath(pDoc, "/metafile/polyline[1]/point[3]", "y", "7507");
      78             : 
      79           2 :     assertXPath(pDoc, "/metafile/polyline[1]/point[4]", "x", "26090");
      80           2 :     assertXPath(pDoc, "/metafile/polyline[1]/point[4]", "y", "1003");
      81             : 
      82           2 :     assertXPath(pDoc, "/metafile/polyline[1]/point[5]", "x", "16798");
      83           4 :     assertXPath(pDoc, "/metafile/polyline[1]/point[5]", "y", "1003");
      84           2 : }
      85             : 
      86           2 : void WmfTest::testSine()
      87             : {
      88           2 :     SvFileStream aFileStream(getFullUrl("sine_wave.emf"), STREAM_READ);
      89           4 :     GDIMetaFile aGDIMetaFile;
      90           2 :     ReadWindowMetafile(aFileStream, aGDIMetaFile);
      91             : 
      92           4 :     MetafileXmlDump dumper;
      93           2 :     dumper.filterAllActionTypes();
      94           2 :     dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false);
      95           2 :     xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
      96             : 
      97           2 :     CPPUNIT_ASSERT (pDoc);
      98             : 
      99           2 :     assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "top", "0");
     100           2 :     assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "left", "0");
     101           2 :     assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "bottom", "1155947");
     102           2 :     assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "right", "1155378");
     103             : 
     104           2 :     assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "top", "1411");
     105           2 :     assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "left", "2962");
     106           2 :     assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "bottom", "16651");
     107           4 :     assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "right", "20698");
     108           2 : }
     109             : 
     110           2 : void WmfTest::testEmfProblem()
     111             : {
     112           2 :     SvFileStream aFileStream(getFullUrl("computer_mail.emf"), STREAM_READ);
     113           4 :     GDIMetaFile aGDIMetaFile;
     114           2 :     ReadWindowMetafile(aFileStream, aGDIMetaFile);
     115             : 
     116           4 :     MetafileXmlDump dumper;
     117           2 :     dumper.filterAllActionTypes();
     118           2 :     dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false);
     119           2 :     xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
     120             : 
     121           2 :     CPPUNIT_ASSERT (pDoc);
     122             : 
     123           2 :     assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "top", "427");
     124           2 :     assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "left", "740");
     125           2 :     assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "bottom", "2823");
     126           4 :     assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "right", "1876");
     127           2 : }
     128             : 
     129           2 : void WmfTest::testWorldTransformFontSize()
     130             : {
     131           2 :     SvFileStream aFileStream(getFullUrl("image1.emf"), STREAM_READ);
     132           4 :     GDIMetaFile aGDIMetaFile;
     133           2 :     ReadWindowMetafile(aFileStream, aGDIMetaFile);
     134             : 
     135           4 :     MetafileXmlDump dumper;
     136           2 :     dumper.filterAllActionTypes();
     137           2 :     dumper.filterActionType(META_FONT_ACTION, false);
     138           2 :     xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
     139             : 
     140           2 :     CPPUNIT_ASSERT (pDoc);
     141             : 
     142           2 :     assertXPath(pDoc, "/metafile/font", 8);
     143             : 
     144           2 :     assertXPath(pDoc, "/metafile/font[1]", "color", "#595959");
     145           2 :     assertXPath(pDoc, "/metafile/font[1]", "width", "0");
     146           2 :     assertXPath(pDoc, "/metafile/font[1]", "height", "389");
     147           2 :     assertXPath(pDoc, "/metafile/font[1]", "orientation", "0");
     148           2 :     assertXPath(pDoc, "/metafile/font[1]", "weight", "bold");
     149             : 
     150             :     // World transform should not affect font size. Rotating text for 90 degrees
     151             :     // should not exchange font width and height.
     152           2 :     assertXPath(pDoc, "/metafile/font[3]", "color", "#000000");
     153           2 :     assertXPath(pDoc, "/metafile/font[3]", "width", "0");
     154           2 :     assertXPath(pDoc, "/metafile/font[3]", "height", "530");
     155           2 :     assertXPath(pDoc, "/metafile/font[3]", "orientation", "900");
     156           4 :     assertXPath(pDoc, "/metafile/font[3]", "weight", "normal");
     157           2 : }
     158             : 
     159           2 : CPPUNIT_TEST_SUITE_REGISTRATION(WmfTest);
     160             : 
     161           8 : CPPUNIT_PLUGIN_IMPLEMENT();
     162             : 
     163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10