diff options
author | Robin Burchell <robin.burchell@jollamobile.com> | 2013-05-28 11:18:38 +0000 |
---|---|---|
committer | Robin Burchell <robin+qt@viroteck.net> | 2013-06-11 00:49:40 +0200 |
commit | 7c357e999dec36f4c990671dd0e082c08150c915 (patch) | |
tree | 7ff4625e0c52ef428e5d51bfccec26bb084f7cf4 /src | |
parent | 87b7bc2826de14eb8029d29c92db5c87f778c33e (diff) |
Add an option for qmltestrunner to load translation files.
This is virtually a backport of
qtdeclarative/0339d34691ecf4d67d4ef41c028a687251c2d81a.
Done-with: Richard Braakman <richard.braakman@jollamobile.com>
Change-Id: I8d32c42536aafae1570b273655f200e037582948
Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/quicktestlib/quicktest.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/quicktestlib/quicktest.cpp b/src/quicktestlib/quicktest.cpp index 6776a99..b7c42dc 100644 --- a/src/quicktestlib/quicktest.cpp +++ b/src/quicktestlib/quicktest.cpp @@ -63,6 +63,7 @@ #include <QtCore/qfile.h> #include <QtCore/qdebug.h> #include <QtCore/qeventloop.h> +#include <QtCore/qtranslator.h> #include <QtGui/qtextdocument.h> #include <stdio.h> @@ -117,8 +118,10 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport // Look for QML-specific command-line options. // -import dir Specify an import directory. // -input dir Specify the input directory for test cases. + // -translation file Specify a .qm file to load // -qtquick2 Run with QtQuick 2 rather than QtQuick 1. QStringList imports; + QStringList qmfiles; QString testPath; bool qtQuick2 = false; int outargc = 1; @@ -135,6 +138,9 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport } else if (strcmp(argv[index], "-qtquick2") == 0) { qtQuick2 = true; ++index; + } else if (strcmp(argv[index], "-translation") == 0) { + qmfiles += stripQuotes(QString::fromLocal8Bit(argv[index + 1])); + index += 2; } else if (outargc != index) { argv[outargc++] = argv[index++]; } else { @@ -173,6 +179,16 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport QuickTestResult::parseArgs(argc, argv); QuickTestResult::setProgramName(name); + // Load all the translations in the order they were given in the args + foreach (QString qmfile, qmfiles) { + QTranslator *translator = new QTranslator(qApp); + if (translator->load(qmfile)) { + qApp->installTranslator(translator); + } else { + qWarning() << "Could not load the translation file" << qmfile; + } + } + // Scan through all of the "tst_*.qml" files and run each of them // in turn with a QDeclarativeView. #ifdef QUICK_TEST_SCENEGRAPH |