diff options
Diffstat (limited to 'tests/auto/tools')
28 files changed, 516 insertions, 61 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 350c6142d2..c113b7cd60 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -513,6 +513,8 @@ class tst_Moc : public QObject Q_PROPERTY(QString member4 MEMBER sMember NOTIFY member4Changed) Q_PROPERTY(QString member5 MEMBER sMember NOTIFY member5Changed) Q_PROPERTY(QString member6 MEMBER sConst CONSTANT) + Q_PROPERTY(QString sub1 MEMBER (sub.m_string)) + Q_PROPERTY(QString sub2 READ (sub.string) WRITE (sub.setString)) public: inline tst_Moc() : sConst("const") {} @@ -626,6 +628,13 @@ private: QString sMember; const QString sConst; PrivatePropertyTest *pPPTest; + + struct { + QString m_string; + void setString(const QString &s) { m_string = s; } + QString string() { return m_string; } + } sub; + }; void tst_Moc::initTestCase() @@ -880,7 +889,7 @@ void tst_Moc::preprocessorConditionals() QVERIFY(mobj->indexOfSignal("signalInIf1()") != -1); QVERIFY(mobj->indexOfSignal("signalInIf2()") != -1); QVERIFY(mobj->indexOfSignal("signalInIf3()") != -1); - QVERIFY(mobj->indexOfSignal("doNotExist()") == -1); + QCOMPARE(mobj->indexOfSignal("doNotExist()"), -1); } void tst_Moc::blackslashNewlines() @@ -888,7 +897,7 @@ void tst_Moc::blackslashNewlines() BackslashNewlines tst; const QMetaObject *mobj = tst.metaObject(); QVERIFY(mobj->indexOfSlot("works()") != -1); - QVERIFY(mobj->indexOfSlot("buggy()") == -1); + QCOMPARE(mobj->indexOfSlot("buggy()"), -1); } void tst_Moc::slotWithSillyConst() @@ -928,8 +937,8 @@ void tst_Moc::testExtraDataForEnum() const QMetaObject * const *objects = mobjUser->d.relatedMetaObjects; QVERIFY(objects); - QVERIFY(objects[0] == mobjSource); - QVERIFY(objects[1] == 0); + QCOMPARE(objects[0], mobjSource); + QVERIFY(!objects[1]); } void tst_Moc::namespaceTypeProperty() @@ -982,7 +991,7 @@ void tst_Moc::namespacedFlags() const QVariant v = bar.property("flags"); QVERIFY(v.isValid()); QVERIFY(baz.setProperty("flags", v)); - QVERIFY(baz.flags() == bar.flags()); + QCOMPARE(baz.flags(), bar.flags()); QList<Foo::Bar::Flags> l; l << baz.flags(); @@ -1104,7 +1113,7 @@ void tst_Moc::winNewline() if (data.at(i) == QLatin1Char('\r')) { QVERIFY(i < data.count() - 1); ++i; - QVERIFY(data.at(i) == '\n'); + QCOMPARE(data.at(i), '\n'); } else { QVERIFY(data.at(i) != '\n'); } @@ -1255,14 +1264,14 @@ void tst_Moc::invokable() { const QMetaObject &mobj = InvokableBeforeReturnType::staticMetaObject; QCOMPARE(mobj.methodCount(), 6); - QVERIFY(mobj.method(5).methodSignature() == QByteArray("foo()")); + QCOMPARE(mobj.method(5).methodSignature(), QByteArray("foo()")); } { const QMetaObject &mobj = InvokableBeforeInline::staticMetaObject; QCOMPARE(mobj.methodCount(), 7); - QVERIFY(mobj.method(5).methodSignature() == QByteArray("foo()")); - QVERIFY(mobj.method(6).methodSignature() == QByteArray("bar()")); + QCOMPARE(mobj.method(5).methodSignature(), QByteArray("foo()")); + QCOMPARE(mobj.method(6).methodSignature(), QByteArray("bar()")); } } @@ -1271,22 +1280,22 @@ void tst_Moc::singleFunctionKeywordSignalAndSlot() { const QMetaObject &mobj = SingleFunctionKeywordBeforeReturnType::staticMetaObject; QCOMPARE(mobj.methodCount(), 7); - QVERIFY(mobj.method(5).methodSignature() == QByteArray("mySignal()")); - QVERIFY(mobj.method(6).methodSignature() == QByteArray("mySlot()")); + QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()")); + QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()")); } { const QMetaObject &mobj = SingleFunctionKeywordBeforeInline::staticMetaObject; QCOMPARE(mobj.methodCount(), 7); - QVERIFY(mobj.method(5).methodSignature() == QByteArray("mySignal()")); - QVERIFY(mobj.method(6).methodSignature() == QByteArray("mySlot()")); + QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()")); + QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()")); } { const QMetaObject &mobj = SingleFunctionKeywordAfterInline::staticMetaObject; QCOMPARE(mobj.methodCount(), 7); - QVERIFY(mobj.method(5).methodSignature() == QByteArray("mySignal()")); - QVERIFY(mobj.method(6).methodSignature() == QByteArray("mySlot()")); + QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()")); + QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()")); } } @@ -1740,34 +1749,34 @@ template <class T> void tst_Moc::revisions_T() { int idx = T::staticMetaObject.indexOfProperty("prop1"); - QVERIFY(T::staticMetaObject.property(idx).revision() == 0); + QCOMPARE(T::staticMetaObject.property(idx).revision(), 0); idx = T::staticMetaObject.indexOfProperty("prop2"); - QVERIFY(T::staticMetaObject.property(idx).revision() == 2); + QCOMPARE(T::staticMetaObject.property(idx).revision(), 2); idx = T::staticMetaObject.indexOfMethod("method1()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 0); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 0); idx = T::staticMetaObject.indexOfMethod("method2()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 4); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 4); idx = T::staticMetaObject.indexOfSlot("slot1()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 0); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 0); idx = T::staticMetaObject.indexOfSlot("slot2()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 3); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 3); idx = T::staticMetaObject.indexOfSlot("slot3()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 6); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 6); idx = T::staticMetaObject.indexOfSlot("slot4()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 6); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 6); idx = T::staticMetaObject.indexOfSignal("signal1()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 0); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 0); idx = T::staticMetaObject.indexOfSignal("signal2()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 5); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 5); idx = T::staticMetaObject.indexOfSignal("signal3()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 7); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 7); idx = T::staticMetaObject.indexOfSignal("signal4()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 7); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 7); idx = T::staticMetaObject.indexOfEnumerator("TestEnum"); QCOMPARE(T::staticMetaObject.enumerator(idx).keyCount(), 2); @@ -1883,12 +1892,19 @@ void tst_Moc::warnings_data() << QString() << QString("standard input:5: Error: Class declaration lacks Q_OBJECT macro."); - QTest::newRow("QTBUG-46210: crash on invalid macro") - << QByteArray("#define Foo(a, b, c) a b c #a #b #c a##b##c #d\n Foo(45);") + QTest::newRow("Invalid macro definition") + << QByteArray("#define Foo(a, b, c) a b c #a #b #c a##b##c #d\n Foo(45, 42, 39);") << QStringList() << 1 << QString("IGNORE_ALL_STDOUT") << QString(":2: Error: '#' is not followed by a macro parameter"); + + QTest::newRow("QTBUG-46210: crash on invalid macro invocation") + << QByteArray("#define Foo(a, b, c) a b c #a #b #c a##b##c\n Foo(45);") + << QStringList() + << 1 + << QString("IGNORE_ALL_STDOUT") + << QString(":2: Error: Macro invoked with too few parameters for a use of '#'"); } void tst_Moc::warnings() @@ -1947,7 +1963,7 @@ public: void tst_Moc::privateClass() { - QVERIFY(PrivateClass::staticMetaObject.indexOfConstructor("PrivateClass()") == 0); + QCOMPARE(PrivateClass::staticMetaObject.indexOfConstructor("PrivateClass()"), 0); QVERIFY(PrivateClass::staticMetaObject.indexOfSignal("someSignal()") > 0); } @@ -2037,6 +2053,10 @@ void tst_Moc::memberProperties_data() << 1 << "blub5" << "blub5Changed(const QString&)" << "mno" << true << "mno"; QTest::newRow("private MEMBER property with CONSTANT") << 1 << "blub6" << "" << "test" << false << "const"; + QTest::newRow("sub1") + << 0 << "sub1" << "" << "helloSub1" << true << "helloSub1"; + QTest::newRow("sub2") + << 0 << "sub2" << "" << "helloSub2" << true << "helloSub2"; } void tst_Moc::memberProperties() @@ -3068,7 +3088,7 @@ void tst_Moc::parseDefines() int index = mo->indexOfSlot("stringMethod()"); QVERIFY(index != -1); - QVERIFY(mo->method(index).returnType() == QMetaType::QString); + QCOMPARE(mo->method(index).returnType(), int(QMetaType::QString)); index = mo->indexOfSlot("combined1()"); QVERIFY(index != -1); @@ -3127,7 +3147,7 @@ void tst_Moc::parseDefines() QVERIFY(!qstrcmp(mci.value(), "TestValue")); } } - QVERIFY(count == 3); + QCOMPARE(count, 3); index = mo->indexOfSlot("PD_DEFINE_ITSELF_SUFFIX(int)"); QVERIFY(index != -1); @@ -3253,7 +3273,7 @@ void tst_Moc::relatedMetaObjectsWithinNamespaces() const QMetaObject *testMo = &QTBUG_2151::B::staticMetaObject; QVERIFY(testMo->d.relatedMetaObjects); - QVERIFY(testMo->d.relatedMetaObjects[0] == relatedMo); + QCOMPARE(testMo->d.relatedMetaObjects[0], relatedMo); } void tst_Moc::relatedMetaObjectsInGadget() @@ -3262,7 +3282,7 @@ void tst_Moc::relatedMetaObjectsInGadget() const QMetaObject *testMo = &QTBUG_35657::B::staticMetaObject; QVERIFY(testMo->d.relatedMetaObjects); - QVERIFY(testMo->d.relatedMetaObjects[0] == relatedMo); + QCOMPARE(testMo->d.relatedMetaObjects[0], relatedMo); } void tst_Moc::relatedMetaObjectsNameConflict_data() diff --git a/tests/auto/tools/qmake/qmake.pro b/tests/auto/tools/qmake/qmake.pro index 5ed3073e20..d0817247db 100644 --- a/tests/auto/tools/qmake/qmake.pro +++ b/tests/auto/tools/qmake/qmake.pro @@ -8,5 +8,11 @@ SOURCES += tst_qmake.cpp testcompiler.cpp QT = core testlib cross_compile: DEFINES += QMAKE_CROSS_COMPILED +debug_and_release { + CONFIG(debug, debug|release): \ + DEFINES += DEBUG_BUILD + else: \ + DEFINES += RELEASE_BUILD +} TESTDATA += testdata/* diff --git a/tests/auto/tools/qmake/testdata/.gitignore b/tests/auto/tools/qmake/testdata/.gitignore new file mode 100644 index 0000000000..1e997b287b --- /dev/null +++ b/tests/auto/tools/qmake/testdata/.gitignore @@ -0,0 +1,5 @@ +# Created by various tests, even for shadow builds: +/pro_file_cache/include.pri +/quotedfilenames/cpp folder/ +/quotedfilenames/quotedfilenames +/resources/resources diff --git a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro index 442c9c767f..afb3f65297 100644 --- a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro +++ b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro @@ -1,4 +1,5 @@ DESTDIR = ./ +gcc: QMAKE_CXXFLAGS += -Wno-comment HEADERS += object1.h \ object2.h \ @@ -8,5 +9,7 @@ HEADERS += object1.h \ object6.h \ object7.h \ object8.h \ - object9.h -SOURCES += main.cpp + object9.h \ + objecta.h \ + objectf.h +SOURCES += main.cpp needed.cpp diff --git a/tests/auto/tools/qmake/testdata/findDeps/main.cpp b/tests/auto/tools/qmake/testdata/findDeps/main.cpp index e4aa5c6251..3f4f5def3c 100644 --- a/tests/auto/tools/qmake/testdata/findDeps/main.cpp +++ b/tests/auto/tools/qmake/testdata/findDeps/main.cpp @@ -31,23 +31,60 @@ ** ****************************************************************************/ +#define spurious \ + / #include "needed.cpp" +// if not ignored, symbol needed() won't be available ... - #include <moc_object1.cpp> -/**/ #include <moc_object2.cpp> -/**//**/ #include <moc_object3.cpp> -/*'*/ #include <moc_object4.cpp> -/* -*/ #include <moc_object5.cpp> +// Check we're not confused by string juxtaposition: +static const char text[] = "lorem ""ipsum /*"; -// + #include <moc_object1.cpp> +/**/ #include "\ +moc_object2.cpp\ +" +/**//**/ #include <moc_\ +o\ +b\ +j\ +e\ +c\ +t\ +3\ +.cpp> +/*'"*/ #include <moc_object4.cpp> +/*"' +*/ #include <moc_object5.cpp> /* +#include "missing.cpp" +*/// a backslash newline does make the next line part of this comment \ +/* so this text is in last line's C++-style comment, not a C-comment ! #include <moc_object6.cpp> +#if 0 +#pragma "ignore me" '&' L"me" +#line 4321 "main.cpp" more /* preprocessing */ tokens +#endif static void function1(); -#include <moc_object7.cpp> +#include/* every comment +gets replaced (in phase 3) by a single +space */<moc_object7.cpp> static void function2(); /**/ -#include <moc_object8.cpp> +#include \ +<moc_object8.cpp> static void function3(); // #include <moc_object9.cpp> +/* backslash-newline elimination happens in phase 2 *\ +/ # /* and that's valid here, too. *\ +/ include/* and, of course, here *\ +/<moc_objecta.cpp>// while we're here, ... \ +#include "needed.cpp" -int main () {} +int main () { + extern int needed(void); + return needed(); +} +/* + Deliberately end file in a #include, with nothing after it but the mandatory + (unescaped) newline at the end of every source file. +*/ +#include "moc_objectf.cpp" diff --git a/tests/auto/tools/qmake/testdata/findDeps/needed.cpp b/tests/auto/tools/qmake/testdata/findDeps/needed.cpp new file mode 100644 index 0000000000..698d0aaa12 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/findDeps/needed.cpp @@ -0,0 +1 @@ +extern int needed(void) { return 1; } diff --git a/tests/auto/tools/qmake/testdata/findDeps/objecta.h b/tests/auto/tools/qmake/testdata/findDeps/objecta.h new file mode 100644 index 0000000000..b9813b9e18 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/findDeps/objecta.h @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QObject> + +class ObjectA : public QObject +{ + Q_OBJECT +}; + diff --git a/tests/auto/tools/qmake/testdata/findDeps/objectf.h b/tests/auto/tools/qmake/testdata/findDeps/objectf.h new file mode 100644 index 0000000000..5dead815a0 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/findDeps/objectf.h @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QObject> + +class ObjectF : public QObject +{ + Q_OBJECT +}; + diff --git a/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro b/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro index a4a7dc987d..af672c2621 100644 --- a/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro +++ b/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro @@ -1,4 +1,5 @@ DESTDIR = ./ -HEADERS += object1.h object2.h object3.h object4.h object5.h object6.h object7.h +HEADERS += object1.h object2.h object3.h object4.h \ + object5.h object6.h object7.h object8.h object9.h SOURCES += main.cpp diff --git a/tests/auto/tools/qmake/testdata/findMocs/main.cpp b/tests/auto/tools/qmake/testdata/findMocs/main.cpp index 8e0ef9fc41..3f566c4af4 100644 --- a/tests/auto/tools/qmake/testdata/findMocs/main.cpp +++ b/tests/auto/tools/qmake/testdata/findMocs/main.cpp @@ -39,6 +39,7 @@ #include <moc_object5.cpp> #include <moc_object6.cpp> #include <moc_object7.cpp> +#include "object8.h" +#include <moc_object9.cpp> -int main () {} - +int main() { return 0; } diff --git a/tests/auto/tools/qmake/testdata/findMocs/object1.h b/tests/auto/tools/qmake/testdata/findMocs/object1.h index e0857f4297..1fcac5f511 100644 --- a/tests/auto/tools/qmake/testdata/findMocs/object1.h +++ b/tests/auto/tools/qmake/testdata/findMocs/object1.h @@ -37,6 +37,6 @@ class Object1 : public QObject { - Q_OBJECT + Q\ +_OBJECT }; - diff --git a/tests/auto/tools/qmake/testdata/findMocs/object2.h b/tests/auto/tools/qmake/testdata/findMocs/object2.h index cc60269cd3..a52489b44c 100644 --- a/tests/auto/tools/qmake/testdata/findMocs/object2.h +++ b/tests/auto/tools/qmake/testdata/findMocs/object2.h @@ -36,6 +36,6 @@ class Object2 : public QObject { - Q_OBJECT + Q_\ +OBJECT }; - diff --git a/tests/auto/tools/qmake/testdata/findMocs/object3.h b/tests/auto/tools/qmake/testdata/findMocs/object3.h index c66edee6e1..c481a0796d 100644 --- a/tests/auto/tools/qmake/testdata/findMocs/object3.h +++ b/tests/auto/tools/qmake/testdata/findMocs/object3.h @@ -37,6 +37,6 @@ class Object3 : public QObject { - Q_OBJECT + Q_OBJ\ +ECT }; - diff --git a/tests/auto/tools/qmake/testdata/findMocs/object4.h b/tests/auto/tools/qmake/testdata/findMocs/object4.h index 73bf9cdaa3..eb38652f14 100644 --- a/tests/auto/tools/qmake/testdata/findMocs/object4.h +++ b/tests/auto/tools/qmake/testdata/findMocs/object4.h @@ -44,10 +44,9 @@ class Object4 : public QObject Comment ends there --> /*/ // Now we poison moc, just to make sure this doesn't get moc'ed :) -class NonMocObject +class NonMocObject4 /* : QObject */ { /* qmake ignore Q_OBJECT */ Q_OBJECT }; - diff --git a/tests/auto/tools/qmake/testdata/findMocs/object7.h b/tests/auto/tools/qmake/testdata/findMocs/object7.h index 92b4672d6b..3922a542e0 100644 --- a/tests/auto/tools/qmake/testdata/findMocs/object7.h +++ b/tests/auto/tools/qmake/testdata/findMocs/object7.h @@ -33,6 +33,7 @@ /**//*'*/ #include <QObject> +#define bogon /"/*" class Object7 : public QObject { diff --git a/tests/auto/tools/qmake/testdata/findMocs/object8.h b/tests/auto/tools/qmake/testdata/findMocs/object8.h new file mode 100644 index 0000000000..51096e4c27 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/findMocs/object8.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QObject> +#define Q_OBJECTOID_THING // empty + +class Object8 : public QObject +{ + Q_OBJECT\ +OID_THING +}; + +// Now we poison moc, just to make sure this doesn't get moc'ed :) +class NonMocObject8 +/* : QObject */ +{ + /* qmake ignore Q_OBJECT */ + Q_OBJECT +}; diff --git a/tests/auto/tools/qmake/testdata/findMocs/object9.h b/tests/auto/tools/qmake/testdata/findMocs/object9.h new file mode 100644 index 0000000000..bda50355d9 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/findMocs/object9.h @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QObject> +#define juxtaposed "lorem ""ipsum /*" + +class Object9 : public QObject +{ + Q_OBJECT +}; diff --git a/tests/auto/tools/qmake/testdata/rawString/main.cpp b/tests/auto/tools/qmake/testdata/rawString/main.cpp new file mode 100644 index 0000000000..604986666a --- /dev/null +++ b/tests/auto/tools/qmake/testdata/rawString/main.cpp @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +static const char raw[] = R"blah(lorem " ipsum /*)blah"\ +; +#include <moc_object1.cpp> + +int main () { return 0; } diff --git a/tests/auto/tools/qmake/testdata/rawString/object1.h b/tests/auto/tools/qmake/testdata/rawString/object1.h new file mode 100644 index 0000000000..1435624f7b --- /dev/null +++ b/tests/auto/tools/qmake/testdata/rawString/object1.h @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#define rawstring R"blah(lorem " ipsum /*)blah"; +#include <QObject> + +class Object1 : public QObject +{ + Q_OBJECT +}; diff --git a/tests/auto/tools/qmake/testdata/rawString/rawString.pro b/tests/auto/tools/qmake/testdata/rawString/rawString.pro new file mode 100644 index 0000000000..d2d8132ceb --- /dev/null +++ b/tests/auto/tools/qmake/testdata/rawString/rawString.pro @@ -0,0 +1,4 @@ +DESTDIR = ./ + +HEADERS += object1.h +SOURCES += main.cpp diff --git a/tests/auto/tools/qmake/testdata/resources/main.cpp b/tests/auto/tools/qmake/testdata/resources/main.cpp new file mode 100644 index 0000000000..78f9814396 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/resources/main.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + + +#include <qguiapplication.h> + +int main( int argc, char **argv ) +{ + QGuiApplication a( argc, argv ); + return a.exec(); +} diff --git a/tests/auto/tools/qmake/testdata/resources/resources.pro b/tests/auto/tools/qmake/testdata/resources/resources.pro new file mode 100644 index 0000000000..f024fe5617 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/resources/resources.pro @@ -0,0 +1,10 @@ +TEMPLATE = app +SOURCES = main.cpp + +pro_file.files = resources.pro +pro_file.prefix = /prefix + +subdir.files = subdir/file.txt +subdir.base = subdir + +RESOURCES = test.qrc main.cpp pro_file subdir diff --git a/tests/auto/tools/qmake/testdata/resources/subdir/file.txt b/tests/auto/tools/qmake/testdata/resources/subdir/file.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/resources/subdir/file.txt diff --git a/tests/auto/tools/qmake/testdata/resources/test.qrc b/tests/auto/tools/qmake/testdata/resources/test.qrc new file mode 100644 index 0000000000..decde3dd24 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/resources/test.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>test.qrc</file> + </qresource> +</RCC> diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index da5314c83b..d216a54575 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -39,6 +39,14 @@ #include <QStandardPaths> #include <QDir> +#if defined(DEBUG_BUILD) +# define DIR_INFIX "debug/" +#elif defined(RELEASE_BUILD) +# define DIR_INFIX "release/" +#else +# define DIR_INFIX "" +#endif + class tst_qmake : public QObject { Q_OBJECT @@ -71,12 +79,14 @@ private slots: void one_space(); void findMocs(); void findDeps(); + void rawString(); #if defined(Q_OS_MAC) void bundle_spaces(); #endif void substitutes(); void project(); void proFileCache(); + void resources(); private: TestCompiler test_compiler; @@ -397,6 +407,24 @@ void tst_qmake::findDeps() QVERIFY( test_compiler.removeMakefile(workDir) ); } +void tst_qmake::rawString() +{ +#ifdef Q_COMPILER_RAW_STRINGS + QString workDir = base_path + "/testdata/rawString"; + + QVERIFY( test_compiler.qmake(workDir, "rawString") ); + QVERIFY( test_compiler.make(workDir) ); + QVERIFY( test_compiler.exists(workDir, "rawString", Exe, "1.0.0" ) ); + QVERIFY( test_compiler.makeClean(workDir) ); + QVERIFY( test_compiler.exists(workDir, "rawString", Exe, "1.0.0" ) ); + QVERIFY( test_compiler.makeDistClean(workDir ) ); + QVERIFY( !test_compiler.exists(workDir, "rawString", Exe, "1.0.0" ) ); + QVERIFY( test_compiler.removeMakefile(workDir) ); +#else + QSKIP("Test for C++11 raw strings depends on compiler support for them"); +#endif +} + struct TempFile : QFile { @@ -490,5 +518,38 @@ void tst_qmake::proFileCache() QVERIFY( test_compiler.qmake( workDir, "pro_file_cache" )); } +void tst_qmake::resources() +{ + QString workDir = base_path + "/testdata/resources"; + QVERIFY(test_compiler.qmake(workDir, "resources")); + + { + QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_pro_file.qrc"); + QVERIFY(qrcFile.exists()); + QVERIFY(qrcFile.open(QFile::ReadOnly)); + QByteArray qrcXml = qrcFile.readAll(); + QVERIFY(qrcXml.contains("alias=\"resources.pro\"")); + QVERIFY(qrcXml.contains("prefix=\"/prefix\"")); + } + + { + QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_subdir.qrc"); + QVERIFY(qrcFile.exists()); + QVERIFY(qrcFile.open(QFile::ReadOnly)); + QByteArray qrcXml = qrcFile.readAll(); + QVERIFY(qrcXml.contains("alias=\"file.txt\"")); + } + + { + QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_qmake_immediate.qrc"); + QVERIFY(qrcFile.exists()); + QVERIFY(qrcFile.open(QFile::ReadOnly)); + QByteArray qrcXml = qrcFile.readAll(); + QVERIFY(qrcXml.contains("alias=\"main.cpp\"")); + } + + QVERIFY(test_compiler.make(workDir)); +} + QTEST_MAIN(tst_qmake) #include "tst_qmake.moc" diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index bed4c792a1..beafef5ad2 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -2205,9 +2205,10 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << "" << true; + // FIXME: This also tests that 'exe' is accepted, but does not test whether it actually works. QTest::newRow("write_file(): append") << "VAR = 'one more line'\n" - "write_file(" + wpath + ", VAR, append): OK = 1\n" + "write_file(" + wpath + ", VAR, append exe): OK = 1\n" "OUT = $$cat(" + wpath + ", lines)" << "OK = 1\nOUT = 'other content' 'one more line'" << "" @@ -2227,7 +2228,13 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) QTest::newRow("write_file(): bad number of arguments") << "write_file(1, 2, 3, 4): OK = 1" << "OK = UNDEF" - << "##:1: write_file(name, [content var, [append]]) requires one to three arguments." + << "##:1: write_file(name, [content var, [append] [exe]]) requires one to three arguments." + << true; + + QTest::newRow("write_file(): invalid flag") + << "write_file(file, VAR, fail): OK = 1" + << "OK = UNDEF" + << "##:1: write_file(): invalid flag fail." << true; // FIXME: This doesn't test whether it actually works. diff --git a/tests/auto/tools/qmakelib/tst_qmakelib.h b/tests/auto/tools/qmakelib/tst_qmakelib.h index c4716ca65e..b043d31e21 100644 --- a/tests/auto/tools/qmakelib/tst_qmakelib.h +++ b/tests/auto/tools/qmakelib/tst_qmakelib.h @@ -90,8 +90,8 @@ public: virtual void message(int type, const QString &msg, const QString &fileName, int lineNo) { print(fileName, lineNo, type, msg); } - virtual void fileMessage(const QString &msg) - { doPrint(msg); } + virtual void fileMessage(int type, const QString &msg) + { Q_UNUSED(type) doPrint(msg); } virtual void aboutToEval(ProFile *, ProFile *, EvalFileType) {} virtual void doneWithEval(ProFile *) {} diff --git a/tests/auto/tools/uic/tst_uic.cpp b/tests/auto/tools/uic/tst_uic.cpp index eac80bed7a..42c8e3e7b9 100644 --- a/tests/auto/tools/uic/tst_uic.cpp +++ b/tests/auto/tools/uic/tst_uic.cpp @@ -86,6 +86,7 @@ static QByteArray msgProcessStartFailed(const QString &command, const QString &w void tst_uic::initTestCase() { + QVERIFY2(m_generated.isValid(), qPrintable(m_generated.errorString())); QVERIFY(m_versionRegexp.isValid()); m_baseline = QFINDTESTDATA("baseline"); QVERIFY2(!m_baseline.isEmpty(), "Could not find 'baseline'."); |