Kaydet (Commit) 5d81c9f2 authored tarafından Tobias Lippert's avatar Tobias Lippert Kaydeden (comit) Noel Grandin

tdf#85872 ToxLinkProcessor correct header and tests

commit 6b9ab853 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/17510Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst b73d8b16
...@@ -34,7 +34,10 @@ public: ...@@ -34,7 +34,10 @@ public:
/** Close a link which has been found during processing. /** 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 void
CloseLink(sal_Int32 endPosition, const OUString& url); CloseLink(sal_Int32 endPosition, const OUString& url);
......
...@@ -20,22 +20,27 @@ ...@@ -20,22 +20,27 @@
#include <cppunit/plugin/TestPlugIn.h> #include <cppunit/plugin/TestPlugIn.h>
#include <test/bootstrapfixture.hxx> #include <test/bootstrapfixture.hxx>
#include <poolfmt.hrc>
#include <swdll.hxx> #include <swdll.hxx>
#include "swtypes.hxx"
#include "SwStyleNameMapper.hxx"
using namespace sw; using namespace sw;
class ToxLinkProcessorTest : public test::BootstrapFixture class ToxLinkProcessorTest : public test::BootstrapFixture
{ {
void ExceptionIsThrownIfTooManyLinksAreClosed(); void NoExceptionIsThrownIfTooManyLinksAreClosed();
void AddingAndClosingTwoLinksResultsInTwoClosedLinks(); void AddingAndClosingTwoLinksResultsInTwoClosedLinks();
void LinkIsCreatedCorrectly(); void LinkIsCreatedCorrectly();
void LinkSequenceIsPreserved(); void LinkSequenceIsPreserved();
void StandardOpenLinkIsAddedWhenMoreLinksThanAvaiableAreClosed();
CPPUNIT_TEST_SUITE(ToxLinkProcessorTest); CPPUNIT_TEST_SUITE(ToxLinkProcessorTest);
CPPUNIT_TEST(ExceptionIsThrownIfTooManyLinksAreClosed); CPPUNIT_TEST(NoExceptionIsThrownIfTooManyLinksAreClosed);
CPPUNIT_TEST(AddingAndClosingTwoLinksResultsInTwoClosedLinks); CPPUNIT_TEST(AddingAndClosingTwoLinksResultsInTwoClosedLinks);
CPPUNIT_TEST(LinkIsCreatedCorrectly); CPPUNIT_TEST(LinkIsCreatedCorrectly);
CPPUNIT_TEST(LinkSequenceIsPreserved); CPPUNIT_TEST(LinkSequenceIsPreserved);
CPPUNIT_TEST(StandardOpenLinkIsAddedWhenMoreLinksThanAvaiableAreClosed);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
public: public:
void setUp() SAL_OVERRIDE { void setUp() SAL_OVERRIDE {
...@@ -59,7 +64,7 @@ const sal_uInt16 ToxLinkProcessorTest::POOL_ID_1 = 42; ...@@ -59,7 +64,7 @@ const sal_uInt16 ToxLinkProcessorTest::POOL_ID_1 = 42;
const sal_uInt16 ToxLinkProcessorTest::POOL_ID_2 = 43; const sal_uInt16 ToxLinkProcessorTest::POOL_ID_2 = 43;
void void
ToxLinkProcessorTest::ExceptionIsThrownIfTooManyLinksAreClosed() ToxLinkProcessorTest::NoExceptionIsThrownIfTooManyLinksAreClosed()
{ {
ToxLinkProcessor sut; ToxLinkProcessor sut;
sut.StartNewLink(0, STYLE_NAME_1); sut.StartNewLink(0, STYLE_NAME_1);
...@@ -69,6 +74,17 @@ ToxLinkProcessorTest::ExceptionIsThrownIfTooManyLinksAreClosed() ...@@ -69,6 +74,17 @@ ToxLinkProcessorTest::ExceptionIsThrownIfTooManyLinksAreClosed()
sut.CloseLink(1, URL_1); sut.CloseLink(1, URL_1);
} }
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 void
ToxLinkProcessorTest::AddingAndClosingTwoLinksResultsInTwoClosedLinks() ToxLinkProcessorTest::AddingAndClosingTwoLinksResultsInTwoClosedLinks()
{ {
......
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