summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlabel/tst_qlabel.cpp
diff options
context:
space:
mode:
authorSarah Smith <sarah.j.smith@nokia.com>2009-10-20 01:53:30 (GMT)
committerSarah Smith <sarah.j.smith@nokia.com>2009-10-20 01:53:30 (GMT)
commit420be4ee3d98c093c71cc840192138da6b5e61d2 (patch)
tree9debab52db05f930d2c72095eae0953a320a2816 /tests/auto/qlabel/tst_qlabel.cpp
parentdfd6221d960ec8c563a687684000c3a9c4f58079 (diff)
downloadQt-420be4ee3d98c093c71cc840192138da6b5e61d2.zip
Qt-420be4ee3d98c093c71cc840192138da6b5e61d2.tar.gz
Qt-420be4ee3d98c093c71cc840192138da6b5e61d2.tar.bz2
Fix bug QTBUG-4848
Make the shapeText function return numGlyphs properly - its not always the same as length of string. Task-number: QTBUG-4848 Reviewed-by: Rhys Weatherley
Diffstat (limited to 'tests/auto/qlabel/tst_qlabel.cpp')
-rw-r--r--tests/auto/qlabel/tst_qlabel.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/auto/qlabel/tst_qlabel.cpp b/tests/auto/qlabel/tst_qlabel.cpp
index dd03ef3..9eae9c9 100644
--- a/tests/auto/qlabel/tst_qlabel.cpp
+++ b/tests/auto/qlabel/tst_qlabel.cpp
@@ -50,6 +50,7 @@
#include <qlineedit.h>
#include <qmovie.h>
#include <qpicture.h>
+#include <qmessagebox.h>
//TESTED_CLASS=
//TESTED_FILES=
@@ -112,6 +113,9 @@ private slots:
void task226479_movieResize();
void emptyPixmap();
+ void unicodeText_data();
+ void unicodeText();
+
private:
QLabel *testWidget;
QPointer<Widget> test_box;
@@ -451,5 +455,59 @@ void tst_QLabel::emptyPixmap()
QCOMPARE(label1.sizeHint(), label4.sizeHint());
}
+/**
+ Test for QTBUG-4848 - unicode data corrupting QLabel display
+*/
+void tst_QLabel::unicodeText_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("languageName");
+
+ /*
+ The "glass" phrase in Thai was the initial report for bug QTBUG-4848, was
+ originally found on http://www.columbia.edu/kermit/utf8.html.
+
+ The phrase is from an internet tradition regarding a striking phrase
+ that is translated into many different languages. The utf8 strings
+ below were generated by using http://translate.google.com.
+
+ The glass phrase in Thai contains the ้ว character which manifests bug
+ QTBUG-4848
+
+ The last long phrase is an excerpt from Churchills "on the beaches"
+ speech, also translated using http://translate.google.com.
+ */
+
+ QTest::newRow("english") << QString::fromUtf8("I can eat glass and it doesn't hurt me.") << QString("english");
+ QTest::newRow("thai") << QString::fromUtf8("ฉันจะกินแก้วและไม่เจ็บฉัน") << QString("thai");
+ QTest::newRow("chinese") << QString::fromUtf8("我可以吃玻璃,并没有伤害我。") << QString("chinese");
+ QTest::newRow("arabic") << QString::fromUtf8("أستطيع أكل الزجاج ، وأنه لا يؤذيني.") << QString("arabic");
+ QTest::newRow("russian") << QString::fromUtf8("Я могу есть стекло, и не больно.") << QString("russian");
+ QTest::newRow("korean") << QString::fromUtf8("유리를 먹을 수있는, 그리고 그게 날 다치게하지 않습니다.") << QString("korean");
+ QTest::newRow("greek") << QString::fromUtf8("Μπορώ να φάτε γυαλί και δεν μου κάνει κακό.") << QString("greek");
+ QTest::newRow("german") << QString::fromUtf8("Ich kann Glas essen und es macht mich nicht heiß.") << QString("german");
+
+ QTest::newRow("thai_long") << QString::fromUtf8("เราจะต่อสู้ในทะเลและมหาสมุทร. เราจะต่อสู้ด้วยความมั่นใจเติบโตและความเจริญเติบโตในอากาศเราจะปกป้องเกาะของเราค่าใช้จ่ายใดๆอาจ."
+ "เราจะต่อสู้บนชายหาดเราจะต่อสู้ในบริเวณเชื่อมโยงไปถึงเราจะต่อสู้ในช่องและในถนนที่เราจะต่อสู้ในภูเขานั้นเราจะไม่ยอม.")
+ << QString("thai_long");
+}
+
+void tst_QLabel::unicodeText()
+{
+ const QString testDataPath("testdata/unicodeText");
+ QFETCH(QString, text);
+ QFETCH(QString, languageName);
+ QFrame frame;
+ QVBoxLayout *layout = new QVBoxLayout();
+ QLabel *label = new QLabel(text, &frame);
+ layout->addWidget(label);
+ layout->setMargin(8);
+ frame.setLayout(layout);
+ frame.show();
+ QTest::qWaitForWindowShown(&frame);
+ QVERIFY(frame.isVisible()); // was successfully sized and shown
+ testWidget->show();
+}
+
QTEST_MAIN(tst_QLabel)
#include "tst_qlabel.moc"