diff options
Diffstat (limited to 'svtools/qa/unit/testHtmlReader.cxx')
-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); } |