summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2018-10-15 16:14:02 +0200
committerCaolán McNamara <caolanm@redhat.com>2018-10-16 12:35:28 +0200
commit48d22544be09bf63ded8eb48d1f8252b456f7fd5 (patch)
tree008bac42a20651889adc416078ca56f6929b6e95
parentf3961ea18cf4f80d231f6bc63320af1454d1e7e9 (diff)
sw: merge test suites sw_unoapi and sw_unowriter
Both test suites have the same propose "Test to assert UNO API call results of Writer" so better to keep them together. Change-Id: I0ef7c28856a374dca3edcec73fd98a96c5067527 Reviewed-on: https://gerrit.libreoffice.org/61794 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/CppunitTest_sw_unoapi.mk62
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/qa/extras/unowriter/data/xautotextgroup.odt (renamed from sw/qa/unit/data/xautotextgroup.odt)bin11151 -> 11151 bytes
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx230
-rw-r--r--sw/qa/unit/unoapi.cxx235
5 files changed, 217 insertions, 311 deletions
diff --git a/sw/CppunitTest_sw_unoapi.mk b/sw/CppunitTest_sw_unoapi.mk
deleted file mode 100644
index 3a7403169ec3..000000000000
--- a/sw/CppunitTest_sw_unoapi.mk
+++ /dev/null
@@ -1,62 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#*************************************************************************
-#
-# 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/.
-#
-#*************************************************************************
-
-$(eval $(call gb_CppunitTest_CppunitTest,sw_unoapi))
-
-$(eval $(call gb_CppunitTest_add_exception_objects,sw_unoapi, \
- sw/qa/unit/unoapi \
-))
-
-$(eval $(call gb_CppunitTest_use_libraries,sw_unoapi, \
- comphelper \
- cppu \
- cppuhelper \
- editeng \
- i18nlangtag \
- sal \
- sfx \
- svl \
- svt \
- sw \
- test \
- tl \
- unotest \
- utl \
- vcl \
-))
-
-$(eval $(call gb_CppunitTest_use_externals,sw_unoapi,\
- boost_headers \
- libxml2 \
-))
-
-$(eval $(call gb_CppunitTest_set_include,sw_unoapi,\
- -I$(SRCDIR)/sw/inc \
- -I$(SRCDIR)/sw/source/core/inc \
- -I$(SRCDIR)/sw/source/uibase/inc \
- -I$(SRCDIR)/sw/qa/extras/inc \
- $$(INCLUDE) \
-))
-
-$(eval $(call gb_CppunitTest_use_api,sw_unoapi,\
- udkapi \
- offapi \
- oovbaapi \
-))
-
-$(eval $(call gb_CppunitTest_use_ure,sw_unoapi))
-$(eval $(call gb_CppunitTest_use_vcl,sw_unoapi))
-
-$(eval $(call gb_CppunitTest_use_rdb,sw_unoapi,services))
-
-$(eval $(call gb_CppunitTest_use_configuration,sw_unoapi))
-
-# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 0d41a854c66a..43f2abdc60ce 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -97,7 +97,6 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_accessible_relation_set \
CppunitTest_sw_apitests \
CppunitTest_sw_unowriter \
- CppunitTest_sw_unoapi \
))
ifneq ($(DISABLE_GUI),TRUE)
diff --git a/sw/qa/unit/data/xautotextgroup.odt b/sw/qa/extras/unowriter/data/xautotextgroup.odt
index e1cb9e7ea052..e1cb9e7ea052 100644
--- a/sw/qa/unit/data/xautotextgroup.odt
+++ b/sw/qa/extras/unowriter/data/xautotextgroup.odt
Binary files differ
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx
index 96945d25a40f..933e17b928bb 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -10,6 +10,14 @@
#include <swmodeltestbase.hxx>
#include <com/sun/star/awt/FontSlant.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/text/AutoTextContainer.hpp>
+#include <com/sun/star/text/XAutoTextGroup.hpp>
+#include <com/sun/star/rdf/URI.hpp>
+#include <com/sun/star/rdf/URIs.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
namespace
{
@@ -20,18 +28,55 @@ char const DATA_DIRECTORY[] = "/sw/qa/extras/unowriter/data/";
class SwUnoWriter : public SwModelTestBase
{
public:
- void testDefaultCharStyle();
- void testGraphicDesciptorURL();
- void testGraphicDesciptorURLBitmap();
-
- CPPUNIT_TEST_SUITE(SwUnoWriter);
- CPPUNIT_TEST(testDefaultCharStyle);
- CPPUNIT_TEST(testGraphicDesciptorURL);
- CPPUNIT_TEST(testGraphicDesciptorURLBitmap);
- CPPUNIT_TEST_SUITE_END();
+ SwUnoWriter()
+ : SwModelTestBase(DATA_DIRECTORY, "writer8")
+ {
+ }
};
-void SwUnoWriter::testDefaultCharStyle()
+/**
+ * Macro to declare a new test with preloaded file
+ * (similar to DECLARE_SW_ROUNDTRIP_TEST)
+ */
+#define DECLARE_UNOAPI_TEST_FILE(TestName, filename) \
+ class TestName : public SwUnoWriter \
+ { \
+ protected: \
+ virtual OUString getTestName() override { return OUString(#TestName); } \
+ \
+ public: \
+ CPPUNIT_TEST_SUITE(TestName); \
+ CPPUNIT_TEST(loadAndTest); \
+ CPPUNIT_TEST_SUITE_END(); \
+ void loadAndTest() \
+ { \
+ load(mpTestDocumentPath, filename); \
+ runTest(); \
+ } \
+ void runTest(); \
+ }; \
+ CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \
+ void TestName::runTest()
+
+/**
+ * Macro to declare a new test without loading any files
+ */
+#define DECLARE_UNOAPI_TEST(TestName) \
+ class TestName : public SwUnoWriter \
+ { \
+ protected: \
+ virtual OUString getTestName() override { return OUString(#TestName); } \
+ \
+ public: \
+ CPPUNIT_TEST_SUITE(TestName); \
+ CPPUNIT_TEST(runTest); \
+ CPPUNIT_TEST_SUITE_END(); \
+ void runTest(); \
+ }; \
+ CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \
+ void TestName::runTest()
+
+DECLARE_UNOAPI_TEST(testDefaultCharStyle)
{
// Create a new document, type a character, set its char style to Emphasis
// and assert the style was set.
@@ -57,7 +102,7 @@ void SwUnoWriter::testDefaultCharStyle()
getProperty<awt::FontSlant>(xCursorProps, "CharPosture"));
}
-void SwUnoWriter::testGraphicDesciptorURL()
+DECLARE_UNOAPI_TEST(testGraphicDesciptorURL)
{
loadURL("private:factory/swriter", nullptr);
@@ -84,7 +129,7 @@ void SwUnoWriter::testGraphicDesciptorURL()
CPPUNIT_ASSERT(xGraphic.is());
}
-void SwUnoWriter::testGraphicDesciptorURLBitmap()
+DECLARE_UNOAPI_TEST(testGraphicDesciptorURLBitmap)
{
loadURL("private:factory/swriter", nullptr);
@@ -115,7 +160,166 @@ void SwUnoWriter::testGraphicDesciptorURLBitmap()
CPPUNIT_ASSERT(xGraphic.is());
}
-CPPUNIT_TEST_SUITE_REGISTRATION(SwUnoWriter);
+static bool ensureAutoTextExistsByTitle(const Reference<XAutoTextGroup>& autoTextGroup,
+ const OUString& autoTextName)
+{
+ uno::Sequence<OUString> aTitles(autoTextGroup->getTitles());
+ for (const auto& rTitle : aTitles)
+ {
+ if (rTitle == autoTextName)
+ return true;
+ }
+ return false;
+}
+
+static bool ensureAutoTextExistsByName(const Reference<XAutoTextGroup>& autoTextGroup,
+ const OUString& autoTextName)
+{
+ uno::Sequence<OUString> aTitles(autoTextGroup->getElementNames());
+ for (const auto& rTitle : aTitles)
+ {
+ if (rTitle == autoTextName)
+ return true;
+ }
+ return false;
+}
+
+DECLARE_UNOAPI_TEST_FILE(testXAutoTextGroup, "xautotextgroup.odt")
+{
+ Reference<XAutoTextContainer> xAutoTextContainer
+ = AutoTextContainer::create(comphelper::getProcessComponentContext());
+
+ uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
+
+ const OUString sGroupName = "TestGroup*1";
+ const OUString sTextName = "TEST";
+ const OUString sTextNameNew = "TESTRENAMED";
+ const OUString sTextTitle = "Test Auto Text";
+ const OUString sTextTitleNew = "Test Auto Text Renamed";
+
+ // Create new temporary group
+ Reference<XAutoTextGroup> xAutoTextGroup(xAutoTextContainer->insertNewByName(sGroupName),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE("AutoTextGroup was not found!", xAutoTextGroup.is());
+
+ // Insert new element and ensure it exists
+ Reference<XAutoTextEntry> xAutoTextEntry
+ = xAutoTextGroup->insertNewByName(sTextName, sTextTitle, xTextRange);
+ CPPUNIT_ASSERT_MESSAGE("AutoText was not inserted!", xAutoTextEntry.is());
+ CPPUNIT_ASSERT_MESSAGE("Can't find newly created AutoText by title!",
+ ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitle));
+ CPPUNIT_ASSERT_MESSAGE("Can't find newly created AutoText by name!",
+ ensureAutoTextExistsByName(xAutoTextGroup, sTextName));
+
+ // Insert once again the same should throw an exception
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on insertion of same AutoText",
+ xAutoTextGroup->insertNewByName(sTextName, sTextTitle, xTextRange),
+ container::ElementExistException);
+
+ // Rename it & ensure everything is ok
+ xAutoTextGroup->renameByName(sTextName, sTextNameNew, sTextTitleNew);
+ CPPUNIT_ASSERT_MESSAGE("Can't find renamed AutoText by title!",
+ ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitleNew));
+ CPPUNIT_ASSERT_MESSAGE("Can't find renamed AutoText by name!",
+ ensureAutoTextExistsByName(xAutoTextGroup, sTextNameNew));
+ // Not found by old names
+ CPPUNIT_ASSERT_MESSAGE("Found AutoText by old title!",
+ !ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitle));
+ CPPUNIT_ASSERT_MESSAGE("Found AutoText by old name!",
+ !ensureAutoTextExistsByName(xAutoTextGroup, sTextName));
+
+ // Rename not existing should throw an exception
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "We expect an exception on renaming not-exising AutoText",
+ xAutoTextGroup->renameByName(sTextName, sTextNameNew, sTextTitleNew),
+ container::ElementExistException);
+
+ // Remove it and ensure it does not exist
+ xAutoTextGroup->removeByName(sTextNameNew);
+ CPPUNIT_ASSERT_MESSAGE("AutoText was not removed!",
+ !ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitleNew));
+ CPPUNIT_ASSERT_MESSAGE("AutoText was not removed!",
+ !ensureAutoTextExistsByName(xAutoTextGroup, sTextNameNew));
+
+ // Remove non-existing element should throw an exception
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on removing not-existing AutoText",
+ xAutoTextGroup->removeByName(sTextName),
+ container::NoSuchElementException);
+
+ // Remove our temporary group
+ xAutoTextContainer->removeByName(sGroupName);
+}
+
+DECLARE_UNOAPI_TEST(testXURI)
+{
+ Reference<XComponentContext> xContext(::comphelper::getProcessComponentContext());
+
+ // createKnown()
+ Reference<rdf::XURI> xURIcreateKnown(rdf::URI::createKnown(xContext, rdf::URIs::ODF_PREFIX),
+ UNO_SET_THROW);
+ CPPUNIT_ASSERT(xURIcreateKnown.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://docs.oasis-open.org/ns/office/1.2/meta/odf#"),
+ xURIcreateKnown->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("prefix"), xURIcreateKnown->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://docs.oasis-open.org/ns/office/1.2/meta/odf#prefix"),
+ xURIcreateKnown->getStringValue());
+
+ // createKnown() with invalid constant
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid constant",
+ rdf::URI::createKnown(xContext, 12345),
+ lang::IllegalArgumentException);
+
+ // create()
+ Reference<rdf::XURI> xURIcreate(rdf::URI::create(xContext, "http://example.com/url#somedata"),
+ UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#"), xURIcreate->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("somedata"), xURIcreate->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#somedata"), xURIcreate->getStringValue());
+
+ // create() without local name splitted with "/"
+ Reference<rdf::XURI> xURIcreate2(rdf::URI::create(xContext, "http://example.com/url"),
+ UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/"), xURIcreate2->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("url"), xURIcreate2->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url"), xURIcreate2->getStringValue());
+
+ // create() without prefix
+ Reference<rdf::XURI> xURIcreate3(rdf::URI::create(xContext, "#somedata"), UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("#"), xURIcreate3->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("somedata"), xURIcreate3->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("#somedata"), xURIcreate3->getStringValue());
+
+ // create() with invalid URI
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid URI",
+ rdf::URI::create(xContext, "some junk and not URI"),
+ lang::IllegalArgumentException);
+
+ // createNS()
+ Reference<rdf::XURI> xURIcreateNS(
+ rdf::URI::createNS(xContext, "http://example.com/url#", "somedata"), UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#"), xURIcreateNS->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("somedata"), xURIcreateNS->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#somedata"),
+ xURIcreateNS->getStringValue());
+
+ // TODO: What's going on here? Is such usecase valid?
+ Reference<rdf::XURI> xURIcreateNS2(
+ rdf::URI::createNS(xContext, "http://example.com/url", "somedata"), UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/"), xURIcreateNS2->getNamespace());
+ CPPUNIT_ASSERT_EQUAL(OUString("urlsomedata"), xURIcreateNS2->getLocalName());
+ CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/urlsomedata"),
+ xURIcreateNS2->getStringValue());
+
+ // createNS() some invalid cases
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid URI",
+ rdf::URI::createNS(xContext, "bla", "bla"),
+ lang::IllegalArgumentException);
+
+ CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid URI",
+ rdf::URI::createNS(xContext, OUString(), OUString()),
+ lang::IllegalArgumentException);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/unit/unoapi.cxx b/sw/qa/unit/unoapi.cxx
deleted file mode 100644
index cc08d5d440c9..000000000000
--- a/sw/qa/unit/unoapi.cxx
+++ /dev/null
@@ -1,235 +0,0 @@
-/* -*- 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 <swmodeltestbase.hxx>
-
-#include <comphelper/processfactory.hxx>
-#include <comphelper/string.hxx>
-
-#include <com/sun/star/text/AutoTextContainer.hpp>
-#include <com/sun/star/text/XAutoTextGroup.hpp>
-
-#include <com/sun/star/rdf/URI.hpp>
-#include <com/sun/star/rdf/URIs.hpp>
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::text;
-
-class UnoApiTest : public SwModelTestBase
-{
-public:
- UnoApiTest()
- : SwModelTestBase("sw/qa/unit/data/", "writer8")
- {
- }
-};
-
-/**
- * Macro to declare a new test with preloaded file
- * (similar to DECLARE_SW_ROUNDTRIP_TEST)
- */
-#define DECLARE_UNOAPI_TEST_FILE(TestName, filename) \
- class TestName : public UnoApiTest \
- { \
- protected: \
- virtual OUString getTestName() override { return OUString(#TestName); } \
- \
- public: \
- CPPUNIT_TEST_SUITE(TestName); \
- CPPUNIT_TEST(loadAndTest); \
- CPPUNIT_TEST_SUITE_END(); \
- void loadAndTest() \
- { \
- load(mpTestDocumentPath, filename); \
- runTest(); \
- } \
- void runTest(); \
- }; \
- CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \
- void TestName::runTest()
-
-/**
- * Macro to declare a new test without loading any files
- */
-#define DECLARE_UNOAPI_TEST(TestName) \
- class TestName : public CppUnit::TestFixture \
- { \
- public: \
- CPPUNIT_TEST_SUITE(TestName); \
- CPPUNIT_TEST(runTest); \
- CPPUNIT_TEST_SUITE_END(); \
- void runTest(); \
- }; \
- CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \
- void TestName::runTest()
-
-static bool ensureAutoTextExistsByTitle(const Reference<XAutoTextGroup>& autoTextGroup,
- const OUString& autoTextName)
-{
- uno::Sequence<OUString> aTitles(autoTextGroup->getTitles());
- for (const auto& rTitle : aTitles)
- {
- if (rTitle == autoTextName)
- return true;
- }
- return false;
-}
-
-static bool ensureAutoTextExistsByName(const Reference<XAutoTextGroup>& autoTextGroup,
- const OUString& autoTextName)
-{
- uno::Sequence<OUString> aTitles(autoTextGroup->getElementNames());
- for (const auto& rTitle : aTitles)
- {
- if (rTitle == autoTextName)
- return true;
- }
- return false;
-}
-
-DECLARE_UNOAPI_TEST_FILE(testXAutoTextGroup, "xautotextgroup.odt")
-{
- Reference<XAutoTextContainer> xAutoTextContainer
- = AutoTextContainer::create(comphelper::getProcessComponentContext());
-
- uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
-
- const OUString sGroupName = "TestGroup*1";
- const OUString sTextName = "TEST";
- const OUString sTextNameNew = "TESTRENAMED";
- const OUString sTextTitle = "Test Auto Text";
- const OUString sTextTitleNew = "Test Auto Text Renamed";
-
- // Create new temporary group
- Reference<XAutoTextGroup> xAutoTextGroup(xAutoTextContainer->insertNewByName(sGroupName),
- uno::UNO_QUERY);
- CPPUNIT_ASSERT_MESSAGE("AutoTextGroup was not found!", xAutoTextGroup.is());
-
- // Insert new element and ensure it exists
- Reference<XAutoTextEntry> xAutoTextEntry
- = xAutoTextGroup->insertNewByName(sTextName, sTextTitle, xTextRange);
- CPPUNIT_ASSERT_MESSAGE("AutoText was not inserted!", xAutoTextEntry.is());
- CPPUNIT_ASSERT_MESSAGE("Can't find newly created AutoText by title!",
- ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitle));
- CPPUNIT_ASSERT_MESSAGE("Can't find newly created AutoText by name!",
- ensureAutoTextExistsByName(xAutoTextGroup, sTextName));
-
- // Insert once again the same should throw an exception
- CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on insertion of same AutoText",
- xAutoTextGroup->insertNewByName(sTextName, sTextTitle, xTextRange),
- container::ElementExistException);
-
- // Rename it & ensure everything is ok
- xAutoTextGroup->renameByName(sTextName, sTextNameNew, sTextTitleNew);
- CPPUNIT_ASSERT_MESSAGE("Can't find renamed AutoText by title!",
- ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitleNew));
- CPPUNIT_ASSERT_MESSAGE("Can't find renamed AutoText by name!",
- ensureAutoTextExistsByName(xAutoTextGroup, sTextNameNew));
- // Not found by old names
- CPPUNIT_ASSERT_MESSAGE("Found AutoText by old title!",
- !ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitle));
- CPPUNIT_ASSERT_MESSAGE("Found AutoText by old name!",
- !ensureAutoTextExistsByName(xAutoTextGroup, sTextName));
-
- // Rename not existing should throw an exception
- CPPUNIT_ASSERT_THROW_MESSAGE(
- "We expect an exception on renaming not-exising AutoText",
- xAutoTextGroup->renameByName(sTextName, sTextNameNew, sTextTitleNew),
- container::ElementExistException);
-
- // Remove it and ensure it does not exist
- xAutoTextGroup->removeByName(sTextNameNew);
- CPPUNIT_ASSERT_MESSAGE("AutoText was not removed!",
- !ensureAutoTextExistsByTitle(xAutoTextGroup, sTextTitleNew));
- CPPUNIT_ASSERT_MESSAGE("AutoText was not removed!",
- !ensureAutoTextExistsByName(xAutoTextGroup, sTextNameNew));
-
- // Remove non-existing element should throw an exception
- CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on removing not-existing AutoText",
- xAutoTextGroup->removeByName(sTextName),
- container::NoSuchElementException);
-
- // Remove our temporary group
- xAutoTextContainer->removeByName(sGroupName);
-}
-
-DECLARE_UNOAPI_TEST(testXURI)
-{
- Reference<XComponentContext> xContext(::comphelper::getProcessComponentContext());
-
- // createKnown()
- Reference<rdf::XURI> xURIcreateKnown(rdf::URI::createKnown(xContext, rdf::URIs::ODF_PREFIX),
- UNO_SET_THROW);
- CPPUNIT_ASSERT(xURIcreateKnown.is());
- CPPUNIT_ASSERT_EQUAL(OUString("http://docs.oasis-open.org/ns/office/1.2/meta/odf#"),
- xURIcreateKnown->getNamespace());
- CPPUNIT_ASSERT_EQUAL(OUString("prefix"), xURIcreateKnown->getLocalName());
- CPPUNIT_ASSERT_EQUAL(OUString("http://docs.oasis-open.org/ns/office/1.2/meta/odf#prefix"),
- xURIcreateKnown->getStringValue());
-
- // createKnown() with invalid constant
- CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid constant",
- rdf::URI::createKnown(xContext, 12345),
- lang::IllegalArgumentException);
-
- // create()
- Reference<rdf::XURI> xURIcreate(rdf::URI::create(xContext, "http://example.com/url#somedata"),
- UNO_SET_THROW);
- CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#"), xURIcreate->getNamespace());
- CPPUNIT_ASSERT_EQUAL(OUString("somedata"), xURIcreate->getLocalName());
- CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#somedata"), xURIcreate->getStringValue());
-
- // create() without local name splitted with "/"
- Reference<rdf::XURI> xURIcreate2(rdf::URI::create(xContext, "http://example.com/url"),
- UNO_SET_THROW);
- CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/"), xURIcreate2->getNamespace());
- CPPUNIT_ASSERT_EQUAL(OUString("url"), xURIcreate2->getLocalName());
- CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url"), xURIcreate2->getStringValue());
-
- // create() without prefix
- Reference<rdf::XURI> xURIcreate3(rdf::URI::create(xContext, "#somedata"), UNO_SET_THROW);
- CPPUNIT_ASSERT_EQUAL(OUString("#"), xURIcreate3->getNamespace());
- CPPUNIT_ASSERT_EQUAL(OUString("somedata"), xURIcreate3->getLocalName());
- CPPUNIT_ASSERT_EQUAL(OUString("#somedata"), xURIcreate3->getStringValue());
-
- // create() with invalid URI
- CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid URI",
- rdf::URI::create(xContext, "some junk and not URI"),
- lang::IllegalArgumentException);
-
- // createNS()
- Reference<rdf::XURI> xURIcreateNS(
- rdf::URI::createNS(xContext, "http://example.com/url#", "somedata"), UNO_SET_THROW);
- CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#"), xURIcreateNS->getNamespace());
- CPPUNIT_ASSERT_EQUAL(OUString("somedata"), xURIcreateNS->getLocalName());
- CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/url#somedata"),
- xURIcreateNS->getStringValue());
-
- // TODO: What's going on here? Is such usecase valid?
- Reference<rdf::XURI> xURIcreateNS2(
- rdf::URI::createNS(xContext, "http://example.com/url", "somedata"), UNO_SET_THROW);
- CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/"), xURIcreateNS2->getNamespace());
- CPPUNIT_ASSERT_EQUAL(OUString("urlsomedata"), xURIcreateNS2->getLocalName());
- CPPUNIT_ASSERT_EQUAL(OUString("http://example.com/urlsomedata"),
- xURIcreateNS2->getStringValue());
-
- // createNS() some invalid cases
- CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid URI",
- rdf::URI::createNS(xContext, "bla", "bla"),
- lang::IllegalArgumentException);
-
- CPPUNIT_ASSERT_THROW_MESSAGE("We expect an exception on invalid URI",
- rdf::URI::createNS(xContext, OUString(), OUString()),
- lang::IllegalArgumentException);
-}
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */