diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2013-11-11 14:52:11 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-11 15:56:52 +0100 |
commit | 459fb114818eaf6a209e80ff7d59ccefeee881e3 (patch) | |
tree | 59bea0639be7a7dff86781e503d248d805e22302 /tests | |
parent | a4446c299a9eab7e1844ca6b94823984c8e7d67b (diff) |
uic: Accept an -include argument to generate a #include.
Change-Id: I2854619ab995b4ba3c820fec58e998ad04ac9858
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/tools/uic/baseline/translation/Dialog_without_Buttons_tr.h | 50 | ||||
-rw-r--r-- | tests/auto/tools/uic/tst_uic.cpp | 52 |
2 files changed, 102 insertions, 0 deletions
diff --git a/tests/auto/tools/uic/baseline/translation/Dialog_without_Buttons_tr.h b/tests/auto/tools/uic/baseline/translation/Dialog_without_Buttons_tr.h new file mode 100644 index 0000000000..597728e207 --- /dev/null +++ b/tests/auto/tools/uic/baseline/translation/Dialog_without_Buttons_tr.h @@ -0,0 +1,50 @@ +/******************************************************************************** +** Form generated from reading UI file 'Dialog_without_Buttons.ui' +** +** Created by: Qt User Interface Compiler version 5.3.0 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef DIALOG_WITHOUT_BUTTONS_TR_H +#define DIALOG_WITHOUT_BUTTONS_TR_H + +#include <QtCore/QVariant> +#include <QtWidgets/QAction> +#include <QtWidgets/QApplication> +#include <QtWidgets/QButtonGroup> +#include <QtWidgets/QDialog> +#include <QtWidgets/QHeaderView> +#include <ki18n.h> + +QT_BEGIN_NAMESPACE + +class Ui_Dialog +{ +public: + + void setupUi(QDialog *Dialog) + { + if (Dialog->objectName().isEmpty()) + Dialog->setObjectName(QStringLiteral("Dialog")); + Dialog->resize(400, 300); + + retranslateUi(Dialog); + + QMetaObject::connectSlotsByName(Dialog); + } // setupUi + + void retranslateUi(QDialog *Dialog) + { + Dialog->setWindowTitle(i18n("Dialog", 0)); + } // retranslateUi + +}; + +namespace Ui { + class Dialog: public Ui_Dialog {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // DIALOG_WITHOUT_BUTTONS_TR_H diff --git a/tests/auto/tools/uic/tst_uic.cpp b/tests/auto/tools/uic/tst_uic.cpp index c6e8466d89..02a19c0c33 100644 --- a/tests/auto/tools/uic/tst_uic.cpp +++ b/tests/auto/tools/uic/tst_uic.cpp @@ -64,9 +64,13 @@ private Q_SLOTS: void run(); void run_data() const; + void runTranslation(); + void compare(); void compare_data() const; + void runCompare(); + private: const QString m_command; QString m_baseline; @@ -220,5 +224,53 @@ void tst_uic::compare_data() const } } +void tst_uic::runTranslation() +{ + QProcess process; + + QDir baseline(m_baseline); + + QDir generated(m_generated.path()); + generated.mkdir(QLatin1String("translation")); + QString generatedFile = generated.absolutePath() + QLatin1String("/translation/Dialog_without_Buttons_tr.h"); + + process.start(m_command, QStringList(baseline.filePath("Dialog_without_Buttons.ui")) + << QString(QLatin1String("-tr")) << "i18n" + << QString(QLatin1String("-include")) << "ki18n.h" + << QString(QLatin1String("-o")) << generatedFile); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(m_command, process.errorString())); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); + QCOMPARE(QFileInfo(generatedFile).exists(), true); +} + + +void tst_uic::runCompare() +{ + QFile orgFile(m_baseline + QLatin1String("/translation/Dialog_without_Buttons_tr.h")); + + QDir generated(m_generated.path()); + QFile genFile(generated.absolutePath() + QLatin1String("/translation/Dialog_without_Buttons_tr.h")); + + if (!orgFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + QString err(QLatin1String("Could not read file: %1...")); + QFAIL(err.arg(orgFile.fileName()).toUtf8()); + } + + if (!genFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + QString err(QLatin1String("Could not read file: %1...")); + QFAIL(err.arg(genFile.fileName()).toUtf8()); + } + + QString originalFile = orgFile.readAll(); + originalFile.replace(QRegExp(QLatin1String("Created by: Qt User Interface Compiler version [.\\d]{5,5}")), ""); + + QString generatedFile = genFile.readAll(); + generatedFile.replace(QRegExp(QLatin1String("Created by: Qt User Interface Compiler version [.\\d]{5,5}")), ""); + + QCOMPARE(generatedFile, originalFile); +} + QTEST_MAIN(tst_uic) #include "tst_uic.moc" |