LCOV - code coverage report
Current view: top level - tools/qa/cppunit - test_color.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 37 37 100.0 %
Date: 2015-06-13 12:38:46 Functions: 13 13 100.0 %
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 <sal/types.h>
      11             : #include "cppunit/TestAssert.h"
      12             : #include "cppunit/TestFixture.h"
      13             : #include "cppunit/extensions/HelperMacros.h"
      14             : #include "cppunit/plugin/TestPlugIn.h"
      15             : #include <tools/color.hxx>
      16             : #include <tools/stream.hxx>
      17             : 
      18             : namespace
      19             : {
      20             : 
      21           6 : class Test: public CppUnit::TestFixture
      22             : {
      23             : public:
      24             :     void test_asRGBColor();
      25             :     void test_readAndWriteStream();
      26             : 
      27           2 :     CPPUNIT_TEST_SUITE(Test);
      28           1 :     CPPUNIT_TEST(test_asRGBColor);
      29           1 :     CPPUNIT_TEST(test_readAndWriteStream);
      30           5 :     CPPUNIT_TEST_SUITE_END();
      31             : };
      32             : 
      33           1 : void Test::test_asRGBColor()
      34             : {
      35           1 :     Color aColor;
      36           1 :     aColor = COL_BLACK;
      37           1 :     CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("000000"));
      38             : 
      39           1 :     aColor = COL_WHITE;
      40           1 :     CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("ffffff"));
      41             : 
      42           1 :     aColor = COL_RED;
      43           1 :     CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("800000"));
      44             : 
      45           1 :     aColor = COL_TRANSPARENT;
      46           1 :     CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("ffffff"));
      47             : 
      48           1 :     aColor = COL_BLUE;
      49           1 :     CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("000080"));
      50             : 
      51           1 :     aColor.SetRed(0x12);
      52           1 :     aColor.SetGreen(0x34);
      53           1 :     aColor.SetBlue(0x56);
      54           1 :     CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("123456"));
      55             : 
      56           1 :     aColor = COL_AUTO;
      57           1 :     CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("ffffff"));
      58           1 : }
      59             : 
      60           1 : void Test::test_readAndWriteStream()
      61             : {
      62             :     {
      63           1 :         SvMemoryStream aStream;
      64           1 :         Color aWriteColor(0x12, 0x34, 0x56);
      65           1 :         Color aReadColor;
      66             : 
      67           1 :         WriteColor(aStream, aWriteColor);
      68             : 
      69           1 :         aStream.Seek(STREAM_SEEK_TO_BEGIN);
      70             : 
      71           1 :         ReadColor(aStream, aReadColor);
      72             : 
      73           1 :         CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x12), aReadColor.GetRed());
      74           1 :         CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x34), aReadColor.GetGreen());
      75           1 :         CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x56), aReadColor.GetBlue());
      76             :     }
      77           1 : }
      78             : 
      79           1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
      80             : 
      81           3 : }
      82             : 
      83             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11