vcl/qa/cppunit/text.cxx |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

New commits:
commit 0cf173ff4a53618e6ddd40a278f375680d92a71f
Author:     Chris Sherlock <chris.sherloc...@gmail.com>
AuthorDate: Tue Sep 27 05:37:47 2022 +1000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Oct 7 10:42:05 2022 +0200

    vcl: test OutputDevice::GetTextBreak()
    
    Change-Id: I1618d268ca7495d4aae1bde1a43be6bcf8811869
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140630
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx
index d233fa9d9aa3..8ec7597e6a65 100644
--- a/vcl/qa/cppunit/text.cxx
+++ b/vcl/qa/cppunit/text.cxx
@@ -62,6 +62,7 @@ public:
     void testImplLayoutArgsBiDiRtl();
     void testImplLayoutArgsRightAlign();
     void testImplLayoutArgs_PrepareFallback_precalculatedglyphs();
+    void testGetTextBreak();
 
     CPPUNIT_TEST_SUITE(VclTextTest);
     CPPUNIT_TEST(testSimpleText);
@@ -74,6 +75,7 @@ public:
     CPPUNIT_TEST(testImplLayoutArgsBiDiRtl);
     CPPUNIT_TEST(testImplLayoutArgsRightAlign);
     CPPUNIT_TEST(testImplLayoutArgs_PrepareFallback_precalculatedglyphs);
+    CPPUNIT_TEST(testGetTextBreak);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -574,6 +576,30 @@ void 
VclTextTest::testImplLayoutArgs_PrepareFallback_precalculatedglyphs()
     CPPUNIT_ASSERT(!bRTL);
 }
 
+void VclTextTest::testGetTextBreak()
+{
+    ScopedVclPtr<VirtualDevice> device = 
VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT);
+    device->SetOutputSizePixel(Size(1000, 1000));
+    device->SetFont(vcl::Font("DejaVu Sans", "Book", Size(0, 11)));
+
+    const OUString sTestStr(u"textline_ text_");
+    const auto nLen = sTestStr.getLength();
+    const auto nTextWidth = device->GetTextWidth("text");
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4),
+                         device->GetTextBreak(sTestStr, nTextWidth, 0, nLen));
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(7),
+                         device->GetTextBreak(sTestStr, nTextWidth, 3, nLen));
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(9),
+                         device->GetTextBreak(sTestStr, nTextWidth, 6, nLen));
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(12),
+                         device->GetTextBreak(sTestStr, nTextWidth, 8, nLen));
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(14),
+                         device->GetTextBreak(sTestStr, nTextWidth, 11, nLen));
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1),
+                         device->GetTextBreak(sTestStr, nTextWidth, 13, nLen));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(VclTextTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();

Reply via email to