diff options
author | Mike FABIAN <mike.fabian@basyskom.de> | 2010-11-24 15:38:50 +0100 |
---|---|---|
committer | Mike FABIAN <mike.fabian@basyskom.de> | 2010-11-24 17:01:08 +0100 |
commit | edb66229c5a21fac3c5feea3b06196227b7fcf10 (patch) | |
tree | 82a9d01db6337d7d10685c42518fcfa0002f982d /tests | |
parent | cbed65d7b8e8c8b797ccfc03af08ee8b91f5cfba (diff) |
Changes: unit test improvements for mlabel layout direction and text direction
RevBy: John Tapsell, Peter Penz
Details:
Needed for the fix for
NB#205694 - Wrong reordering of Bidi Text in MLabels
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ut_mlabel/ut_mlabel.cpp | 48 | ||||
-rw-r--r-- | tests/ut_mlabel/ut_mlabel.h | 4 |
2 files changed, 47 insertions, 5 deletions
diff --git a/tests/ut_mlabel/ut_mlabel.cpp b/tests/ut_mlabel/ut_mlabel.cpp index 043aad25..38bda507 100644 --- a/tests/ut_mlabel/ut_mlabel.cpp +++ b/tests/ut_mlabel/ut_mlabel.cpp @@ -181,8 +181,10 @@ void Ut_MLabel::testLayoutDirection_data() { QTest::addColumn<QString>("text"); - QTest::newRow("plain") << "this is plain text!"; - QTest::newRow("rich") << "<b>this is rich text!</b>"; + QTest::newRow("english-plain") << "this is plain English text!"; + QTest::newRow("english-rich") << "<b>this is rich English text!</b>"; + QTest::newRow("arabic-plain") << QString::fromUtf8("العربية"); + QTest::newRow("arabic-rich") << QString::fromUtf8("<b>العربية</b>"); } void Ut_MLabel::testLayoutDirection() @@ -199,8 +201,46 @@ void Ut_MLabel::testLayoutDirection() QVERIFY(label->layoutDirection() == Qt::RightToLeft); QImage rtl = captureImage(label); - //ltr.save("ltr", "PNG"); - //rtl.save("rtl", "PNG"); +#if 0 + ltr.save("layoutdirection-" + QString(QTest::currentDataTag()) + "-ltr.png"); + rtl.save("layoutdirection-" + QString(QTest::currentDataTag()) + "-rtl.png"); +#endif + + QVERIFY(ltr == rtl); +} + +void Ut_MLabel::testTextDirection_data() +{ + QTest::addColumn<QString>("text"); + + QTest::newRow("english-arabic-english-plain") + << QString::fromUtf8("Englishالعربيةlanguage"); + QTest::newRow("english-arabic-english-rich") + << QString::fromUtf8("<b>Englishالعربيةlanguage</b>"); + QTest::newRow("arabic-english-arabic-plain") + << QString::fromUtf8("العرEnglishبية"); + QTest::newRow("arabic-english-arabic-rich") + << QString::fromUtf8("<b>العرEnglishبية</b>"); +} + +void Ut_MLabel::testTextDirection() +{ + QFETCH(QString, text); + label->setText(text); + QVERIFY(text == label->text()); + + label->model()->setTextDirection(Qt::LeftToRight); + QVERIFY(label->model()->textDirection() == Qt::LeftToRight); + QImage ltr = captureImage(label); + + label->model()->setTextDirection(Qt::RightToLeft); + QVERIFY(label->model()->textDirection() == Qt::RightToLeft); + QImage rtl = captureImage(label); + +#if 0 + ltr.save("textdirection-" + QString(QTest::currentDataTag()) + "-ltr.png"); + rtl.save("textdirection-" + QString(QTest::currentDataTag()) + "-rtl.png"); +#endif QVERIFY(ltr != rtl); } diff --git a/tests/ut_mlabel/ut_mlabel.h b/tests/ut_mlabel/ut_mlabel.h index 01720fef..250d4c1c 100644 --- a/tests/ut_mlabel/ut_mlabel.h +++ b/tests/ut_mlabel/ut_mlabel.h @@ -70,15 +70,17 @@ private slots: void testTextAlignment_data(); void testLayoutDirection_data(); + void testTextDirection_data(); void testTextWordWrap_data(); void testTextElide_data(); - + void testClear_data(); void testPlainTextColor_data(); void testTestConstruction(); void testTextAlignment(); void testLayoutDirection(); + void testTextDirection(); void testTextWordWrap(); void testTextElide(); void testRichTextElide_data(); |