fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / tools / qa / cppunit / test_color.cxx
blob99f311fc5a4c497365dbadb62e02a5fff454b2b7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
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>
18 namespace
21 class Test: public CppUnit::TestFixture
23 public:
24 void test_asRGBColor();
25 void test_readAndWriteStream();
27 CPPUNIT_TEST_SUITE(Test);
28 CPPUNIT_TEST(test_asRGBColor);
29 CPPUNIT_TEST(test_readAndWriteStream);
30 CPPUNIT_TEST_SUITE_END();
33 void Test::test_asRGBColor()
35 Color aColor;
36 aColor = COL_BLACK;
37 CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("000000"));
39 aColor = COL_WHITE;
40 CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("ffffff"));
42 aColor = COL_RED;
43 CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("800000"));
45 aColor = COL_TRANSPARENT;
46 CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("ffffff"));
48 aColor = COL_BLUE;
49 CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("000080"));
51 aColor.SetRed(0x12);
52 aColor.SetGreen(0x34);
53 aColor.SetBlue(0x56);
54 CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("123456"));
56 aColor = COL_AUTO;
57 CPPUNIT_ASSERT_EQUAL(aColor.AsRGBHexString(), OUString("ffffff"));
60 void Test::test_readAndWriteStream()
63 SvMemoryStream aStream;
64 Color aWriteColor(0x12, 0x34, 0x56);
65 Color aReadColor;
67 WriteColor(aStream, aWriteColor);
69 aStream.Seek(STREAM_SEEK_TO_BEGIN);
71 ReadColor(aStream, aReadColor);
73 CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x12), aReadColor.GetRed());
74 CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x34), aReadColor.GetGreen());
75 CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x56), aReadColor.GetBlue());
79 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */