From 128540391f27da4dce8b460883fbcdb3aba8a44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 2 Apr 2020 11:14:57 +0200 Subject: Add lupdate test for Objective-C++ sources Change-Id: I3728a77d44798e5ab71c6f775f95821513be00fe Reviewed-by: Friedemann Kleint Reviewed-by: Volker Hilsheimer Reviewed-by: Simon Hausmann Reviewed-by: Karsten Heimrich --- .../lupdate/testdata/good/parseobjc/main.mm | 51 ++++++++++++++++++++++ .../lupdate/testdata/good/parseobjc/project.pro | 3 ++ .../testdata/good/parseobjc/project.ts.result | 20 +++++++++ tests/auto/linguist/lupdate/tst_lupdate.cpp | 3 ++ 4 files changed, 77 insertions(+) create mode 100644 tests/auto/linguist/lupdate/testdata/good/parseobjc/main.mm create mode 100644 tests/auto/linguist/lupdate/testdata/good/parseobjc/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/parseobjc/project.ts.result (limited to 'tests/auto/linguist/lupdate') diff --git a/tests/auto/linguist/lupdate/testdata/good/parseobjc/main.mm b/tests/auto/linguist/lupdate/testdata/good/parseobjc/main.mm new file mode 100644 index 000000000..7cc1c34e3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseobjc/main.mm @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +@interface NSObject +@end + +@interface Foo : NSObject +@property (nonatomic, retain) NSObject *child; +- (bool)someMethodWithArg:(NSObject*)child andAnotherArg:(int)age; +@end + +@implementation Foo +- (bool)someMethodWithArg:(NSObject*)child andAnotherArg:(int)age +{ + QCoreApplication::translate("Biz", "Baz"); + return self.child == child && age == 42; +} +@end + +int main() +{ + QCoreApplication::translate("Foo", "Bar"); + return 0; +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parseobjc/project.pro b/tests/auto/linguist/lupdate/testdata/good/parseobjc/project.pro new file mode 100644 index 000000000..e9d4e1ec3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseobjc/project.pro @@ -0,0 +1,3 @@ +SOURCES += main.mm + +TRANSLATIONS = project.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/parseobjc/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parseobjc/project.ts.result new file mode 100644 index 000000000..675d16449 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseobjc/project.ts.result @@ -0,0 +1,20 @@ + + + + + Biz + + + Baz + + + + + Foo + + + Bar + + + + diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp index c55167a55..0837ee572 100644 --- a/tests/auto/linguist/lupdate/tst_lupdate.cpp +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -222,6 +222,9 @@ void tst_lupdate::good_data() #ifndef Q_OS_WIN dirs.removeAll(QLatin1String("backslashes")); #endif +#ifndef Q_OS_MACOS + dirs.removeAll(QLatin1String("parseobjc")); +#endif for (const QString &dir : qAsConst(dirs)) QTest::newRow(dir.toLocal8Bit()) << dir; -- cgit v1.2.3 From 1b992406a6523a144c58baa9bbd1198bb9a2d98c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 15 Apr 2020 11:51:27 +0200 Subject: Fix some deprecation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit findfiledialog.cpp:188:24: warning: ‘AdjustToMinimumContentsLength’ is deprecated: Use AdjustToContents or AdjustToContentsOnFirstShow [-Wdeprecated-declarations] tst_lupdate.cpp:291:63: warning: ‘void QProcess::start(const QString&, QIODevice::OpenMode)’ is deprecated: Use QProcess::start(const QString &program, const QStringList &arguments,OpenMode mode = ReadWrite) instead [-Wdeprecated-declarations] tst_qtattributionsscanner.cpp:112:63: warning: ‘void QProcess::start(const QString&, QIODevice::OpenMode)’ is deprecated: Use QProcess::start(const QString &program, const QStringList &arguments,OpenMode mode = ReadWrite) instead [-Wdeprecated-declarations] tst_qtdiag.cpp:70:27: warning: ‘void QProcess::start(const QString&, QIODevice::OpenMode)’ is deprecated: Use QProcess::start(const QString &program, const QStringList &arguments,OpenMode mode = ReadWrite) instead [-Wdeprecated-declarations] Cherry-picked from branch: dev Change-Id: I103a28bd6ce97de311042f145d4a793be9d4b9a7 Reviewed-by: cherrypickbot --- tests/auto/linguist/lupdate/tst_lupdate.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'tests/auto/linguist/lupdate') diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp index 0837ee572..ac6e4db2b 100644 --- a/tests/auto/linguist/lupdate/tst_lupdate.cpp +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -240,7 +240,7 @@ void tst_lupdate::good() QString workDir = dir; QStringList generatedtsfiles(QLatin1String("project.ts")); - QString lupdatecmd; + QStringList lupdateArguments; QFile file(dir + "/lupdatecmd"); if (file.exists()) { @@ -250,8 +250,8 @@ void tst_lupdate::good() if (cmdstring.startsWith('#')) continue; if (cmdstring.startsWith("lupdate")) { - cmdstring.remove(0, 8); - lupdatecmd.append(cmdstring); + for (auto argument : cmdstring.mid(8).simplified().split(' ')) + lupdateArguments += argument; break; } else if (cmdstring.startsWith("TRANSLATION:")) { cmdstring.remove(0, 12); @@ -280,29 +280,29 @@ void tst_lupdate::good() QVERIFY(file.open(QIODevice::WriteOnly)); file.close(); - if (lupdatecmd.isEmpty()) - lupdatecmd = QLatin1String("project.pro"); - lupdatecmd.prepend("-silent "); + if (lupdateArguments.isEmpty()) + lupdateArguments.append(QLatin1String("project.pro")); + lupdateArguments.prepend("-silent"); QProcess proc; proc.setWorkingDirectory(workDir); proc.setProcessChannelMode(QProcess::MergedChannels); - const QString command = QLatin1Char('"') + m_cmdLupdate + QLatin1String("\" ") + lupdatecmd; - proc.start(command, QIODevice::ReadWrite | QIODevice::Text); + const QString command = m_cmdLupdate + ' ' + lupdateArguments.join(' '); + proc.start(m_cmdLupdate, lupdateArguments, QIODevice::ReadWrite | QIODevice::Text); QVERIFY2(proc.waitForStarted(), qPrintable(command + QLatin1String(" :") + proc.errorString())); QVERIFY2(proc.waitForFinished(30000), qPrintable(command)); - QByteArray output = proc.readAll(); + const QString output = QString::fromLocal8Bit(proc.readAll()); QVERIFY2(proc.exitStatus() == QProcess::NormalExit, - "\"lupdate " + lupdatecmd.toLatin1() + "\" crashed\n" + output); + qPrintable(QLatin1Char('"') + command + "\" crashed\n" + output)); QVERIFY2(!proc.exitCode(), - "\"lupdate " + lupdatecmd.toLatin1() + "\" exited with code " + - QByteArray::number(proc.exitCode()) + "\n" + output); + qPrintable(QLatin1Char('"') + command + "\" exited with code " + + QString::number(proc.exitCode()) + '\n' + output)); // If the file expectedoutput.txt exists, compare the // console output with the content of that file QFile outfile(dir + "/expectedoutput.txt"); if (outfile.exists()) { - QStringList errslist = QString::fromLatin1(output).split(QLatin1Char('\n')); + QStringList errslist = output.split(QLatin1Char('\n')); doCompare(errslist, outfile.fileName(), true); if (QTest::currentTestFailed()) return; -- cgit v1.2.3