LCOV - code coverage report
Current view: top level - vcl/qa/cppunit - outdev.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 27 27 100.0 %
Date: 2015-06-13 12:38:46 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             : 
      13             : #include <vcl/virdev.hxx>
      14             : #include <vcl/salbtype.hxx>
      15             : #include <vcl/bmpacc.hxx>
      16             : #include <vcl/wrkwin.hxx>
      17             : 
      18             : #include <tools/stream.hxx>
      19             : #include <vcl/pngwrite.hxx>
      20             : 
      21           2 : class VclOutdevTest : public test::BootstrapFixture
      22             : {
      23             : public:
      24           1 :     VclOutdevTest() : BootstrapFixture(true, false) {}
      25             : 
      26             :     void testVirtualDevice();
      27             : 
      28           2 :     CPPUNIT_TEST_SUITE(VclOutdevTest);
      29           1 :     CPPUNIT_TEST(testVirtualDevice);
      30           5 :     CPPUNIT_TEST_SUITE_END();
      31             : };
      32             : 
      33           1 : void VclOutdevTest::testVirtualDevice()
      34             : {
      35           1 :     ScopedVclPtrInstance< VirtualDevice > pVDev;
      36           1 :     pVDev->SetOutputSizePixel(Size(32,32));
      37           1 :     pVDev->SetBackground(Wallpaper(COL_WHITE));
      38           1 :     pVDev->Erase();
      39           1 :     pVDev->DrawPixel(Point(1,2),COL_BLUE);
      40           1 :     pVDev->DrawPixel(Point(31,30),COL_RED);
      41             : 
      42           1 :     Size aSize = pVDev->GetOutputSizePixel();
      43           1 :     CPPUNIT_ASSERT(aSize == Size(32,32));
      44             : 
      45           2 :     Bitmap aBmp = pVDev->GetBitmap(Point(),aSize);
      46             : 
      47             : #if 0
      48             :     OUString rFileName("/tmp/foo-unx.png");
      49             :     try {
      50             :         vcl::PNGWriter aWriter( aBmp );
      51             :         SvFileStream sOutput( rFileName, StreamMode::WRITE );
      52             :         aWriter.Write( sOutput );
      53             :         sOutput.Close();
      54             :     } catch (...) {
      55             :         SAL_WARN("vcl", "Error writing png to " << rFileName);
      56             :     }
      57             : #endif
      58             : 
      59           1 :     CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(0,0)).GetColor());
      60             : #if defined LINUX //TODO: various failures on Mac and Windows tinderboxes
      61           1 :     CPPUNIT_ASSERT_EQUAL(COL_BLUE, pVDev->GetPixel(Point(1,2)).GetColor());
      62           1 :     CPPUNIT_ASSERT_EQUAL(COL_RED, pVDev->GetPixel(Point(31,30)).GetColor());
      63             : #endif
      64           1 :     CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(30,31)).GetColor());
      65             : 
      66             :     // Gotcha: y and x swap for BitmapReadAccess: deep joy.
      67           2 :     Bitmap::ScopedReadAccess pAcc(aBmp);
      68           1 :     CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(pAcc->GetPixel(0,0)).GetColor());
      69             : #if defined LINUX //TODO: various failures on Mac and Windows tinderboxes
      70           1 :     CPPUNIT_ASSERT_EQUAL(COL_BLUE, Color(pAcc->GetPixel(2,1)).GetColor());
      71           1 :     CPPUNIT_ASSERT_EQUAL(COL_RED, Color(pAcc->GetPixel(30,31)).GetColor());
      72             : #endif
      73           2 :     CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(pAcc->GetPixel(31,30)).GetColor());
      74             : 
      75             : #if 0
      76             :     VclPtr<vcl::Window> pWin = VclPtr<WorkWindow>::Create( (vcl::Window *)nullptr );
      77             :     CPPUNIT_ASSERT( pWin );
      78             :     OutputDevice *pOutDev = static_cast< OutputDevice * >( pWin );
      79             : #endif
      80           1 : }
      81             : 
      82           1 : CPPUNIT_TEST_SUITE_REGISTRATION(VclOutdevTest);
      83             : 
      84           4 : CPPUNIT_PLUGIN_IMPLEMENT();
      85             : 
      86             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11