summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtranslator
diff options
context:
space:
mode:
authorDavid Sansome <me@davidsansome.com>2010-03-24 09:11:11 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-03-24 10:27:09 (GMT)
commit423f1cf2c5bd505497400db1e732efad12361976 (patch)
treed30db9e405bb0c810d9cd0411468f1ea984a1443 /tests/auto/qtranslator
parent67ff95079522d79e45d64d579856c5c1cd3a69d9 (diff)
downloadQt-423f1cf2c5bd505497400db1e732efad12361976.zip
Qt-423f1cf2c5bd505497400db1e732efad12361976.tar.gz
Qt-423f1cf2c5bd505497400db1e732efad12361976.tar.bz2
Add unit tests for QTranslator.
Two new tests: * Check that translations can be loaded from resources * Check that nothing happens when trying to "load" a directory Merge-request: 531 Reviewed-by: Benjamin Poulain <benjamin.poulain@nokia.com>
Diffstat (limited to 'tests/auto/qtranslator')
-rw-r--r--tests/auto/qtranslator/qtranslator.pro2
-rw-r--r--tests/auto/qtranslator/qtranslator.qrc5
-rw-r--r--tests/auto/qtranslator/tst_qtranslator.cpp19
3 files changed, 25 insertions, 1 deletions
diff --git a/tests/auto/qtranslator/qtranslator.pro b/tests/auto/qtranslator/qtranslator.pro
index 30ffc1c..2b08b4a 100644
--- a/tests/auto/qtranslator/qtranslator.pro
+++ b/tests/auto/qtranslator/qtranslator.pro
@@ -1,6 +1,6 @@
load(qttest_p4)
SOURCES += tst_qtranslator.cpp
-
+RESOURCES += qtranslator.qrc
wince*|symbian*: {
addFiles.sources = hellotr_la.qm msgfmt_from_po.qm
diff --git a/tests/auto/qtranslator/qtranslator.qrc b/tests/auto/qtranslator/qtranslator.qrc
new file mode 100644
index 0000000..333dcfa
--- /dev/null
+++ b/tests/auto/qtranslator/qtranslator.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/tst_qtranslator">
+ <file>hellotr_la.qm</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/qtranslator/tst_qtranslator.cpp b/tests/auto/qtranslator/tst_qtranslator.cpp
index 44fc10c..f2bfbf0 100644
--- a/tests/auto/qtranslator/tst_qtranslator.cpp
+++ b/tests/auto/qtranslator/tst_qtranslator.cpp
@@ -70,6 +70,8 @@ private slots:
void testLanguageChange();
void plural();
void translate_qm_file_generated_with_msgfmt();
+ void loadFromResource();
+ void loadDirectory();
private:
int languageChangeEventCounter;
@@ -237,5 +239,22 @@ void tst_QTranslator::translate_qm_file_generated_with_msgfmt()
qApp->removeTranslator(&translator);
}
+void tst_QTranslator::loadFromResource()
+{
+ QTranslator tor;
+ tor.load(":/tst_qtranslator/hellotr_la.qm");
+ QVERIFY(!tor.isEmpty());
+ QCOMPARE(tor.translate("QPushButton", "Hello world!"), QString::fromLatin1("Hallo Welt!"));
+}
+
+void tst_QTranslator::loadDirectory()
+{
+ QVERIFY(QFileInfo("../qtranslator").isDir());
+
+ QTranslator tor;
+ tor.load("qtranslator", "..");
+ QVERIFY(tor.isEmpty());
+}
+
QTEST_MAIN(tst_QTranslator)
#include "tst_qtranslator.moc"