diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-08-28 18:10:03 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-08-29 08:37:10 +0200 |
commit | 60362accc78fdff4213fa6c28bb4fbf00e06972f (patch) | |
tree | 9afb29fc6349211636d5cba651c85415f32826cf /svtools/qa | |
parent | b5fcdfd30c0a75b3365e42082f7af860381b2bc5 (diff) |
XHTML import: <br></br> is one line break
But only for XHTML, HTML stays unchanged to be in sync with web
browsers.
Change-Id: I3a1cf6651dab565bafece68963acb112ae715cdd
Reviewed-on: https://gerrit.libreoffice.org/59727
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'svtools/qa')
-rw-r--r-- | svtools/qa/unit/testHtmlReader.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/svtools/qa/unit/testHtmlReader.cxx b/svtools/qa/unit/testHtmlReader.cxx index b09abaaabdd5..6df6b5541c2d 100644 --- a/svtools/qa/unit/testHtmlReader.cxx +++ b/svtools/qa/unit/testHtmlReader.cxx @@ -22,8 +22,11 @@ class TestHTMLParser : public HTMLParser public: TestHTMLParser(SvStream& rStream); virtual void NextToken(HtmlTokenId nToken) override; + /// Make this public for test purposes. + using HTMLParser::SetNamespace; OUString m_aDocument; + int m_nLineBreakCount = 0; }; TestHTMLParser::TestHTMLParser(SvStream& rStream) @@ -35,6 +38,8 @@ void TestHTMLParser::NextToken(HtmlTokenId nToken) { if (nToken == HtmlTokenId::TEXTTOKEN) m_aDocument += aToken; + else if (nToken == HtmlTokenId::LINEBREAK) + ++m_nLineBreakCount; } /// Tests HTMLParser. @@ -42,9 +47,11 @@ class Test : public CppUnit::TestFixture { public: void testTdf114428(); + void testLineBreak(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testTdf114428); + CPPUNIT_TEST(testLineBreak); CPPUNIT_TEST_SUITE_END(); }; @@ -63,6 +70,21 @@ void Test::testTdf114428() CPPUNIT_ASSERT_EQUAL(OUString("hello"), xParser->m_aDocument.trim()); } +void Test::testLineBreak() +{ + SvMemoryStream aStream; + OString aDocument("aaa<br></br>bbb"); + aStream.WriteBytes(aDocument.getStr(), aDocument.getLength()); + aStream.Seek(0); + + tools::SvRef<TestHTMLParser> xParser = new TestHTMLParser(aStream); + xParser->SetNamespace("reqif-xhtml"); + xParser->CallParser(); + + // This was 2, <br></br> was interpreted as 2 line breaks in XHTML mode. + CPPUNIT_ASSERT_EQUAL(1, xParser->m_nLineBreakCount); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } |