android: Update app-specific/MIME type icons
[LibreOffice.git] / writerfilter / qa / cppunittests / rtftok / rtfdispatchsymbol.cxx
blobfa491121656ae9c9ecf1845409a32a6811a843cf
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 <test/unoapi_test.hxx>
12 #include <com/sun/star/text/XTextDocument.hpp>
13 #include <com/sun/star/beans/XPropertySet.hpp>
14 #include <com/sun/star/style/ParagraphAdjust.hpp>
16 using namespace ::com::sun::star;
18 namespace
20 /// Tests for writerfilter/source/rtftok/rtfdispatchsymbol.cxx.
21 class Test : public UnoApiTest
23 public:
24 Test()
25 : UnoApiTest("/writerfilter/qa/cppunittests/rtftok/data/")
30 CPPUNIT_TEST_FIXTURE(Test, testPage)
32 // Given a file with a \page and 2 \par tokens:
33 loadFromURL(u"page.rtf");
35 // Then make sure we get exactly two paragraphs:
36 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
37 uno::Reference<container::XEnumerationAccess> xText(xTextDocument->getText(), uno::UNO_QUERY);
38 uno::Reference<container::XEnumeration> xParagraphs = xText->createEnumeration();
39 xParagraphs->nextElement();
40 xParagraphs->nextElement();
41 // Without the accompanying fix in place, this test would have failed, the document had 3
42 // paragraphs, not 2.
43 CPPUNIT_ASSERT(!xParagraphs->hasMoreElements());
46 CPPUNIT_TEST_FIXTURE(Test, testCenterAfterPage)
48 // Given a file with a \page, followed by a \qc:
49 // When loading that file:
50 loadFromURL(u"center-after-page.rtf");
52 // Then make sure that the last paragraph is centered:
53 uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
54 uno::Reference<container::XEnumerationAccess> xText(xTextDocument->getText(), uno::UNO_QUERY);
55 uno::Reference<container::XEnumeration> xParagraphs = xText->createEnumeration();
56 xParagraphs->nextElement();
57 xParagraphs->nextElement();
58 uno::Reference<beans::XPropertySet> xParagraph(xParagraphs->nextElement(), uno::UNO_QUERY);
59 sal_Int16 eActual{};
60 CPPUNIT_ASSERT(xParagraph->getPropertyValue("ParaAdjust") >>= eActual);
61 // Without the accompanying fix in place, this test would have failed with:
62 // - Expected: 3 (CENTER)
63 // - Actual : 0 (LEFT)
64 // i.e. the paragraph alignment on the second page was lost.
65 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(style::ParagraphAdjust_CENTER), eActual);
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */