1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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>
21 class Test
: public CppUnit::TestFixture
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()
37 CPPUNIT_ASSERT_EQUAL(aColor
.AsRGBHexString(), OUString("000000"));
40 CPPUNIT_ASSERT_EQUAL(aColor
.AsRGBHexString(), OUString("ffffff"));
43 CPPUNIT_ASSERT_EQUAL(aColor
.AsRGBHexString(), OUString("800000"));
45 aColor
= COL_TRANSPARENT
;
46 CPPUNIT_ASSERT_EQUAL(aColor
.AsRGBHexString(), OUString("ffffff"));
49 CPPUNIT_ASSERT_EQUAL(aColor
.AsRGBHexString(), OUString("000080"));
52 aColor
.SetGreen(0x34);
54 CPPUNIT_ASSERT_EQUAL(aColor
.AsRGBHexString(), OUString("123456"));
57 CPPUNIT_ASSERT_EQUAL(aColor
.AsRGBHexString(), OUString("ffffff"));
60 void Test::test_readAndWriteStream()
63 SvMemoryStream aStream
;
64 Color
aWriteColor(0x12, 0x34, 0x56);
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: */