summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Lippert <drtl@fastmail.fm>2015-08-06 20:30:28 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-08-13 07:01:23 +0000
commit5d81c9f24fbe48a0717640c1ba6bcf882b9358e2 (patch)
tree2a45a2616d33f7bdd74555fbe5cde6180e583fec
parentb73d8b16d5509d54460189547746352d5454448c (diff)
tdf#85872 ToxLinkProcessor correct header and tests
commit 6b9ab853b6a5fa71c0b6c594ed0e6e6016d13a3b changed the behavior of the class, but the header comments were not updated. This commit adds comments for the new behavior. Also: The tested behavior in the unittest was changed. This commit adapts the unittest name to the new behavior. Change-Id: Ia364ebbc3e2bfe1b0b8e3e26269a3c162e1a05d1 Reviewed-on: https://gerrit.libreoffice.org/17510 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r--sw/inc/ToxLinkProcessor.hxx5
-rw-r--r--sw/qa/core/test_ToxLinkProcessor.cxx22
2 files changed, 23 insertions, 4 deletions
diff --git a/sw/inc/ToxLinkProcessor.hxx b/sw/inc/ToxLinkProcessor.hxx
index a8b06d0bdf95..3887121e06dc 100644
--- a/sw/inc/ToxLinkProcessor.hxx
+++ b/sw/inc/ToxLinkProcessor.hxx
@@ -34,7 +34,10 @@ public:
/** Close a link which has been found during processing.
*
- * @throw std::runtime_error If there are no open links.
+ * @internal
+ * If you close more links than were opened, then the method will behave
+ * as if a start link was opened at position 0 with the character style
+ * STR_POOLCHR_TOXJUMP.
*/
void
CloseLink(sal_Int32 endPosition, const OUString& url);
diff --git a/sw/qa/core/test_ToxLinkProcessor.cxx b/sw/qa/core/test_ToxLinkProcessor.cxx
index e768c210ce2b..660d7458a7f1 100644
--- a/sw/qa/core/test_ToxLinkProcessor.cxx
+++ b/sw/qa/core/test_ToxLinkProcessor.cxx
@@ -20,22 +20,27 @@
#include <cppunit/plugin/TestPlugIn.h>
#include <test/bootstrapfixture.hxx>
+#include <poolfmt.hrc>
#include <swdll.hxx>
+#include "swtypes.hxx"
+#include "SwStyleNameMapper.hxx"
using namespace sw;
class ToxLinkProcessorTest : public test::BootstrapFixture
{
- void ExceptionIsThrownIfTooManyLinksAreClosed();
+ void NoExceptionIsThrownIfTooManyLinksAreClosed();
void AddingAndClosingTwoLinksResultsInTwoClosedLinks();
void LinkIsCreatedCorrectly();
void LinkSequenceIsPreserved();
+ void StandardOpenLinkIsAddedWhenMoreLinksThanAvaiableAreClosed();
CPPUNIT_TEST_SUITE(ToxLinkProcessorTest);
- CPPUNIT_TEST(ExceptionIsThrownIfTooManyLinksAreClosed);
+ CPPUNIT_TEST(NoExceptionIsThrownIfTooManyLinksAreClosed);
CPPUNIT_TEST(AddingAndClosingTwoLinksResultsInTwoClosedLinks);
CPPUNIT_TEST(LinkIsCreatedCorrectly);
CPPUNIT_TEST(LinkSequenceIsPreserved);
+ CPPUNIT_TEST(StandardOpenLinkIsAddedWhenMoreLinksThanAvaiableAreClosed);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() SAL_OVERRIDE {
@@ -59,7 +64,7 @@ const sal_uInt16 ToxLinkProcessorTest::POOL_ID_1 = 42;
const sal_uInt16 ToxLinkProcessorTest::POOL_ID_2 = 43;
void
-ToxLinkProcessorTest::ExceptionIsThrownIfTooManyLinksAreClosed()
+ToxLinkProcessorTest::NoExceptionIsThrownIfTooManyLinksAreClosed()
{
ToxLinkProcessor sut;
sut.StartNewLink(0, STYLE_NAME_1);
@@ -70,6 +75,17 @@ ToxLinkProcessorTest::ExceptionIsThrownIfTooManyLinksAreClosed()
}
void
+ToxLinkProcessorTest::StandardOpenLinkIsAddedWhenMoreLinksThanAvaiableAreClosed()
+{
+ ToxLinkProcessor sut;
+ sut.StartNewLink(0, STYLE_NAME_1);
+ sut.CloseLink(1, URL_1);
+ sut.CloseLink(1, URL_1);
+ CPPUNIT_ASSERT_EQUAL(2u, static_cast<unsigned>(sut.mClosedLinks.size()));
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned>(sut.mClosedLinks.at(1).mEndTextPos));
+}
+
+void
ToxLinkProcessorTest::AddingAndClosingTwoLinksResultsInTwoClosedLinks()
{
ToxLinkProcessor sut;