summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2021-03-07 13:19:55 +1100
committerTomaž Vajngerl <quikee@gmail.com>2021-08-28 15:09:12 +0200
commit9ca9faabd4009698096ccde03c45e9c203804c80 (patch)
tree458966017e413f5b58ef3fdcd814443f6f5e07e1 /vcl/qa
parent9a58ec3f6f65da27e3b26e1173b6661b743e66a4 (diff)
vcl: move TextLayoutCache to own module header
Add a unit test for TextLayoutClass - it basically tests that script runs work as intended. Change-Id: Ie65acf06f13c89c182d93b20fc9a28866db2330c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115470 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/text.cxx28
1 files changed, 25 insertions, 3 deletions
diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx
index 19e5da942932..0db15435a675 100644
--- a/vcl/qa/cppunit/text.cxx
+++ b/vcl/qa/cppunit/text.cxx
@@ -8,14 +8,16 @@
*/
#include <test/bootstrapfixture.hxx>
+#include <sal/log.hxx>
#include <tools/stream.hxx>
+
#include <vcl/BitmapReadAccess.hxx>
#include <vcl/graphicfilter.hxx>
-#include <vcl/virdev.hxx>
-#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
-#include <sal/log.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/virdev.hxx>
+#include <TextLayoutCache.hxx>
#include <salgdi.hxx>
class VclTextTest : public test::BootstrapFixture
@@ -42,10 +44,12 @@ public:
void testSimpleText();
void testVerticalText();
+ void testTextLayoutCache();
CPPUNIT_TEST_SUITE(VclTextTest);
CPPUNIT_TEST(testSimpleText);
CPPUNIT_TEST(testVerticalText);
+ CPPUNIT_TEST(testTextLayoutCache);
CPPUNIT_TEST_SUITE_END();
};
@@ -375,6 +379,24 @@ void VclTextTest::testVerticalText()
CPPUNIT_ASSERT_DOUBLES_EQUAL(width36, width36pct50, 2);
}
+void VclTextTest::testTextLayoutCache()
+{
+ OUString sTestString = u"The quick brown fox\n jumped over the lazy dogالعاشر";
+ vcl::TextLayoutCache cache(sTestString.getStr(), sTestString.getLength());
+
+ vcl::Run run1 = cache.runs[0];
+ vcl::Run run2 = cache.runs[1];
+
+ bool bCorrectRuns = (cache.runs.size() == 2);
+ CPPUNIT_ASSERT_MESSAGE("Wrong number of runs", bCorrectRuns);
+ CPPUNIT_ASSERT_EQUAL(USCRIPT_LATIN, run1.nCode);
+ CPPUNIT_ASSERT_EQUAL(0, run1.nStart);
+ CPPUNIT_ASSERT_EQUAL(45, run1.nEnd);
+ CPPUNIT_ASSERT_EQUAL(USCRIPT_ARABIC, run2.nCode);
+ CPPUNIT_ASSERT_EQUAL(45, run2.nStart);
+ CPPUNIT_ASSERT_EQUAL(51, run2.nEnd);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(VclTextTest);
CPPUNIT_PLUGIN_IMPLEMENT();