Kaydet (Commit) 3428ca9c authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen Kaydeden (comit) Björn Michaelsen

name apitest suites consistently while we still can

- writer test apitest suites are now called like the UNO implementation they
  are testing
- also mark them final for good measure
- move tests to module test and try to match its conventions
  * BaseIndex
  * TextDocumentIndex
  * TextDocumentSettings
  * TextPrinterSettings
  * TextSettings
  * XDocumentIndex
- also remove anonymous namespace in header, as that is a bad idea
- also remove now obsolete ApiBaseTest
- also remove dead code in TextPrinterSettings
- remove writer xtextcontent test as it duplicates the impl in module test

Change-Id: I71aa5f3755d5c90726f4ff4394117fa2391495d7
Reviewed-on: https://gerrit.libreoffice.org/69374
Tested-by: Jenkins
Reviewed-by: 's avatarBjörn Michaelsen <bjoern.michaelsen@libreoffice.org>
üst 09b9499d
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_TEST_TEXT_BASEINDEXTEST_HXX
#define INCLUDED_TEST_TEXT_BASEINDEXTEST_HXX
#include <test/testdllapi.hxx>
namespace apitest
{
class OOO_DLLPUBLIC_TEST BaseIndex
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
virtual ~BaseIndex();
void testBaseIndexProperties();
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_TEST_TEXT_DOCUMENTINDEXTEST_HXX
#define INCLUDED_TEST_TEXT_DOCUMENTINDEXTEST_HXX
#include <com/sun/star/beans/XPropertySet.hpp>
#include <test/unoapi_property_testers.hxx>
#include <test/testdllapi.hxx>
namespace apitest
{
class OOO_DLLPUBLIC_TEST TextDocumentIndex
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
virtual ~TextDocumentIndex();
void testDocumentIndexProperties();
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_TEST_TEXT_TEXTDOCUMENTSETTINGS_HXX
#define INCLUDED_TEST_TEXT_TEXTDOCUMENTSETTINGS_HXX
#include <com/sun/star/uno/Reference.hxx>
#include <test/testdllapi.hxx>
namespace apitest
{
class OOO_DLLPUBLIC_TEST TextDocumentSettings
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
virtual ~TextDocumentSettings();
void testDocumentSettingsProperties();
};
} // end namespace apitest
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_TEST_TEXT_TEXTPRINTERSETTINGS_HXX
#define INCLUDED_TEST_TEXT_TEXTPRINTERSETTINGS_HXX
#include <test/unoapi_property_testers.hxx>
#include <test/testdllapi.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
namespace apitest
{
class OOO_DLLPUBLIC_TEST TextPrinterSettings
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
virtual ~TextPrinterSettings();
void testPrinterSettingsProperties();
};
} // end namespace apitest
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_TEST_TEXT_TEXTSETTINGS_HXX
#define INCLUDED_TEST_TEXT_TEXTSETTINGS_HXX
namespace apitest
{
class OOO_DLLPUBLIC_TEST TextSettings
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
virtual ~TextSettings();
void testSettingsProperties();
};
} // end namespace apitest
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_TEST_TEST_XDOCUMENTINDEX_HXX
#define INCLUDED_TEST_TEST_XDOCUMENTINDEX_HXX
#include <com/sun/star/text/XTextDocument.hpp>
#include <test/testdllapi.hxx>
namespace apitest
{
/**
* Testing <code>com.sun.star.text.XDocumentIndex</code>
*
* @see com.sun.star.text.XDocumentIndex
*/
class OOO_DLLPUBLIC_TEST XDocumentIndex
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
virtual css::uno::Reference<css::text::XTextDocument> getTextDocument() = 0;
virtual ~XDocumentIndex();
void testUpdate();
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -15,7 +15,7 @@ $(eval $(call gb_CppunitTest_use_external,sw_apitests,boost_headers))
$(eval $(call gb_CppunitTest_add_exception_objects,sw_apitests, \
sw/qa/api/SwXDocumentIndex \
sw/qa/api/DocumentSettings \
sw/qa/api/SwXDocumentSettings \
sw/qa/api/SwXTextTable \
))
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SW_QA_CORE_APITESTBASE_HXX
#define INCLUDED_SW_QA_CORE_APITESTBASE_HXX
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
namespace apitest
{
class ApiTestBase
{
protected:
static bool extstsProperty(css::uno::Reference<css::beans::XPropertySet> const& rxPropertySet,
OUString const& rPropertyName)
{
css::uno::Reference<css::beans::XPropertySetInfo> xPropertySetInfo(
rxPropertySet->getPropertySetInfo());
return xPropertySetInfo->hasPropertyByName(rPropertyName);
}
static bool
isPropertyReadOnly(css::uno::Reference<css::beans::XPropertySet> const& rxPropertySet,
OUString const& rPropertyName)
{
css::uno::Reference<css::beans::XPropertySetInfo> xPropertySetInfo(
rxPropertySet->getPropertySetInfo());
css::uno::Sequence<css::beans::Property> xProperties = xPropertySetInfo->getProperties();
for (auto const& rProperty : xProperties)
{
if (rProperty.Name == rPropertyName)
return (rProperty.Attributes & com::sun::star::beans::PropertyAttribute::READONLY)
!= 0;
}
return false;
}
virtual ~ApiTestBase() {}
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SW_QA_API_BASEINDEXTEST_HXX
#define INCLUDED_SW_QA_API_BASEINDEXTEST_HXX
#include "ApiTestBase.hxx"
#include <cppunit/TestAssert.h>
#include <test/unoapi_property_testers.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/text/XTextColumns.hpp>
#include <com/sun/star/text/XTextSection.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <vcl/BitmapTools.hxx>
#include <vcl/graph.hxx>
#include <vcl/pngwrite.hxx>
#include <unotools/tempfile.hxx>
#include <tools/stream.hxx>
namespace apitest
{
namespace
{
BitmapEx createExampleBitmap()
{
vcl::bitmap::RawBitmap aRawBitmap(Size(4, 4), 24);
aRawBitmap.SetPixel(0, 0, COL_LIGHTBLUE);
aRawBitmap.SetPixel(0, 1, COL_LIGHTGREEN);
aRawBitmap.SetPixel(1, 0, COL_LIGHTRED);
aRawBitmap.SetPixel(1, 1, COL_LIGHTMAGENTA);
return vcl::bitmap::CreateFromData(std::move(aRawBitmap));
}
void writerFileWithBitmap(OUString const& rURL)
{
BitmapEx aBitmapEx = createExampleBitmap();
SvFileStream aFileStream(rURL, StreamMode::READ | StreamMode::WRITE);
vcl::PNGWriter aWriter(aBitmapEx);
aWriter.Write(aFileStream);
aFileStream.Seek(STREAM_SEEK_TO_BEGIN);
aFileStream.Close();
}
} // end anonymous namespace
class BaseIndexTest : public ApiTestBase
{
public:
void testBaseIndexProperties()
{
css::uno::Reference<css::beans::XPropertySet> xBaseIndex(init(), css::uno::UNO_QUERY_THROW);
testStringProperty(xBaseIndex, "Title", "Value");
testBooleanProperty(xBaseIndex, "IsProtected");
testStringProperty(xBaseIndex, "ParaStyleHeading", "Value");
testStringProperty(xBaseIndex, "ParaStyleLevel1", "Value");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel2");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel3");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel4");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel5");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel6");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel7");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel8");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel9");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel10");
testStringOptionalProperty(xBaseIndex, "ParaStyleSeparator");
// [property] XTextColumns TextColumns;
{
OUString name = "TextColumns";
css::uno::Reference<css::text::XTextColumns> xGetTextColumns;
CPPUNIT_ASSERT(xBaseIndex->getPropertyValue(name) >>= xGetTextColumns);
xGetTextColumns->setColumnCount(xGetTextColumns->getColumnCount() + 1);
xBaseIndex->setPropertyValue(name, css::uno::makeAny(xGetTextColumns));
css::uno::Reference<css::text::XTextColumns> xSetTextColumns;
CPPUNIT_ASSERT(xBaseIndex->getPropertyValue(name) >>= xSetTextColumns);
//CPPUNIT_ASSERT_EQUAL(xGetTextColumns->getColumnCount(), xSetTextColumns->getColumnCount());
}
// [property] com::sun::star::graphic::XGraphic BackGraphic;
// [property] string BackGraphicURL;
{
OUString name = "BackGraphicURL";
bool bOK = false;
try
{
xBaseIndex->getPropertyValue(name);
}
catch (css::uno::RuntimeException const& /*ex*/)
{
bOK = true;
}
// BackGraphicURL is "set-only" attribute
CPPUNIT_ASSERT_MESSAGE("Expected RuntimeException wasn't thrown", bOK);
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
writerFileWithBitmap(aTempFile.GetURL());
css::uno::Reference<css::graphic::XGraphic> xGraphic;
CPPUNIT_ASSERT(xBaseIndex->getPropertyValue("BackGraphic") >>= xGraphic);
CPPUNIT_ASSERT(!xGraphic.is());
xBaseIndex->setPropertyValue(name, css::uno::makeAny(aTempFile.GetURL()));
CPPUNIT_ASSERT(xBaseIndex->getPropertyValue("BackGraphic") >>= xGraphic);
CPPUNIT_ASSERT(xGraphic.is());
}
testStringProperty(xBaseIndex, "BackGraphicFilter", "Value");
// [property] com::sun::star::style::GraphicLocation BackGraphicLocation;
testColorProperty(xBaseIndex, "BackColor");
testBooleanProperty(xBaseIndex, "BackTransparent");
// [optional, property] com::sun::star::container::XIndexReplace LevelFormat;
testBooleanOptionalProperty(xBaseIndex, "CreateFromChapter");
// [property] com::sun::star::text::XTextSection ContentSection;
{
OUString name = "ContentSection";
css::uno::Reference<css::text::XTextSection> xGetTextSection;
CPPUNIT_ASSERT_MESSAGE(name.toUtf8().getStr(),
xBaseIndex->getPropertyValue(name) >>= xGetTextSection);
CPPUNIT_ASSERT_EQUAL_MESSAGE(name.toUtf8().getStr(), OUString(""),
xGetTextSection->getAnchor()->getString());
}
// [property] com::sun::star::text::XTextSection HeaderSection;
{
OUString name = "HeaderSection";
css::uno::Reference<css::text::XTextSection> xGetTextSection;
if (xBaseIndex->getPropertyValue(name).hasValue())
CPPUNIT_ASSERT_MESSAGE(name.toUtf8().getStr(),
xBaseIndex->getPropertyValue(name) >>= xGetTextSection);
}
}
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SW_QA_API_PRINTERSETTINGSTEST_HXX
#define INCLUDED_SW_QA_API_PRINTERSETTINGSTEST_HXX
#include "ApiTestBase.hxx"
#include <cppunit/TestAssert.h>
#include <test/unoapi_property_testers.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/text/NotePrintMode.hpp>
namespace apitest
{
class PrinterSettingsTest : public ApiTestBase
{
static void
testPrintAnnotationMode(css::uno::Reference<css::beans::XPropertySet> const& rxPrinterSettings)
{
const OUString rPropertyName = "PrintAnnotationMode";
// This property is not optional but it's not set in some cases
if (!extstsProperty(rxPrinterSettings, rPropertyName))
return;
/*css::text::NotePrintMode aNotePrintMode_Get;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxPrinterSettings->getPropertyValue(rPropertyName)
>>= aNotePrintMode_Get);
css::text::NotePrintMode aNotePrintMode_Set;
css::uno::Any aNewValue;
aNewValue <<= css::text::NotePrintMode_ONLY;
rxPrinterSettings->setPropertyValue(rPropertyName, aNewValue);
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxPrinterSettings->getPropertyValue(rPropertyName)
>>= aNotePrintMode_Set);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", css::text::NotePrintMode_ONLY,
aNotePrintMode_Set);*/
}
public:
void testPrinterSettingsProperties()
{
css::uno::Reference<css::beans::XPropertySet> xPrinterSettings(init(),
css::uno::UNO_QUERY_THROW);
testBooleanProperty(xPrinterSettings, "PrintGraphics");
testBooleanProperty(xPrinterSettings, "PrintTables");
testBooleanProperty(xPrinterSettings, "PrintDrawings");
testBooleanProperty(xPrinterSettings, "PrintLeftPages");
testBooleanProperty(xPrinterSettings, "PrintRightPages");
testBooleanProperty(xPrinterSettings, "PrintControls");
testBooleanProperty(xPrinterSettings, "PrintReversed");
testBooleanProperty(xPrinterSettings, "PrintControls");
testStringProperty(xPrinterSettings, "PrintFaxName", "FaxName");
testPrintAnnotationMode(
xPrinterSettings); // it's not set in this case but it's not optional - bug?
testBooleanProperty(xPrinterSettings, "PrintProspect");
testBooleanProperty(xPrinterSettings, "PrintPageBackground");
testBooleanProperty(xPrinterSettings, "PrintBlackFonts");
testBooleanOptionalProperty(xPrinterSettings, "PrintEmptyPages");
}
};
} // end namespace apitest
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SW_QA_API_SETTINGSTEST_HXX
#define INCLUDED_SW_QA_API_SETTINGSTEST_HXX
#include "ApiTestBase.hxx"
#include <cppunit/TestAssert.h>
#include <test/unoapi_property_testers.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
namespace apitest
{
class SettingsTest : public ApiTestBase
{
// [property] string PrinterName;
static void testPrinterName(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
{
const OUString rPropertyName("PrinterName");
if (!extstsProperty(rxSettings, rPropertyName))
return; // Property is sometimes not set - bug? it is not defined as optional
OUString aPrinterName_Get;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxSettings->getPropertyValue(rPropertyName) >>= aPrinterName_Get);
OUString aPrinterName_Set;
css::uno::Any aNewValue;
aNewValue <<= aPrinterName_Get;
rxSettings->setPropertyValue(rPropertyName, aNewValue);
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxSettings->getPropertyValue(rPropertyName) >>= aPrinterName_Set);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", aPrinterName_Get,
aPrinterName_Set);
}
// [optional, property] short PrinterIndependentLayout;
static void
testPrinterIndependentLayout(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
{
const OUString rPropertyName("PrinterIndependentLayout");
if (!extstsProperty(rxSettings, rPropertyName))
return; // Property is optional
sal_Int16 aValue_Get;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxSettings->getPropertyValue(rPropertyName) >>= aValue_Get);
sal_Int16 aValue_New;
aValue_New = (aValue_Get == 1 ? 3 : 1);
rxSettings->setPropertyValue(rPropertyName, css::uno::Any(aValue_New));
sal_Int16 aValue_Set;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxSettings->getPropertyValue(rPropertyName) >>= aValue_Set);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", aValue_New, aValue_Set);
}
// [optional, property] com::sun::star::i18n::XForbiddenCharacters ForbiddenCharacters;
static void
testForbiddenCharacters(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
{
const OUString rPropertyName("ForbiddenCharacters");
if (!extstsProperty(rxSettings, rPropertyName))
return; // Property is optional
CPPUNIT_ASSERT_MESSAGE("Property is read-only but shouldn't be",
!isPropertyReadOnly(rxSettings, rPropertyName));
css::uno::Reference<css::i18n::XForbiddenCharacters> aValue_Get;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxSettings->getPropertyValue(rPropertyName) >>= aValue_Get);
CPPUNIT_ASSERT_MESSAGE("Empty reference to XForbiddenCharacters", aValue_Get.is());
}
public:
void testSettingsProperties()
{
css::uno::Reference<css::beans::XPropertySet> xSettings(init(), css::uno::UNO_QUERY_THROW);
testForbiddenCharacters(xSettings);
//testShortOptionalProperty(xSettings, "LinkUpdateMode");
testPrinterName(xSettings);
// [property] sequence< byte > PrinterSetup;
testBooleanOptionalProperty(xSettings, "IsKernAsianPunctuation");
//testShortOptionalProperty(xSettings, "CharacterCompressionType");
testBooleanOptionalProperty(xSettings, "ApplyUserData");
testBooleanOptionalProperty(xSettings, "SaveVersionOnClose");
testBooleanOptionalProperty(xSettings, "UpdateFromTemplate");
testBooleanOptionalProperty(xSettings, "FieldAutoUpdate");
testStringOptionalProperty(xSettings, "CurrentDatabaseDataSource");
testStringOptionalProperty(xSettings, "CurrentDatabaseCommand");
testLongOptionalProperty(xSettings, "CurrentDatabaseCommandType");
testLongOptionalProperty(xSettings, "DefaultTabStop");
testBooleanOptionalProperty(xSettings, "IsPrintBooklet");
testBooleanOptionalProperty(xSettings, "IsPrintBookletFront");
testBooleanOptionalProperty(xSettings, "IsPrintBookletBack");
testLongOptionalProperty(xSettings, "PrintQuality");
testStringOptionalProperty(xSettings, "ColorTableURL");
testStringOptionalProperty(xSettings, "DashTableURL");
testStringOptionalProperty(xSettings, "LineEndTableURL");
testStringOptionalProperty(xSettings, "HatchTableURL");
testStringOptionalProperty(xSettings, "GradientTableURL");
testStringOptionalProperty(xSettings, "BitmapTableURL");
testBooleanOptionalProperty(xSettings, "AutoCalculate");
testPrinterIndependentLayout(xSettings);
testBooleanOptionalProperty(xSettings, "AddExternalLeading");
testBooleanOptionalProperty(xSettings, "EmbedFonts");
testBooleanOptionalProperty(xSettings, "EmbedSystemFonts");
testBooleanOptionalProperty(xSettings, "EmbedOnlyUsedFonts");
testBooleanOptionalProperty(xSettings, "EmbedLatinScriptFonts");
testBooleanOptionalProperty(xSettings, "EmbedAsianScriptFonts");
testBooleanOptionalProperty(xSettings, "EmbedComplexScriptFonts");
}
};
} // end namespace apitest
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -7,14 +7,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "BaseIndexTest.hxx"
#include "DocumentIndexTest.hxx"
#include "XDocumentIndexTest.hxx"
#include "XTextContentTest.hxx"
#include <test/bootstrapfixture.hxx>
#include <test/lang/xserviceinfo.hxx>
#include <test/lang/xcomponent.hxx>
#include <test/text/baseindex.hxx>
#include <test/text/textdocumentindex.hxx>
#include <test/text/xdocumentindex.hxx>
#include <test/text/xtextcontent.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
......@@ -26,6 +25,7 @@
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/XTextCursor.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/text/XDocumentIndex.hpp>
#include <comphelper/processfactory.hxx>
......@@ -37,29 +37,34 @@ namespace
/**
* Test for Java API test of file com.sun.star.comp.office.SwXDocumentIndex.csv
*/
class SwXDocumentIndexTest : public test::BootstrapFixture,
public unotest::MacrosTest,
public apitest::XDocumentIndexTest,
public apitest::BaseIndexTest,
public apitest::DocumentIndexTest,
public apitest::XTextContentTest,
public apitest::XServiceInfo,
public apitest::XComponent
class SwXDocumentIndex final : public test::BootstrapFixture,
public unotest::MacrosTest,
public apitest::XDocumentIndex,
public apitest::BaseIndex,
public apitest::TextDocumentIndex,
public apitest::XTextContent,
public apitest::XServiceInfo,
public apitest::XComponent
{
uno::Reference<uno::XComponentContext> mxComponentContext;
uno::Reference<text::XTextDocument> mxTextDocument;
uno::Reference<text::XTextRange> mxTextRange;
uno::Reference<text::XTextContent> mxTextContent;
public:
virtual void setUp() override;
virtual void tearDown() override;
SwXDocumentIndexTest()
SwXDocumentIndex()
: apitest::XServiceInfo("SwXDocumentIndex", "com.sun.star.text.BaseIndex"){};
uno::Reference<uno::XInterface> init() override;
uno::Reference<text::XTextRange> getTextRange() override;
uno::Reference<text::XTextContent> getTextContent() override;
bool isAttachSupported() override { return true; }
uno::Reference<text::XTextDocument> getTextDocument() override { return mxTextDocument; }
void triggerDesktopTerminate() override {}
CPPUNIT_TEST_SUITE(SwXDocumentIndexTest);
CPPUNIT_TEST_SUITE(SwXDocumentIndex);
CPPUNIT_TEST(testGetImplementationName);
CPPUNIT_TEST(testGetSupportedServiceNames);
CPPUNIT_TEST(testSupportsService);
......@@ -73,7 +78,7 @@ public:
CPPUNIT_TEST_SUITE_END();
};
void SwXDocumentIndexTest::setUp()
void SwXDocumentIndex::setUp()
{
test::BootstrapFixture::setUp();
......@@ -85,7 +90,7 @@ void SwXDocumentIndexTest::setUp()
CPPUNIT_ASSERT(mxTextDocument.is());
}
void SwXDocumentIndexTest::tearDown()
void SwXDocumentIndex::tearDown()
{
if (mxTextDocument.is())
mxTextDocument->dispose();
......@@ -93,7 +98,7 @@ void SwXDocumentIndexTest::tearDown()
test::BootstrapFixture::tearDown();
}
uno::Reference<uno::XInterface> SwXDocumentIndexTest::init()
uno::Reference<uno::XInterface> SwXDocumentIndex::init()
{
uno::Reference<lang::XMultiServiceFactory> xMSF(mxTextDocument, uno::UNO_QUERY_THROW);
uno::Reference<text::XDocumentIndex> xDocumentIndex(
......@@ -103,10 +108,17 @@ uno::Reference<uno::XInterface> SwXDocumentIndexTest::init()
CPPUNIT_ASSERT(xTextCursor.is());
xText->insertTextContent(xTextCursor, xDocumentIndex, false);
xTextCursor->gotoEnd(false);
mxTextRange = uno::Reference<text::XTextRange>(xTextCursor, uno::UNO_QUERY_THROW);
mxTextContent = uno::Reference<text::XTextContent>(
xMSF->createInstance("com.sun.star.text.DocumentIndex"), uno::UNO_QUERY_THROW);
return xDocumentIndex;
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwXDocumentIndexTest);
uno::Reference<text::XTextRange> SwXDocumentIndex::getTextRange() { return mxTextRange; }
uno::Reference<text::XTextContent> SwXDocumentIndex::getTextContent() { return mxTextContent; }
CPPUNIT_TEST_SUITE_REGISTRATION(SwXDocumentIndex);
}
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -9,6 +9,9 @@
#include <test/bootstrapfixture.hxx>
#include <test/lang/xserviceinfo.hxx>
#include <test/text/textdocumentsettings.hxx>
#include <test/text/textprintersettings.hxx>
#include <test/text/textsettings.hxx>
#include <unotest/macros_test.hxx>
#include <com/sun/star/frame/Desktop.hpp>
......@@ -21,10 +24,6 @@
#include <comphelper/processfactory.hxx>
#include "DocumentSettingsTest.hxx"
#include "SettingsTest.hxx"
#include "PrinterSettingsTest.hxx"
using namespace css;
namespace
......@@ -32,12 +31,12 @@ namespace
/**
* Test for Java API test of file com.sun.star.comp.Writer.DocumentSettings.csv
*/
class DocumentSettingsTest : public test::BootstrapFixture,
public unotest::MacrosTest,
public apitest::DocumentSettingsTest,
public apitest::SettingsTest,
public apitest::PrinterSettingsTest,
public apitest::XServiceInfo
class SwXDocumentSettings final : public test::BootstrapFixture,
public unotest::MacrosTest,
public apitest::TextDocumentSettings,
public apitest::TextSettings,
public apitest::TextPrinterSettings,
public apitest::XServiceInfo
{
private:
uno::Reference<uno::XComponentContext> mxComponentContext;
......@@ -47,11 +46,11 @@ public:
virtual void setUp() override;
virtual void tearDown() override;
DocumentSettingsTest()
SwXDocumentSettings()
: apitest::XServiceInfo("SwXDocumentSettings", "com.sun.star.text.DocumentSettings"){};
uno::Reference<uno::XInterface> init() override;
CPPUNIT_TEST_SUITE(DocumentSettingsTest);
CPPUNIT_TEST_SUITE(SwXDocumentSettings);
CPPUNIT_TEST(testGetImplementationName);
CPPUNIT_TEST(testGetSupportedServiceNames);
CPPUNIT_TEST(testSupportsService);
......@@ -61,7 +60,7 @@ public:
CPPUNIT_TEST_SUITE_END();
};
void DocumentSettingsTest::setUp()
void SwXDocumentSettings::setUp()
{
test::BootstrapFixture::setUp();
......@@ -69,7 +68,7 @@ void DocumentSettingsTest::setUp()
mxDesktop.set(frame::Desktop::create(mxComponentContext));
}
void DocumentSettingsTest::tearDown()
void SwXDocumentSettings::tearDown()
{
if (mxComponent.is())
mxComponent->dispose();
......@@ -77,7 +76,7 @@ void DocumentSettingsTest::tearDown()
test::BootstrapFixture::tearDown();
}
uno::Reference<uno::XInterface> DocumentSettingsTest::init()
uno::Reference<uno::XInterface> SwXDocumentSettings::init()
{
mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
CPPUNIT_ASSERT(mxComponent.is());
......@@ -91,7 +90,7 @@ uno::Reference<uno::XInterface> DocumentSettingsTest::init()
return xDocumentSettings;
}
CPPUNIT_TEST_SUITE_REGISTRATION(DocumentSettingsTest);
CPPUNIT_TEST_SUITE_REGISTRATION(SwXDocumentSettings);
} // end anonymous namespace
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SW_QA_API_XDOCUMENTINDEXTEST_HXX
#define INCLUDED_SW_QA_API_XDOCUMENTINDEXTEST_HXX
#include "ApiTestBase.hxx"
#include <cppunit/TestAssert.h>
#include <test/unoapi_property_testers.hxx>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/XDocumentIndex.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
namespace apitest
{
/**
* Testing <code>com.sun.star.text.XDocumentIndex</code>
*
* @see com.sun.star.text.XDocumentIndex
*/
class XDocumentIndexTest : public ApiTestBase
{
public:
virtual css::uno::Reference<css::text::XTextDocument> getTextDocument() = 0;
/**
* Gets the document from relation and insert a new index mark.
* Then it stores the text content of document index before
* update and after.<p>
*
* Has <b> OK </b> status if index content is changed and
* new index contains index mark inserted. <p>
*/
void testUpdate()
{
css::uno::Reference<css::text::XDocumentIndex> xDocumentIndex(init(),
css::uno::UNO_QUERY_THROW);
bool bOK = true;
try
{
auto xText = getTextDocument()->getText();
auto xTextRange = xText->getEnd();
xTextRange->setString("IndexMark");
css::uno::Reference<css::lang::XMultiServiceFactory> xFactory(
getTextDocument(), css::uno::UNO_QUERY_THROW);
css::uno::Reference<css::text::XTextContent> xTextContentMark(
xFactory->createInstance("com.sun.star.text.DocumentIndexMark"),
css::uno::UNO_QUERY_THROW);
xText->insertTextContent(xTextRange, xTextContentMark, true);
}
catch (css::uno::Exception /*exception*/)
{
bOK = false;
}
CPPUNIT_ASSERT_MESSAGE("Couldn't create the document index mark", bOK);
OUString sContentBefore = xDocumentIndex->getAnchor()->getString();
xDocumentIndex->update();
OUString sContentAfter = xDocumentIndex->getAnchor()->getString();
CPPUNIT_ASSERT_MESSAGE("Before and after shouldn't be equal",
sContentBefore != sContentAfter);
CPPUNIT_ASSERT_MESSAGE("Content after should contain string 'IndexMark'",
sContentAfter.indexOf("IndexMark") >= 0);
}
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -169,11 +169,17 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/table/xtablechartssupplier \
test/source/table/xtablecolumns \
test/source/table/xtablerows \
test/source/text/baseindex \
test/source/text/xsimpletext \
test/source/text/xtext \
test/source/text/xtextcontent \
test/source/text/xtextfield \
test/source/text/xtextrange \
test/source/text/xdocumentindex \
test/source/text/textdocumentsettings \
test/source/text/textprintersettings \
test/source/text/textsettings \
test/source/text/textdocumentindex \
test/source/util/xindent \
test/source/util/xmergeable \
test/source/util/xrefreshable \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/text/XTextColumns.hpp>
#include <com/sun/star/text/XTextSection.hpp>
#include <vcl/BitmapTools.hxx>
#include <vcl/graph.hxx>
#include <vcl/pngwrite.hxx>
#include <unotools/tempfile.hxx>
#include <tools/stream.hxx>
#include <test/unoapi_property_testers.hxx>
#include <test/text/baseindex.hxx>
#include <test/testdllapi.hxx>
namespace
{
BitmapEx createExampleBitmap()
{
vcl::bitmap::RawBitmap aRawBitmap(Size(4, 4), 24);
aRawBitmap.SetPixel(0, 0, COL_LIGHTBLUE);
aRawBitmap.SetPixel(0, 1, COL_LIGHTGREEN);
aRawBitmap.SetPixel(1, 0, COL_LIGHTRED);
aRawBitmap.SetPixel(1, 1, COL_LIGHTMAGENTA);
return vcl::bitmap::CreateFromData(std::move(aRawBitmap));
}
void writerFileWithBitmap(OUString const& rURL)
{
BitmapEx aBitmapEx = createExampleBitmap();
SvFileStream aFileStream(rURL, StreamMode::READ | StreamMode::WRITE);
vcl::PNGWriter aWriter(aBitmapEx);
aWriter.Write(aFileStream);
aFileStream.Seek(STREAM_SEEK_TO_BEGIN);
aFileStream.Close();
}
}
namespace apitest
{
BaseIndex::~BaseIndex() {}
void BaseIndex::testBaseIndexProperties()
{
css::uno::Reference<css::beans::XPropertySet> xBaseIndex(init(), css::uno::UNO_QUERY_THROW);
testStringProperty(xBaseIndex, "Title", "Value");
testBooleanProperty(xBaseIndex, "IsProtected");
testStringProperty(xBaseIndex, "ParaStyleHeading", "Value");
testStringProperty(xBaseIndex, "ParaStyleLevel1", "Value");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel2");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel3");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel4");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel5");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel6");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel7");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel8");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel9");
testStringOptionalProperty(xBaseIndex, "ParaStyleLevel10");
testStringOptionalProperty(xBaseIndex, "ParaStyleSeparator");
// [property] XTextColumns TextColumns;
{
OUString name = "TextColumns";
css::uno::Reference<css::text::XTextColumns> xGetTextColumns;
CPPUNIT_ASSERT(xBaseIndex->getPropertyValue(name) >>= xGetTextColumns);
xGetTextColumns->setColumnCount(xGetTextColumns->getColumnCount() + 1);
xBaseIndex->setPropertyValue(name, css::uno::makeAny(xGetTextColumns));
css::uno::Reference<css::text::XTextColumns> xSetTextColumns;
CPPUNIT_ASSERT(xBaseIndex->getPropertyValue(name) >>= xSetTextColumns);
//CPPUNIT_ASSERT_EQUAL(xGetTextColumns->getColumnCount(), xSetTextColumns->getColumnCount());
}
// [property] com::sun::star::graphic::XGraphic BackGraphic;
// [property] string BackGraphicURL;
{
OUString name = "BackGraphicURL";
bool bOK = false;
try
{
xBaseIndex->getPropertyValue(name);
}
catch (css::uno::RuntimeException const& /*ex*/)
{
bOK = true;
}
// BackGraphicURL is "set-only" attribute
CPPUNIT_ASSERT_MESSAGE("Expected RuntimeException wasn't thrown", bOK);
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
writerFileWithBitmap(aTempFile.GetURL());
css::uno::Reference<css::graphic::XGraphic> xGraphic;
CPPUNIT_ASSERT(xBaseIndex->getPropertyValue("BackGraphic") >>= xGraphic);
CPPUNIT_ASSERT(!xGraphic.is());
xBaseIndex->setPropertyValue(name, css::uno::makeAny(aTempFile.GetURL()));
CPPUNIT_ASSERT(xBaseIndex->getPropertyValue("BackGraphic") >>= xGraphic);
CPPUNIT_ASSERT(xGraphic.is());
}
testStringProperty(xBaseIndex, "BackGraphicFilter", "Value");
// [property] com::sun::star::style::GraphicLocation BackGraphicLocation;
testColorProperty(xBaseIndex, "BackColor");
testBooleanProperty(xBaseIndex, "BackTransparent");
// [optional, property] com::sun::star::container::XIndexReplace LevelFormat;
testBooleanOptionalProperty(xBaseIndex, "CreateFromChapter");
// [property] com::sun::star::text::XTextSection ContentSection;
{
OUString name = "ContentSection";
css::uno::Reference<css::text::XTextSection> xGetTextSection;
CPPUNIT_ASSERT_MESSAGE(name.toUtf8().getStr(),
xBaseIndex->getPropertyValue(name) >>= xGetTextSection);
CPPUNIT_ASSERT_EQUAL_MESSAGE(name.toUtf8().getStr(), OUString(""),
xGetTextSection->getAnchor()->getString());
}
// [property] com::sun::star::text::XTextSection HeaderSection;
{
OUString name = "HeaderSection";
css::uno::Reference<css::text::XTextSection> xGetTextSection;
if (xBaseIndex->getPropertyValue(name).hasValue())
CPPUNIT_ASSERT_MESSAGE(name.toUtf8().getStr(),
xBaseIndex->getPropertyValue(name) >>= xGetTextSection);
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <com/sun/star/beans/XPropertySet.hpp>
#include <test/unoapi_property_testers.hxx>
#include <test/text/textdocumentindex.hxx>
namespace apitest
{
TextDocumentIndex::~TextDocumentIndex() {}
void TextDocumentIndex::testDocumentIndexProperties()
{
css::uno::Reference<css::beans::XPropertySet> xDocumnetIndex(init(), css::uno::UNO_QUERY_THROW);
testBooleanProperty(xDocumnetIndex, "UseAlphabeticalSeparators");
testBooleanProperty(xDocumnetIndex, "UseKeyAsEntry");
testBooleanProperty(xDocumnetIndex, "UseCombinedEntries");
testBooleanProperty(xDocumnetIndex, "IsCaseSensitive");
testBooleanProperty(xDocumnetIndex, "UsePP");
testBooleanProperty(xDocumnetIndex, "UseDash");
testBooleanProperty(xDocumnetIndex, "UseUpperCase");
testStringOptionalProperty(xDocumnetIndex, "MainEntryCharacterStyleName");
// [readonly, property] sequence <com::sun::star::text::XDocumentIndexMark> DocumentIndexMarks;
// [property] com::sun::star::lang::Locale Locale;
testStringProperty(xDocumnetIndex, "SortAlgorithm", "Value");
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -7,41 +7,36 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SW_QA_API_DOCUMENTSETTINGSTEST_HXX
#define INCLUDED_SW_QA_API_DOCUMENTSETTINGSTEST_HXX
#include "ApiTestBase.hxx"
#include <cppunit/TestAssert.h>
#include <test/text/textdocumentsettings.hxx>
#include <test/unoapi_property_testers.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/uno/Reference.hxx>
using namespace css::uno;
namespace apitest
{
class DocumentSettingsTest : public ApiTestBase
TextDocumentSettings::~TextDocumentSettings() {}
void TextDocumentSettings::testDocumentSettingsProperties()
{
public:
void testDocumentSettingsProperties()
{
css::uno::Reference<css::beans::XPropertySet> xDocumentSettings(init(),
css::uno::UNO_QUERY_THROW);
testBooleanOptionalProperty(xDocumentSettings, "ChartAutoUpdate");
testBooleanOptionalProperty(xDocumentSettings, "AddParaTableSpacing");
testBooleanOptionalProperty(xDocumentSettings, "AddParaTableSpacingAtStart");
testBooleanOptionalProperty(xDocumentSettings, "AlignTabStopPosition");
testBooleanOptionalProperty(xDocumentSettings, "SaveGlobalDocumentLinks");
testBooleanOptionalProperty(xDocumentSettings, "IsLabelDocument");
testBooleanOptionalProperty(xDocumentSettings, "UseFormerLineSpacing");
testBooleanOptionalProperty(xDocumentSettings, "AddParaSpacingToTableCells");
testBooleanOptionalProperty(xDocumentSettings, "UseFormerObjectPositioning");
testBooleanOptionalProperty(xDocumentSettings, "ConsiderTextWrapOnObjPos");
testBooleanOptionalProperty(xDocumentSettings, "MathBaselineAlignment");
}
};
} // end namespace apitest
css::uno::Reference<css::beans::XPropertySet> xDocumentSettings(init(),
css::uno::UNO_QUERY_THROW);
testBooleanOptionalProperty(xDocumentSettings, "ChartAutoUpdate");
testBooleanOptionalProperty(xDocumentSettings, "AddParaTableSpacing");
testBooleanOptionalProperty(xDocumentSettings, "AddParaTableSpacingAtStart");
testBooleanOptionalProperty(xDocumentSettings, "AlignTabStopPosition");
testBooleanOptionalProperty(xDocumentSettings, "SaveGlobalDocumentLinks");
testBooleanOptionalProperty(xDocumentSettings, "IsLabelDocument");
testBooleanOptionalProperty(xDocumentSettings, "UseFormerLineSpacing");
testBooleanOptionalProperty(xDocumentSettings, "AddParaSpacingToTableCells");
testBooleanOptionalProperty(xDocumentSettings, "UseFormerObjectPositioning");
testBooleanOptionalProperty(xDocumentSettings, "ConsiderTextWrapOnObjPos");
testBooleanOptionalProperty(xDocumentSettings, "MathBaselineAlignment");
}
#endif
} // end namespace apitest
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -7,41 +7,33 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SW_QA_API_DOCUMENTINDEXTEST_HXX
#define INCLUDED_SW_QA_API_DOCUMENTINDEXTEST_HXX
#include "ApiTestBase.hxx"
#include <com/sun/star/beans/XPropertySet.hpp>
#include <cppunit/TestAssert.h>
#include <test/unoapi_property_testers.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <test/text/textprintersettings.hxx>
namespace apitest
{
class DocumentIndexTest : public ApiTestBase
TextPrinterSettings::~TextPrinterSettings() {}
void TextPrinterSettings::testPrinterSettingsProperties()
{
public:
void testDocumentIndexProperties()
{
css::uno::Reference<css::beans::XPropertySet> xDocumnetIndex(init(),
css::uno::UNO_QUERY_THROW);
testBooleanProperty(xDocumnetIndex, "UseAlphabeticalSeparators");
testBooleanProperty(xDocumnetIndex, "UseKeyAsEntry");
testBooleanProperty(xDocumnetIndex, "UseCombinedEntries");
testBooleanProperty(xDocumnetIndex, "IsCaseSensitive");
testBooleanProperty(xDocumnetIndex, "UsePP");
testBooleanProperty(xDocumnetIndex, "UseDash");
testBooleanProperty(xDocumnetIndex, "UseUpperCase");
testStringOptionalProperty(xDocumnetIndex, "MainEntryCharacterStyleName");
// [readonly, property] sequence <com::sun::star::text::XDocumentIndexMark> DocumentIndexMarks;
// [property] com::sun::star::lang::Locale Locale;
testStringProperty(xDocumnetIndex, "SortAlgorithm", "Value");
}
};
css::uno::Reference<css::beans::XPropertySet> xPrinterSettings(init(),
css::uno::UNO_QUERY_THROW);
testBooleanProperty(xPrinterSettings, "PrintGraphics");
testBooleanProperty(xPrinterSettings, "PrintTables");
testBooleanProperty(xPrinterSettings, "PrintDrawings");
testBooleanProperty(xPrinterSettings, "PrintLeftPages");
testBooleanProperty(xPrinterSettings, "PrintRightPages");
testBooleanProperty(xPrinterSettings, "PrintControls");
testBooleanProperty(xPrinterSettings, "PrintReversed");
testBooleanProperty(xPrinterSettings, "PrintControls");
testStringProperty(xPrinterSettings, "PrintFaxName", "FaxName");
testBooleanProperty(xPrinterSettings, "PrintProspect");
testBooleanProperty(xPrinterSettings, "PrintPageBackground");
testBooleanProperty(xPrinterSettings, "PrintBlackFonts");
testBooleanOptionalProperty(xPrinterSettings, "PrintEmptyPages");
}
#endif
} // end namespace apitest
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
#include <test/unoapi_property_testers.hxx>
#include <test/text/textsettings.hxx>
namespace
{
bool extstsProperty(css::uno::Reference<css::beans::XPropertySet> const& rxPropertySet,
OUString const& rPropertyName)
{
css::uno::Reference<css::beans::XPropertySetInfo> xPropertySetInfo(
rxPropertySet->getPropertySetInfo());
return xPropertySetInfo->hasPropertyByName(rPropertyName);
}
bool isPropertyReadOnly(css::uno::Reference<css::beans::XPropertySet> const& rxPropertySet,
OUString const& rPropertyName)
{
css::uno::Reference<css::beans::XPropertySetInfo> xPropertySetInfo(
rxPropertySet->getPropertySetInfo());
css::uno::Sequence<css::beans::Property> xProperties = xPropertySetInfo->getProperties();
for (auto const& rProperty : xProperties)
{
if (rProperty.Name == rPropertyName)
return (rProperty.Attributes & com::sun::star::beans::PropertyAttribute::READONLY) != 0;
}
return false;
}
// [property] string PrinterName;
void testPrinterName(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
{
const OUString rPropertyName("PrinterName");
if (!extstsProperty(rxSettings, rPropertyName))
return; // Property is sometimes not set - bug? it is not defined as optional
OUString aPrinterName_Get;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxSettings->getPropertyValue(rPropertyName) >>= aPrinterName_Get);
OUString aPrinterName_Set;
css::uno::Any aNewValue;
aNewValue <<= aPrinterName_Get;
rxSettings->setPropertyValue(rPropertyName, aNewValue);
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxSettings->getPropertyValue(rPropertyName) >>= aPrinterName_Set);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", aPrinterName_Get, aPrinterName_Set);
}
// [optional, property] short PrinterIndependentLayout;
void testPrinterIndependentLayout(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
{
const OUString rPropertyName("PrinterIndependentLayout");
if (!extstsProperty(rxSettings, rPropertyName))
return; // Property is optional
sal_Int16 aValue_Get;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxSettings->getPropertyValue(rPropertyName) >>= aValue_Get);
sal_Int16 aValue_New;
aValue_New = (aValue_Get == 1 ? 3 : 1);
rxSettings->setPropertyValue(rPropertyName, css::uno::Any(aValue_New));
sal_Int16 aValue_Set;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxSettings->getPropertyValue(rPropertyName) >>= aValue_Set);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue", aValue_New, aValue_Set);
}
// [optional, property] com::sun::star::i18n::XForbiddenCharacters ForbiddenCharacters;
void testForbiddenCharacters(css::uno::Reference<css::beans::XPropertySet> const& rxSettings)
{
const OUString rPropertyName("ForbiddenCharacters");
if (!extstsProperty(rxSettings, rPropertyName))
return; // Property is optional
CPPUNIT_ASSERT_MESSAGE("Property is read-only but shouldn't be",
!isPropertyReadOnly(rxSettings, rPropertyName));
css::uno::Reference<css::i18n::XForbiddenCharacters> aValue_Get;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue",
rxSettings->getPropertyValue(rPropertyName) >>= aValue_Get);
CPPUNIT_ASSERT_MESSAGE("Empty reference to XForbiddenCharacters", aValue_Get.is());
}
}
namespace apitest
{
TextSettings::~TextSettings() {}
void TextSettings::testSettingsProperties()
{
css::uno::Reference<css::beans::XPropertySet> xSettings(init(), css::uno::UNO_QUERY_THROW);
testForbiddenCharacters(xSettings);
//testShortOptionalProperty(xSettings, "LinkUpdateMode");
testPrinterName(xSettings);
// [property] sequence< byte > PrinterSetup;
testBooleanOptionalProperty(xSettings, "IsKernAsianPunctuation");
//testShortOptionalProperty(xSettings, "CharacterCompressionType");
testBooleanOptionalProperty(xSettings, "ApplyUserData");
testBooleanOptionalProperty(xSettings, "SaveVersionOnClose");
testBooleanOptionalProperty(xSettings, "UpdateFromTemplate");
testBooleanOptionalProperty(xSettings, "FieldAutoUpdate");
testStringOptionalProperty(xSettings, "CurrentDatabaseDataSource");
testStringOptionalProperty(xSettings, "CurrentDatabaseCommand");
testLongOptionalProperty(xSettings, "CurrentDatabaseCommandType");
testLongOptionalProperty(xSettings, "DefaultTabStop");
testBooleanOptionalProperty(xSettings, "IsPrintBooklet");
testBooleanOptionalProperty(xSettings, "IsPrintBookletFront");
testBooleanOptionalProperty(xSettings, "IsPrintBookletBack");
testLongOptionalProperty(xSettings, "PrintQuality");
testStringOptionalProperty(xSettings, "ColorTableURL");
testStringOptionalProperty(xSettings, "DashTableURL");
testStringOptionalProperty(xSettings, "LineEndTableURL");
testStringOptionalProperty(xSettings, "HatchTableURL");
testStringOptionalProperty(xSettings, "GradientTableURL");
testStringOptionalProperty(xSettings, "BitmapTableURL");
testBooleanOptionalProperty(xSettings, "AutoCalculate");
testPrinterIndependentLayout(xSettings);
testBooleanOptionalProperty(xSettings, "AddExternalLeading");
testBooleanOptionalProperty(xSettings, "EmbedFonts");
testBooleanOptionalProperty(xSettings, "EmbedSystemFonts");
testBooleanOptionalProperty(xSettings, "EmbedOnlyUsedFonts");
testBooleanOptionalProperty(xSettings, "EmbedLatinScriptFonts");
testBooleanOptionalProperty(xSettings, "EmbedAsianScriptFonts");
testBooleanOptionalProperty(xSettings, "EmbedComplexScriptFonts");
}
} // end namespace apitest
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -7,55 +7,61 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SW_QA_API_XTEXTCONTENTTEST_HXX
#define INCLUDED_SW_QA_API_XTEXTCONTENTTEST_HXX
#include "ApiTestBase.hxx"
#include <cppunit/TestAssert.h>
#include <test/unoapi_property_testers.hxx>
#include <cppunit/extensions/HelperMacros.h>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/XDocumentIndex.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <test/unoapi_property_testers.hxx>
#include <test/text/xdocumentindex.hxx>
namespace apitest
{
class XTextContentTest : public ApiTestBase
XDocumentIndex::~XDocumentIndex() {}
/**
* Gets the document from relation and insert a new index mark.
* Then it stores the text content of document index before
* update and after.<p>
*
* Has <b> OK </b> status if index content is changed and
* new index contains index mark inserted. <p>
*/
void XDocumentIndex::testUpdate()
{
public:
virtual css::uno::Reference<css::text::XTextDocument> getTextDocument() = 0;
/**
* Tries to attach the text content to the test range
* gotten with getAnchor(). If relations are found
* then they are used for testing. <p>
*
* The test is OK if the method works without error.
*/
void testAttach()
{
css::uno::Reference<css::text::XTextContent> xTextContent(init(),
css::uno::Reference<css::text::XDocumentIndex> xDocumentIndex(init(),
css::uno::UNO_QUERY_THROW);
auto xTextCursor = getTextDocument()->getText()->createTextCursor();
xTextCursor->gotoEnd(false);
css::uno::Reference<css::lang::XMultiServiceFactory> xMSF(getTextDocument(),
css::uno::UNO_QUERY_THROW);
css::uno::Reference<css::text::XDocumentIndex> xDocumentIndex(
xMSF->createInstance("com.sun.star.text.DocumentIndex"), css::uno::UNO_QUERY_THROW);
xDocumentIndex->attach(xTextCursor);
}
void testGetAnchor()
bool bOK = true;
try
{
css::uno::Reference<css::text::XTextContent> xTextContent(init(),
css::uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(OUString(""), xTextContent->getAnchor()->getString());
auto xText = getTextDocument()->getText();
auto xTextRange = xText->getEnd();
xTextRange->setString("IndexMark");
css::uno::Reference<css::lang::XMultiServiceFactory> xFactory(getTextDocument(),
css::uno::UNO_QUERY_THROW);
css::uno::Reference<css::text::XTextContent> xTextContentMark(
xFactory->createInstance("com.sun.star.text.DocumentIndexMark"),
css::uno::UNO_QUERY_THROW);
xText->insertTextContent(xTextRange, xTextContentMark, true);
}
};
}
catch (css::uno::Exception /*exception*/)
{
bOK = false;
}
CPPUNIT_ASSERT_MESSAGE("Couldn't create the document index mark", bOK);
OUString sContentBefore = xDocumentIndex->getAnchor()->getString();
xDocumentIndex->update();
OUString sContentAfter = xDocumentIndex->getAnchor()->getString();
#endif
CPPUNIT_ASSERT_MESSAGE("Before and after shouldn't be equal", sContentBefore != sContentAfter);
CPPUNIT_ASSERT_MESSAGE("Content after should contain string 'IndexMark'",
sContentAfter.indexOf("IndexMark") >= 0);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment