summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtranslator
diff options
context:
space:
mode:
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"