diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-10 18:48:16 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-10 18:55:12 (GMT) |
commit | 6bffb9055a6548730ba915630007ba44b292b03f (patch) | |
tree | c07d32efbba69e35318e4c9ea078afd5fe1f9987 /tests/auto | |
parent | 435fae071798817f57bc89bf5d1ac20aae488625 (diff) | |
parent | 4d31527417419d4f7c1417b9360ef91d72469aa0 (diff) | |
download | Qt-6bffb9055a6548730ba915630007ba44b292b03f.zip Qt-6bffb9055a6548730ba915630007ba44b292b03f.tar.gz Qt-6bffb9055a6548730ba915630007ba44b292b03f.tar.bz2 |
Merge commit 'qt/master' into graphicssceneindex
Conflicts:
src/gui/graphicsview/qgraphicsitem_p.h
tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
tests/auto/qgraphicsview/tst_qgraphicsview.cpp
Diffstat (limited to 'tests/auto')
91 files changed, 3076 insertions, 221 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 6143534..f94d428 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -436,6 +436,7 @@ xmlpatternsxslts.depends = xmlpatternsxqts unix:!embedded:contains(QT_CONFIG, dbus):SUBDIRS += \ qdbusabstractadaptor \ + qdbusabstractinterface \ qdbusconnection \ qdbusinterface \ qdbuslocalcalls \ diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 6d3bc0a..d2ef64a 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -140,6 +140,13 @@ struct GestureState last.secondfinger.lastPoint = TouchPoint(); last.secondfinger.point = TouchPoint(); last.secondfinger.offset = QPoint(); + last.pan.delivered = false; + last.pan.startPoints[0] = TouchPoint(); + last.pan.startPoints[1] = TouchPoint(); + last.pan.lastPoints[0] = TouchPoint(); + last.pan.lastPoints[1] = TouchPoint(); + last.pan.points[0] = TouchPoint(); + last.pan.points[1] = TouchPoint(); last.cancelled.clear(); } }; @@ -760,7 +767,8 @@ void tst_Gestures::simpleGraphicsItem() scene.addItem(item); QApplication::processEvents(); - SingleshotEvent event(50, 80); + QPoint pt = view.mapFromScene(item->mapToScene(30, 30)); + SingleshotEvent event(pt.x(), pt.y()); sendSpontaneousEvent(&view, &event); QVERIFY(item->gesture.seenGestureEvent); QVERIFY(scene.gesture.seenGestureEvent); @@ -771,7 +779,9 @@ void tst_Gestures::simpleGraphicsItem() mainWidget->reset(); item->shouldAcceptSingleshotGesture = false; - SingleshotEvent event2(20, 40); + // outside of the graphicsitem + pt = view.mapFromScene(item->mapToScene(-10, -10)); + SingleshotEvent event2(pt.x(), pt.y()); sendSpontaneousEvent(&view, &event2); QVERIFY(!item->gesture.seenGestureEvent); QVERIFY(scene.gesture.seenGestureEvent); @@ -790,9 +800,11 @@ void tst_Gestures::overlappingGraphicsItems() scene.addItem(item); GraphicsItem *subitem1 = new GraphicsItem(50, 70); subitem1->setPos(70, 70); + subitem1->setZValue(1); scene.addItem(subitem1); GraphicsItem *subitem2 = new GraphicsItem(50, 70); subitem2->setPos(250, 70); + subitem2->setZValue(1); scene.addItem(subitem2); QApplication::processEvents(); @@ -802,13 +814,14 @@ void tst_Gestures::overlappingGraphicsItems() subitem1->grabSingleshotGesture(); subitem2->grabSecondFingerGesture(); - SingleshotEvent event(100, 100); + QPoint pt = view.mapFromScene(subitem1->mapToScene(20, 20)); + SingleshotEvent event(pt.x(), pt.y()); sendSpontaneousEvent(&view, &event); - QVERIFY(subitem1->gesture.seenGestureEvent); + QVERIFY(scene.gesture.seenGestureEvent); QVERIFY(!subitem2->gesture.seenGestureEvent); QVERIFY(!item->gesture.seenGestureEvent); - QVERIFY(scene.gesture.seenGestureEvent); QVERIFY(!mainWidget->gesture.seenGestureEvent); + QVERIFY(subitem1->gesture.seenGestureEvent); QVERIFY(subitem1->gesture.last.singleshot.delivered); item->reset(); @@ -818,12 +831,12 @@ void tst_Gestures::overlappingGraphicsItems() mainWidget->reset(); subitem1->shouldAcceptSingleshotGesture = false; - SingleshotEvent event2(100, 100); + SingleshotEvent event2(pt.x(), pt.y()); sendSpontaneousEvent(&view, &event2); - QVERIFY(subitem1->gesture.seenGestureEvent); + QVERIFY(scene.gesture.seenGestureEvent); QVERIFY(!subitem2->gesture.seenGestureEvent); + QVERIFY(subitem1->gesture.seenGestureEvent); QVERIFY(item->gesture.seenGestureEvent); - QVERIFY(scene.gesture.seenGestureEvent); QVERIFY(!mainWidget->gesture.seenGestureEvent); QVERIFY(subitem1->gesture.last.singleshot.delivered); QVERIFY(item->gesture.last.singleshot.delivered); diff --git a/tests/auto/linguist/lconvert/tst_lconvert.cpp b/tests/auto/linguist/lconvert/tst_lconvert.cpp index 3df2a19..40be55a 100644 --- a/tests/auto/linguist/lconvert/tst_lconvert.cpp +++ b/tests/auto/linguist/lconvert/tst_lconvert.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Linguist of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include <QtTest/QtTest> #include <QtCore/QFile> diff --git a/tests/auto/linguist/lrelease/tst_lrelease.cpp b/tests/auto/linguist/lrelease/tst_lrelease.cpp index 6f65dbc..ff90b3c 100644 --- a/tests/auto/linguist/lrelease/tst_lrelease.cpp +++ b/tests/auto/linguist/lrelease/tst_lrelease.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Linguist of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include <QtCore/QDir> #include <QtCore/QDebug> #include <QtCore/QFile> @@ -14,6 +55,7 @@ private slots: void translate(); void mixedcodecs(); void compressed(); + void idbased(); void dupes(); private: @@ -150,6 +192,18 @@ void tst_lrelease::compressed() } +void tst_lrelease::idbased() +{ + QVERIFY(!QProcess::execute("lrelease -idbased testdata/idbased.ts")); + + QTranslator translator; + QVERIFY(translator.load("testdata/idbased.qm")); + qApp->installTranslator(&translator); + + QCOMPARE(qtTrId("test_id"), QString::fromAscii("This is a test string.")); + QCOMPARE(qtTrId("untranslated_id"), QString::fromAscii("This has no translation.")); +} + void tst_lrelease::dupes() { QProcess proc; diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before index e297784..076520a 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before @@ -5,7 +5,7 @@ <message> <location filename="project.ui" line="27"/> <source>Qt Assistant - Find text</source> - <!--should be changed to unfinished, since we are changing the sourcetext in the ui file--> + <!--should be changed to unfinished, since we are changing the sourcetext in the UI file--> <translation>Qt Assistant - Finn tekst</translation> </message> <message> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.result index d65110a..6bc565c 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.result @@ -9,7 +9,7 @@ </message> <message> <location filename="project.ui" line="20"/> - <source>This should not be considered to be more or less equal to the corresponding one in the ts file.</source> + <source>This should not be considered to be more or less equal to the corresponding one in the TS file.</source> <translation type="unfinished"></translation> </message> <message> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ui b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ui index 0d0defd..a5f8e9f 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ui +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ui @@ -17,7 +17,7 @@ <widget class="QWidget" name="FindDialog" > <property name="test1"> <!-- If the sourcetext is not similar to the vernacular sourcetext, mark the old one as obsolete and the new one as unfinished --> - <string>This should not be considered to be more or less equal to the corresponding one in the ts file.</string> + <string>This should not be considered to be more or less equal to the corresponding one in the TS file.</string> </property> <property name="test2"> <string>Here, similarity should kick in!</string> diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index df75baf..735e4cd 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -156,3 +156,34 @@ QT_TRANSLATE_NOOP3_UTF8("scope", "string", "comment") // 4.4 doesn't see this QT_TRANSLATE_NOOP("scope", "string " // this is an interleaved comment "continuation on next line") + + +class TestingTake17 : QObject { + Q_OBJECT + + int function(void) + { + //: random comment + //= this_is_an_id + //~ loc-layout_id fooish_bar + //~ po-ignore_me totally foo-barred nonsense + tr("something cool"); + + tr("less cool"); + + //= another_id + tr("even more cool"); + } +}; + + + + +//: again an extra comment, this time for id-based NOOP +//% "This is supposed\tto be quoted \" newline\n" +//% "backslashed \\ stuff." +QT_TRID_NOOP("this_a_id") + +//~ some thing +//% "This needs to be here. Really." +QString test = qtTrId("this_another_id", n); diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index 9386c19..97d3bce 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -2,6 +2,24 @@ <!DOCTYPE TS> <TS version="2.0"> <context> + <name></name> + <message id="this_a_id"> + <location filename="main.cpp" line="185"/> + <source>This is supposed to be quoted " newline +backslashed \ stuff.</source> + <extracomment>again an extra comment, this time for id-based NOOP</extracomment> + <translation type="unfinished"></translation> + </message> + <message id="this_another_id" numerus="yes"> + <location filename="main.cpp" line="189"/> + <source>This needs to be here. Really.</source> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + <extra-some>thing</extra-some> + </message> +</context> +<context> <name>Dialog2</name> <message numerus="yes"> <location filename="main.cpp" line="29"/> @@ -239,6 +257,27 @@ </message> </context> <context> + <name>TestingTake17</name> + <message id="this_is_an_id"> + <location filename="main.cpp" line="170"/> + <source>something cool</source> + <extracomment>random comment</extracomment> + <translation type="unfinished"></translation> + <extra-po-ignore_me>totally foo-barred nonsense</extra-po-ignore_me> + <extra-loc-layout_id>fooish_bar</extra-loc-layout_id> + </message> + <message> + <location filename="main.cpp" line="172"/> + <source>less cool</source> + <translation type="unfinished"></translation> + </message> + <message id="another_id"> + <location filename="main.cpp" line="175"/> + <source>even more cool</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>scope</name> <message numerus="yes"> <location filename="main.cpp" line="146"/> diff --git a/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.result index d65110a..6bc565c 100644 --- a/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.result @@ -9,7 +9,7 @@ </message> <message> <location filename="project.ui" line="20"/> - <source>This should not be considered to be more or less equal to the corresponding one in the ts file.</source> + <source>This should not be considered to be more or less equal to the corresponding one in the TS file.</source> <translation type="unfinished"></translation> </message> <message> diff --git a/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ui b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ui index 0d0defd..a5f8e9f 100644 --- a/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ui +++ b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ui @@ -17,7 +17,7 @@ <widget class="QWidget" name="FindDialog" > <property name="test1"> <!-- If the sourcetext is not similar to the vernacular sourcetext, mark the old one as obsolete and the new one as unfinished --> - <string>This should not be considered to be more or less equal to the corresponding one in the ts file.</string> + <string>This should not be considered to be more or less equal to the corresponding one in the TS file.</string> </property> <property name="test2"> <string>Here, similarity should kick in!</string> diff --git a/tests/auto/linguist/lupdate/testlupdate.cpp b/tests/auto/linguist/lupdate/testlupdate.cpp index c80dd54..8abc2b0 100644 --- a/tests/auto/linguist/lupdate/testlupdate.cpp +++ b/tests/auto/linguist/lupdate/testlupdate.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Linguist of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "testlupdate.h" #include <stdlib.h> #include <QtGui/QApplication> diff --git a/tests/auto/linguist/lupdate/testlupdate.h b/tests/auto/linguist/lupdate/testlupdate.h index 3fd7dcb..efe9d85 100644 --- a/tests/auto/linguist/lupdate/testlupdate.h +++ b/tests/auto/linguist/lupdate/testlupdate.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Linguist of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef TESTLUPDATE_H #define TESTLUPDATE_H diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp index 1beae73..fcf8582 100644 --- a/tests/auto/linguist/lupdate/tst_lupdate.cpp +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Linguist of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "testlupdate.h" #if CHECK_SIMTEXTH #include "../shared/simtexth.h" diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index 7facf4a..d799c1b 100644 --- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -172,22 +172,22 @@ private slots: private: static void setMatrix(QMatrix2x2& m, const qreal *values); - static void setMatrixFixed(QMatrix2x2& m, const qreal *values); + static void setMatrixDirect(QMatrix2x2& m, const qreal *values); static bool isSame(const QMatrix2x2& m, const qreal *values); static bool isIdentity(const QMatrix2x2& m); static void setMatrix(QMatrix3x3& m, const qreal *values); - static void setMatrixFixed(QMatrix3x3& m, const qreal *values); + static void setMatrixDirect(QMatrix3x3& m, const qreal *values); static bool isSame(const QMatrix3x3& m, const qreal *values); static bool isIdentity(const QMatrix3x3& m); static void setMatrix(QMatrix4x4& m, const qreal *values); - static void setMatrixFixed(QMatrix4x4& m, const qreal *values); + static void setMatrixDirect(QMatrix4x4& m, const qreal *values); static bool isSame(const QMatrix4x4& m, const qreal *values); static bool isIdentity(const QMatrix4x4& m); static void setMatrix(QMatrix4x3& m, const qreal *values); - static void setMatrixFixed(QMatrix4x3& m, const qreal *values); + static void setMatrixDirect(QMatrix4x3& m, const qreal *values); static bool isSame(const QMatrix4x3& m, const qreal *values); static bool isIdentity(const QMatrix4x3& m); }; @@ -321,8 +321,9 @@ void tst_QMatrix::setMatrix(QMatrix4x3& m, const qreal *values) } // Set a matrix to a specified array of values, which are assumed -// to be in row-major order. This sets the values using fixed-point. -void tst_QMatrix::setMatrixFixed(QMatrix2x2& m, const qreal *values) +// to be in row-major order. This sets the values directly into +// the internal data() array. +void tst_QMatrix::setMatrixDirect(QMatrix2x2& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 2; ++row) { @@ -331,7 +332,7 @@ void tst_QMatrix::setMatrixFixed(QMatrix2x2& m, const qreal *values) } } } -void tst_QMatrix::setMatrixFixed(QMatrix3x3& m, const qreal *values) +void tst_QMatrix::setMatrixDirect(QMatrix3x3& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 3; ++row) { @@ -340,7 +341,7 @@ void tst_QMatrix::setMatrixFixed(QMatrix3x3& m, const qreal *values) } } } -void tst_QMatrix::setMatrixFixed(QMatrix4x4& m, const qreal *values) +void tst_QMatrix::setMatrixDirect(QMatrix4x4& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 4; ++row) { @@ -349,7 +350,7 @@ void tst_QMatrix::setMatrixFixed(QMatrix4x4& m, const qreal *values) } } } -void tst_QMatrix::setMatrixFixed(QMatrix4x3& m, const qreal *values) +void tst_QMatrix::setMatrixDirect(QMatrix4x3& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 3; ++row) { @@ -359,8 +360,8 @@ void tst_QMatrix::setMatrixFixed(QMatrix4x3& m, const qreal *values) } } -// qFuzzyCompare isn't quite "fuzzy" enough to handle conversion -// to fixed-point and back again. So create "fuzzier" compares. +// qFuzzyCompare isn't always "fuzzy" enough to handle conversion +// between float, double, and qreal. So create "fuzzier" compares. static bool fuzzyCompare(float x, float y, qreal epsilon = 0.001) { float diff = x - y; @@ -511,7 +512,7 @@ void tst_QMatrix::create2x2() QVERIFY(!m2.isIdentity()); QMatrix2x2 m3; - setMatrixFixed(m3, uniqueValues2); + setMatrixDirect(m3, uniqueValues2); QVERIFY(isSame(m3, uniqueValues2)); QMatrix2x2 m4(m3); @@ -546,7 +547,7 @@ void tst_QMatrix::create3x3() QVERIFY(!m2.isIdentity()); QMatrix3x3 m3; - setMatrixFixed(m3, uniqueValues3); + setMatrixDirect(m3, uniqueValues3); QVERIFY(isSame(m3, uniqueValues3)); QMatrix3x3 m4(m3); @@ -581,7 +582,7 @@ void tst_QMatrix::create4x4() QVERIFY(!m2.isIdentity()); QMatrix4x4 m3; - setMatrixFixed(m3, uniqueValues4); + setMatrixDirect(m3, uniqueValues4); QVERIFY(isSame(m3, uniqueValues4)); QMatrix4x4 m4(m3); @@ -623,7 +624,7 @@ void tst_QMatrix::create4x3() QVERIFY(!m2.isIdentity()); QMatrix4x3 m3; - setMatrixFixed(m3, uniqueValues4x3); + setMatrixDirect(m3, uniqueValues4x3); QVERIFY(isSame(m3, uniqueValues4x3)); QMatrix4x3 m4(m3); @@ -2961,10 +2962,6 @@ void tst_QMatrix::extractTranslation() QVERIFY(fuzzyCompare(vec.y(), y, epsilon)); QVERIFY(fuzzyCompare(vec.z(), z, epsilon)); - // Have to be careful with numbers here, it is really easy to blow away - // the precision of a fixed pointer number, especially when doing distance - // formula for vector normalization - QMatrix4x4 lookAt; QVector3D eye(1.5f, -2.5f, 2.5f); lookAt.lookAt(eye, diff --git a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/math3d/qquaternion/tst_qquaternion.cpp index 395032f..16b87a1 100644 --- a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp +++ b/tests/auto/math3d/qquaternion/tst_qquaternion.cpp @@ -95,8 +95,8 @@ private slots: void nlerp(); }; -// qFuzzyCompare isn't quite "fuzzy" enough to handle conversion -// to fixed-point and back again. So create "fuzzier" compares. +// qFuzzyCompare isn't always "fuzzy" enough to handle conversion +// between float, double, and qreal. So create "fuzzier" compares. static bool fuzzyCompare(float x, float y) { float diff = x - y; diff --git a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/math3d/qvectornd/tst_qvectornd.cpp index 0eb5b07..9c1ea83 100644 --- a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/math3d/qvectornd/tst_qvectornd.cpp @@ -139,8 +139,8 @@ private slots: void dotProduct4(); }; -// qFuzzyCompare isn't quite "fuzzy" enough to handle conversion -// to fixed-point and back again. So create "fuzzier" compares. +// qFuzzyCompare isn't always "fuzzy" enough to handle conversion +// between float, double, and qreal. So create "fuzzier" compares. static bool fuzzyCompare(float x, float y) { float diff = x - y; diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp index fa786f1..0a2e46e 100644 --- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp +++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp @@ -157,11 +157,9 @@ void tst_Q3SqlCursor::createTestTables( QSqlDatabase db ) } if (tst_Databases::isMSAccess(db)) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision") + " (col1 number)")); - } else if (db.driverName().startsWith("QIBASE")) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision") + " (col1 numeric(15, 14))")); + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision") + " (col1 number)")); } else { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision") + " (col1 numeric(15, 14))")); + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision") + " (col1 numeric(15, 14))")); } } @@ -557,7 +555,7 @@ void tst_Q3SqlCursor::unicode() void tst_Q3SqlCursor::precision() { - static const QString precStr = "1.23456789012345"; + static const QString precStr = QLatin1String("1.23456789012345"); static const double precDbl = 2.23456789012345; QFETCH( QString, dbName ); @@ -576,7 +574,10 @@ void tst_Q3SqlCursor::precision() QVERIFY_SQL(cur, select()); QVERIFY( cur.next() ); - QCOMPARE( cur.value( 0 ).asString(), QString( precStr ) ); + if(!tst_Databases::isSqlServer(db)) + QCOMPARE( cur.value( 0 ).asString(), precStr ); + else + QCOMPARE( cur.value( 0 ).asString(), precStr.left(precStr.size()-1) ); // Sql server fails at counting. QVERIFY( cur.next() ); QCOMPARE( cur.value( 0 ).asDouble(), precDbl ); } @@ -760,9 +761,10 @@ void tst_Q3SqlCursor::insertFieldNameContainsWS() { QSqlQuery q(db); tst_Databases::safeDropTable(db, tableName); - QString query = QString("CREATE TABLE %1 (id int, \"first Name\" varchar(20), " - "lastName varchar(20))").arg(tableName); - QVERIFY_SQL(q, exec(query)); + QString query = "CREATE TABLE %1 (id int, " + + db.driver()->escapeIdentifier("first Name", QSqlDriver::FieldName) + + " varchar(20), lastName varchar(20))"; + QVERIFY_SQL(q, exec(query.arg(tableName))); Q3SqlCursor cur(tableName, true, db); cur.select(); diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 8a88b59..b8aec50 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -2623,6 +2623,13 @@ void tst_QAccessibility::spinBoxTest() QVERIFY(childRect.isNull() == false); } + spinBox->setFocus(); + QTestAccessibility::clearEvents(); + QTest::keyPress(spinBox, Qt::Key_Up); + QTest::qWait(200); + EventList events = QTestAccessibility::events(); + QTestAccessibilityEvent expectedEvent(spinBox, 0, (int)QAccessible::ValueChanged); + QVERIFY(events.contains(expectedEvent)); delete spinBox; QTestAccessibility::clearEvents(); #else diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 85494af..8532723 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -1820,27 +1820,38 @@ void tst_QApplication::touchEventPropagation() { int argc = 1; QApplication app(argc, &argv0, QApplication::GuiServer); - QTouchEvent::TouchPoint touchPoint(0); - QTouchEvent touchEvent(QEvent::TouchBegin, Qt::NoModifier, QList<QTouchEvent::TouchPoint *>() << (&touchPoint)); + + QList<QTouchEvent::TouchPoint> pressedTouchPoints; + QTouchEvent::TouchPoint press(0); + press.setState(Qt::TouchPointPressed); + pressedTouchPoints << press; + + QList<QTouchEvent::TouchPoint> releasedTouchPoints; + QTouchEvent::TouchPoint release(0); + release.setState(Qt::TouchPointReleased); + releasedTouchPoints << release; { // touch event behavior on a window TouchEventPropagationTestWidget window; window.setObjectName("1. window"); - QApplicationPrivate::sendTouchEvent(&window, &touchEvent); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints); QVERIFY(!window.seenTouchEvent); - QVERIFY(window.seenMouseEvent); + QVERIFY(!window.seenMouseEvent); window.reset(); - window.setAttribute(Qt::WA_AcceptsTouchEvents); - QApplicationPrivate::sendTouchEvent(&window, &touchEvent); + window.setAttribute(Qt::WA_AcceptTouchEvents); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints); QVERIFY(window.seenTouchEvent); - QVERIFY(window.seenMouseEvent); + QVERIFY(!window.seenMouseEvent); window.reset(); window.acceptTouchEvent = true; - QApplicationPrivate::sendTouchEvent(&window, &touchEvent); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints); QVERIFY(window.seenTouchEvent); QVERIFY(!window.seenMouseEvent); } @@ -1852,34 +1863,38 @@ void tst_QApplication::touchEventPropagation() TouchEventPropagationTestWidget widget(&window); widget.setObjectName("2. widget"); - QApplicationPrivate::sendTouchEvent(&widget, &touchEvent); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints); QVERIFY(!widget.seenTouchEvent); - QVERIFY(widget.seenMouseEvent); + QVERIFY(!widget.seenMouseEvent); QVERIFY(!window.seenTouchEvent); - QVERIFY(window.seenMouseEvent); + QVERIFY(!window.seenMouseEvent); window.reset(); widget.reset(); - widget.setAttribute(Qt::WA_AcceptsTouchEvents); - QApplicationPrivate::sendTouchEvent(&widget, &touchEvent); + widget.setAttribute(Qt::WA_AcceptTouchEvents); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints); QVERIFY(widget.seenTouchEvent); - QVERIFY(widget.seenMouseEvent); + QVERIFY(!widget.seenMouseEvent); QVERIFY(!window.seenTouchEvent); - QVERIFY(window.seenMouseEvent); + QVERIFY(!window.seenMouseEvent); window.reset(); widget.reset(); widget.acceptMouseEvent = true; - QApplicationPrivate::sendTouchEvent(&widget, &touchEvent); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints); QVERIFY(widget.seenTouchEvent); - QVERIFY(widget.seenMouseEvent); + QVERIFY(!widget.seenMouseEvent); QVERIFY(!window.seenTouchEvent); QVERIFY(!window.seenMouseEvent); window.reset(); widget.reset(); widget.acceptTouchEvent = true; - QApplicationPrivate::sendTouchEvent(&widget, &touchEvent); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints); QVERIFY(widget.seenTouchEvent); QVERIFY(!widget.seenMouseEvent); QVERIFY(!window.seenTouchEvent); @@ -1887,18 +1902,20 @@ void tst_QApplication::touchEventPropagation() window.reset(); widget.reset(); - widget.setAttribute(Qt::WA_AcceptsTouchEvents, false); - window.setAttribute(Qt::WA_AcceptsTouchEvents); - QApplicationPrivate::sendTouchEvent(&widget, &touchEvent); + widget.setAttribute(Qt::WA_AcceptTouchEvents, false); + window.setAttribute(Qt::WA_AcceptTouchEvents); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints); QVERIFY(!widget.seenTouchEvent); - QVERIFY(widget.seenMouseEvent); + QVERIFY(!widget.seenMouseEvent); QVERIFY(window.seenTouchEvent); - QVERIFY(window.seenMouseEvent); + QVERIFY(!window.seenMouseEvent); window.reset(); widget.reset(); window.acceptTouchEvent = true; - QApplicationPrivate::sendTouchEvent(&widget, &touchEvent); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints); QVERIFY(!widget.seenTouchEvent); QVERIFY(!widget.seenMouseEvent); QVERIFY(window.seenTouchEvent); @@ -1908,7 +1925,8 @@ void tst_QApplication::touchEventPropagation() widget.reset(); widget.acceptMouseEvent = true; // doesn't matter, touch events are propagated first window.acceptTouchEvent = true; - QApplicationPrivate::sendTouchEvent(&widget, &touchEvent); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints); + qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints); QVERIFY(!widget.seenTouchEvent); QVERIFY(!widget.seenMouseEvent); QVERIFY(window.seenTouchEvent); diff --git a/tests/auto/qchar/tst_qchar.cpp b/tests/auto/qchar/tst_qchar.cpp index 01ba534..512c180 100644 --- a/tests/auto/qchar/tst_qchar.cpp +++ b/tests/auto/qchar/tst_qchar.cpp @@ -500,6 +500,9 @@ void tst_QChar::normalization() } QFile f("NormalizationTest.txt"); + // Windows - current directory is the debug/release subdirectory where the executable is located + if (!f.exists()) + f.setFileName("../NormalizationTest.txt");; if (!f.exists()) { QFAIL("Couldn't find NormalizationTest.txt"); return; diff --git a/tests/auto/qcolumnview/tst_qcolumnview.cpp b/tests/auto/qcolumnview/tst_qcolumnview.cpp index 0216e0f..0b3ba7a 100644 --- a/tests/auto/qcolumnview/tst_qcolumnview.cpp +++ b/tests/auto/qcolumnview/tst_qcolumnview.cpp @@ -42,6 +42,7 @@ #include <QtTest/QtTest> #include <qstandarditemmodel.h> +#include <qitemdelegate.h> #include <qcolumnview.h> #include "../../../src/gui/itemviews/qcolumnviewgrip_p.h" #include "../../../src/gui/dialogs/qfilesystemmodel_p.h" @@ -87,6 +88,8 @@ private slots: void setSelectionModel(); void visualRegionForSelection(); + void dynamicModelChanges(); + // grip void moveGrip_basic(); void moveGrip_data(); @@ -133,16 +136,10 @@ public: inline QModelIndex thirdLevel() { return index(0, 0, secondLevel()); } }; -class ColumnViewPrivate : public QColumnViewPrivate -{ -public: - ColumnViewPrivate() : QColumnViewPrivate() {} -}; - class ColumnView : public QColumnView { public: - ColumnView(QWidget *parent = 0) : QColumnView(*new ColumnViewPrivate, parent){} + ColumnView(QWidget *parent = 0) : QColumnView(parent){} QList<QPointer<QAbstractItemView> > createdColumns; void ScrollContentsBy(int x, int y) {scrollContentsBy(x,y); } @@ -1002,6 +999,37 @@ void tst_QColumnView::pullRug() // don't crash } +void tst_QColumnView::dynamicModelChanges() +{ + struct MyItemDelegate : public QItemDelegate + { + void paint(QPainter *painter, + const QStyleOptionViewItem &option, + const QModelIndex &index) const + { + paintedIndexes += index; + QItemDelegate::paint(painter, option, index); + } + + mutable QSet<QModelIndex> paintedIndexes; + + } delegate;; + QStandardItemModel model; + ColumnView view; + view.setModel(&model); + view.setItemDelegate(&delegate); + view.show(); + + QStandardItem *item = new QStandardItem(QLatin1String("item")); + model.appendRow(item); + + QTest::qWait(200); //let the time for painting to occur + QCOMPARE(delegate.paintedIndexes.count(), 1); + QCOMPARE(*delegate.paintedIndexes.begin(), model.index(0,0)); + + +} + QTEST_MAIN(tst_QColumnView) #include "tst_qcolumnview.moc" diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index c94ace0..67c9ac9 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -1973,6 +1973,7 @@ void tst_QComboBox::task190351_layout() listCombo.showPopup(); QTest::qWait(100); +#ifdef QT_BUILD_INTERNAL QFrame *container = qFindChild<QComboBoxPrivateContainer *>(&listCombo); QVERIFY(container); QCOMPARE(static_cast<QAbstractItemView *>(list), qFindChild<QAbstractItemView *>(container)); @@ -1980,6 +1981,7 @@ void tst_QComboBox::task190351_layout() QVERIFY(top); QVERIFY(top->isVisible()); QCOMPARE(top->mapToGlobal(QPoint(0, top->height())).y(), list->mapToGlobal(QPoint()).y()); +#endif QApplication::setStyle(oldStyle); #else @@ -2045,6 +2047,7 @@ void tst_QComboBox::task191329_size() tableCombo.showPopup(); QTest::qWait(100); +#ifdef QT_BUILD_INTERNAL QFrame *container = qFindChild<QComboBoxPrivateContainer *>(&tableCombo); QVERIFY(container); QCOMPARE(static_cast<QAbstractItemView *>(table), qFindChild<QAbstractItemView *>(container)); @@ -2052,6 +2055,7 @@ void tst_QComboBox::task191329_size() //the popup should be large enough to contains everithing so the top and left button are hidden QVERIFY(!button->isVisible()); } +#endif QApplication::setStyle(oldStyle); #else @@ -2107,9 +2111,11 @@ void tst_QComboBox::task248169_popupWithMinimalSize() comboBox.showPopup(); QTest::qWait(100); +#ifdef QT_BUILD_INTERNAL QFrame *container = qFindChild<QComboBoxPrivateContainer *>(&comboBox); QVERIFY(container); QVERIFY(desktop.screenGeometry(container).contains(container->geometry())); +#endif } void tst_QComboBox::task247863_keyBoardSelection() diff --git a/tests/auto/qcssparser/qcssparser.pro b/tests/auto/qcssparser/qcssparser.pro index 57d6804..723e4d3 100644 --- a/tests/auto/qcssparser/qcssparser.pro +++ b/tests/auto/qcssparser/qcssparser.pro @@ -3,6 +3,7 @@ SOURCES += tst_cssparser.cpp DEFINES += SRCDIR=\\\"$$PWD\\\" QT += xml +requires(contains(QT_CONFIG,private_tests)) wince*: { addFiles.sources = testdata diff --git a/tests/auto/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp index c70c619..5d08c63 100644 --- a/tests/auto/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp +++ b/tests/auto/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp @@ -609,19 +609,22 @@ void tst_QDBusAbstractAdaptor::methodCalls() QVERIFY(con.isConnected()); //QDBusInterface emptycon.baseService(), "/", QString()); - QDBusInterface if1(con.baseService(), "/", "local.Interface1", con); - QDBusInterface if2(con.baseService(), "/", "local.Interface2", con); - QDBusInterface if3(con.baseService(), "/", "local.Interface3", con); - QDBusInterface if4(con.baseService(), "/", "local.Interface4", con); - // must fail: no object - //QCOMPARE(empty->call("method").type(), QDBusMessage::ErrorMessage); - QCOMPARE(if1.call(QDBus::BlockWithGui, "method").type(), QDBusMessage::ErrorMessage); + { + // must fail: no object + QDBusInterface if1(con.baseService(), "/", "local.Interface1", con); + QCOMPARE(if1.call(QDBus::BlockWithGui, "method").type(), QDBusMessage::ErrorMessage); + } QFETCH(int, nInterfaces); MyObject obj(nInterfaces); con.registerObject("/", &obj); + QDBusInterface if1(con.baseService(), "/", "local.Interface1", con); + QDBusInterface if2(con.baseService(), "/", "local.Interface2", con); + QDBusInterface if3(con.baseService(), "/", "local.Interface3", con); + QDBusInterface if4(con.baseService(), "/", "local.Interface4", con); + // must fail: no such method QCOMPARE(if1.call(QDBus::BlockWithGui, "method").type(), QDBusMessage::ErrorMessage); if (!nInterfaces--) @@ -670,11 +673,11 @@ void tst_QDBusAbstractAdaptor::methodCallScriptable() QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(con.isConnected()); - QDBusInterface if2(con.baseService(), "/", "local.Interface2", con); - MyObject obj(2); con.registerObject("/", &obj); + QDBusInterface if2(con.baseService(), "/", "local.Interface2", con); + QCOMPARE(if2.call(QDBus::BlockWithGui,"scriptableMethod").type(), QDBusMessage::ReplyMessage); QCOMPARE(slotSpy, "void Interface2::scriptableMethod()"); } diff --git a/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml b/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml new file mode 100644 index 0000000..fb2aab8 --- /dev/null +++ b/tests/auto/qdbusabstractinterface/com.trolltech.QtDBus.Pinger.xml @@ -0,0 +1,30 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> + <interface name="com.trolltech.QtDBus.Pinger"> + <property name="stringProp" type="s" access="readwrite"/> + <property name="variantProp" type="v" access="readwrite"/> + <property name="complexProp" type="(s)" access="readwrite"> + <annotation name="com.trolltech.QtDBus.QtTypeName" value="RegisteredType"/> + </property> + <signal name="voidSignal"/> + <signal name="stringSignal"> + <arg type="s"/> + </signal> + <signal name="complexSignal"> + <arg name="" type="(s)"/> + <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="RegisteredType"/> + </signal> + <method name="voidMethod" /> + <method name="stringMethod"> + <arg type="s" direction="out"/> + </method> + <method name="complexMethod"> + <arg type="(s)" direction="out"/> + <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="RegisteredType"/> + </method> + <method name="multiOutMethod"> + <arg type="s" direction="out"/> + <arg type="i" direction="out"/ + </method> + </interface> +</node> diff --git a/tests/auto/qdbusabstractinterface/interface.cpp b/tests/auto/qdbusabstractinterface/interface.cpp new file mode 100644 index 0000000..1c391ce --- /dev/null +++ b/tests/auto/qdbusabstractinterface/interface.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "interface.h" + +Interface::Interface() +{ +} + +#include "moc_interface.cpp" diff --git a/tests/auto/qdbusabstractinterface/interface.h b/tests/auto/qdbusabstractinterface/interface.h new file mode 100644 index 0000000..f6d34a7 --- /dev/null +++ b/tests/auto/qdbusabstractinterface/interface.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef INTERFACE_H +#define INTERFACE_H + +#include <QtCore/QObject> +#include <QtDBus/QDBusArgument> + +struct RegisteredType +{ + inline RegisteredType(const QString &str = QString()) : s(str) {} + inline bool operator==(const RegisteredType &other) const { return s == other.s; } + QString s; +}; +Q_DECLARE_METATYPE(RegisteredType) + +inline QDBusArgument &operator<<(QDBusArgument &s, const RegisteredType &data) +{ + s.beginStructure(); + s << data.s; + s.endStructure(); + return s; +} + +inline const QDBusArgument &operator>>(const QDBusArgument &s, RegisteredType &data) +{ + s.beginStructure(); + s >> data.s; + s.endStructure(); + return s; +} + +struct UnregisteredType +{ + QString s; +}; +Q_DECLARE_METATYPE(UnregisteredType) + +class Interface: public QObject +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.trolltech.QtDBus.Pinger") + Q_PROPERTY(QString stringProp READ stringProp WRITE setStringProp SCRIPTABLE true) + Q_PROPERTY(QDBusVariant variantProp READ variantProp WRITE setVariantProp SCRIPTABLE true) + Q_PROPERTY(RegisteredType complexProp READ complexProp WRITE setComplexProp SCRIPTABLE true) + + friend class tst_QDBusAbstractInterface; + QString m_stringProp; + QDBusVariant m_variantProp; + RegisteredType m_complexProp; + +public: + Interface(); + + QString stringProp() const { return m_stringProp; } + void setStringProp(const QString &s) { m_stringProp = s; } + QDBusVariant variantProp() const { return m_variantProp; } + void setVariantProp(const QDBusVariant &v) { m_variantProp = v; } + RegisteredType complexProp() const { return m_complexProp; } + void setComplexProp(const RegisteredType &r) { m_complexProp = r; } + +public slots: + Q_SCRIPTABLE void voidMethod() {} + Q_SCRIPTABLE QString stringMethod() { return "Hello, world"; } + Q_SCRIPTABLE RegisteredType complexMethod() { return RegisteredType("Hello, world"); } + Q_SCRIPTABLE QString multiOutMethod(int &value) { value = 42; return "Hello, world"; } + +signals: + Q_SCRIPTABLE void voidSignal(); + Q_SCRIPTABLE void stringSignal(const QString &); + Q_SCRIPTABLE void complexSignal(RegisteredType); +}; + +#endif // INTERFACE_H diff --git a/tests/auto/qdbusabstractinterface/pinger.cpp b/tests/auto/qdbusabstractinterface/pinger.cpp new file mode 100644 index 0000000..4fcb89a --- /dev/null +++ b/tests/auto/qdbusabstractinterface/pinger.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDBus module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -i interface.h -p pinger com.trolltech.QtDBus.Pinger.xml + * + * qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "pinger.h" + +/* + * Implementation of interface class ComTrolltechQtDBusPingerInterface + */ + +ComTrolltechQtDBusPingerInterface::ComTrolltechQtDBusPingerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +ComTrolltechQtDBusPingerInterface::~ComTrolltechQtDBusPingerInterface() +{ +} + diff --git a/tests/auto/qdbusabstractinterface/pinger.h b/tests/auto/qdbusabstractinterface/pinger.h new file mode 100644 index 0000000..fb8adda --- /dev/null +++ b/tests/auto/qdbusabstractinterface/pinger.h @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDBus module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -i interface.h -p pinger com.trolltech.QtDBus.Pinger.xml + * + * qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef PINGER_H_1246463415 +#define PINGER_H_1246463415 + +#include <QtCore/QObject> +#include <QtCore/QByteArray> +#include <QtCore/QList> +#include <QtCore/QMap> +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QVariant> +#include <QtDBus/QtDBus> +#include "interface.h" + +/* + * Proxy class for interface com.trolltech.QtDBus.Pinger + */ +class ComTrolltechQtDBusPingerInterface: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "com.trolltech.QtDBus.Pinger"; } + +public: + ComTrolltechQtDBusPingerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~ComTrolltechQtDBusPingerInterface(); + + Q_PROPERTY(RegisteredType complexProp READ complexProp WRITE setComplexProp) + inline RegisteredType complexProp() const + { return qvariant_cast< RegisteredType >(property("complexProp")); } + inline void setComplexProp(RegisteredType value) + { setProperty("complexProp", qVariantFromValue(value)); } + + Q_PROPERTY(QString stringProp READ stringProp WRITE setStringProp) + inline QString stringProp() const + { return qvariant_cast< QString >(property("stringProp")); } + inline void setStringProp(const QString &value) + { setProperty("stringProp", qVariantFromValue(value)); } + + Q_PROPERTY(QDBusVariant variantProp READ variantProp WRITE setVariantProp) + inline QDBusVariant variantProp() const + { return qvariant_cast< QDBusVariant >(property("variantProp")); } + inline void setVariantProp(const QDBusVariant &value) + { setProperty("variantProp", qVariantFromValue(value)); } + +public Q_SLOTS: // METHODS + inline QDBusPendingReply<RegisteredType> complexMethod() + { + QList<QVariant> argumentList; + return asyncCallWithArgumentList(QLatin1String("complexMethod"), argumentList); + } + + inline QDBusPendingReply<QString, int> multiOutMethod() + { + QList<QVariant> argumentList; + return asyncCallWithArgumentList(QLatin1String("multiOutMethod"), argumentList); + } + inline QDBusReply<QString> multiOutMethod(int &out1) + { + QList<QVariant> argumentList; + QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("multiOutMethod"), argumentList); + if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) { + out1 = qdbus_cast<int>(reply.arguments().at(1)); + } + return reply; + } + + inline QDBusPendingReply<QString> stringMethod() + { + QList<QVariant> argumentList; + return asyncCallWithArgumentList(QLatin1String("stringMethod"), argumentList); + } + + inline QDBusPendingReply<> voidMethod() + { + QList<QVariant> argumentList; + return asyncCallWithArgumentList(QLatin1String("voidMethod"), argumentList); + } + +Q_SIGNALS: // SIGNALS + void complexSignal(RegisteredType in0); + void stringSignal(const QString &in0); + void voidSignal(); +}; + +namespace com { + namespace trolltech { + namespace QtDBus { + typedef ::ComTrolltechQtDBusPingerInterface Pinger; + } + } +} +#endif diff --git a/tests/auto/qdbusabstractinterface/qdbusabstractinterface.pro b/tests/auto/qdbusabstractinterface/qdbusabstractinterface.pro new file mode 100644 index 0000000..a4853b8 --- /dev/null +++ b/tests/auto/qdbusabstractinterface/qdbusabstractinterface.pro @@ -0,0 +1,15 @@ +load(qttest_p4) +QT = core +contains(QT_CONFIG,dbus): { + SOURCES += tst_qdbusabstractinterface.cpp interface.cpp + HEADERS += interface.h + QT += dbus + + # These are generated sources + # To regenerate, see the command-line at the top of the files + SOURCES += pinger.cpp + HEADERS += pinger.h +} +else:SOURCES += ../qdbusmarshall/dummy.cpp + +OTHER_FILES += com.trolltech.QtDBus.Pinger.xml diff --git a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp new file mode 100644 index 0000000..fa5e332 --- /dev/null +++ b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp @@ -0,0 +1,576 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <qcoreapplication.h> +#include <qdebug.h> +#include <qsharedpointer.h> + +#include <QtTest/QtTest> + +#include <QtDBus> + +#include "interface.h" +#include "pinger.h" + +typedef QSharedPointer<com::trolltech::QtDBus::Pinger> Pinger; + +class tst_QDBusAbstractInterface: public QObject +{ + Q_OBJECT + Interface targetObj; + + Pinger getPinger(QString service = "", const QString &path = "/") + { + QDBusConnection con = QDBusConnection::sessionBus(); + if (!con.isConnected()) + return Pinger(); + if (service.isEmpty() && !service.isNull()) + service = con.baseService(); + return Pinger(new com::trolltech::QtDBus::Pinger(service, path, con)); + } + +public: + tst_QDBusAbstractInterface(); + +private slots: + void initTestCase(); + + void makeVoidCall(); + void makeStringCall(); + void makeComplexCall(); + void makeMultiOutCall(); + + void makeAsyncVoidCall(); + void makeAsyncStringCall(); + void makeAsyncComplexCall(); + void makeAsyncMultiOutCall(); + + void stringPropRead(); + void stringPropWrite(); + void variantPropRead(); + void variantPropWrite(); + void complexPropRead(); + void complexPropWrite(); + + void stringPropDirectRead(); + void stringPropDirectWrite(); + void variantPropDirectRead(); + void variantPropDirectWrite(); + void complexPropDirectRead(); + void complexPropDirectWrite(); + + void getVoidSignal_data(); + void getVoidSignal(); + void getStringSignal_data(); + void getStringSignal(); + void getComplexSignal_data(); + void getComplexSignal(); + + void createErrors_data(); + void createErrors(); + + void callErrors_data(); + void callErrors(); + void asyncCallErrors_data(); + void asyncCallErrors(); + + void propertyReadErrors_data(); + void propertyReadErrors(); + void propertyWriteErrors_data(); + void propertyWriteErrors(); + void directPropertyReadErrors_data(); + void directPropertyReadErrors(); + void directPropertyWriteErrors_data(); + void directPropertyWriteErrors(); +}; + +tst_QDBusAbstractInterface::tst_QDBusAbstractInterface() +{ + // register the meta types + qDBusRegisterMetaType<RegisteredType>(); + qRegisterMetaType<UnregisteredType>(); +} + +void tst_QDBusAbstractInterface::initTestCase() +{ + // register the object + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + con.registerObject("/", &targetObj, QDBusConnection::ExportScriptableContents); +} + +void tst_QDBusAbstractInterface::makeVoidCall() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusReply<void> r = p->voidMethod(); + QVERIFY(r.isValid()); +} + +void tst_QDBusAbstractInterface::makeStringCall() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusReply<QString> r = p->stringMethod(); + QVERIFY(r.isValid()); + QCOMPARE(r.value(), targetObj.stringMethod()); +} + +void tst_QDBusAbstractInterface::makeComplexCall() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusReply<RegisteredType> r = p->complexMethod(); + QVERIFY(r.isValid()); + QCOMPARE(r.value(), targetObj.complexMethod()); +} + +void tst_QDBusAbstractInterface::makeMultiOutCall() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + int value; + QDBusReply<QString> r = p->multiOutMethod(value); + QVERIFY(r.isValid()); + + int expectedValue; + QCOMPARE(r.value(), targetObj.multiOutMethod(expectedValue)); + QCOMPARE(value, expectedValue); +} + +void tst_QDBusAbstractInterface::makeAsyncVoidCall() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusPendingReply<void> r = p->voidMethod(); + r.waitForFinished(); + QVERIFY(r.isValid()); +} + +void tst_QDBusAbstractInterface::makeAsyncStringCall() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusPendingReply<QString> r = p->stringMethod(); + r.waitForFinished(); + QVERIFY(r.isValid()); + QCOMPARE(r.value(), targetObj.stringMethod()); +} + +void tst_QDBusAbstractInterface::makeAsyncComplexCall() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusPendingReply<RegisteredType> r = p->complexMethod(); + r.waitForFinished(); + QVERIFY(r.isValid()); + QCOMPARE(r.value(), targetObj.complexMethod()); +} + +void tst_QDBusAbstractInterface::makeAsyncMultiOutCall() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusPendingReply<QString, int> r = p->multiOutMethod(); + r.waitForFinished(); + QVERIFY(r.isValid()); + + int expectedValue; + QCOMPARE(r.value(), targetObj.multiOutMethod(expectedValue)); + QCOMPARE(r.argumentAt<1>(), expectedValue); +} + +void tst_QDBusAbstractInterface::stringPropRead() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QString expectedValue = targetObj.m_stringProp = "This is a test"; + QVariant v = p->property("stringProp"); + QVERIFY(v.isValid()); + QCOMPARE(v.toString(), expectedValue); +} + +void tst_QDBusAbstractInterface::stringPropWrite() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QString expectedValue = "This is a value"; + QVERIFY(p->setProperty("stringProp", expectedValue)); + QCOMPARE(targetObj.m_stringProp, expectedValue); +} + +void tst_QDBusAbstractInterface::variantPropRead() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusVariant expectedValue = targetObj.m_variantProp = QDBusVariant(QVariant(42)); + QVariant v = p->property("variantProp"); + QVERIFY(v.isValid()); + QDBusVariant value = v.value<QDBusVariant>(); + QCOMPARE(value.variant().userType(), expectedValue.variant().userType()); + QCOMPARE(value.variant(), expectedValue.variant()); +} + +void tst_QDBusAbstractInterface::variantPropWrite() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47)); + QVERIFY(p->setProperty("variantProp", qVariantFromValue(expectedValue))); + QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant()); +} + +void tst_QDBusAbstractInterface::complexPropRead() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + RegisteredType expectedValue = targetObj.m_complexProp = RegisteredType("This is a test"); + QVariant v = p->property("complexProp"); + QVERIFY(v.userType() == qMetaTypeId<RegisteredType>()); + QCOMPARE(v.value<RegisteredType>(), targetObj.m_complexProp); +} + +void tst_QDBusAbstractInterface::complexPropWrite() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + RegisteredType expectedValue = RegisteredType("This is a value"); + QVERIFY(p->setProperty("complexProp", qVariantFromValue(expectedValue))); + QCOMPARE(targetObj.m_complexProp, expectedValue); +} + +void tst_QDBusAbstractInterface::stringPropDirectRead() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QString expectedValue = targetObj.m_stringProp = "This is a test"; + QCOMPARE(p->stringProp(), expectedValue); +} + +void tst_QDBusAbstractInterface::stringPropDirectWrite() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QString expectedValue = "This is a value"; + p->setStringProp(expectedValue); + QCOMPARE(targetObj.m_stringProp, expectedValue); +} + +void tst_QDBusAbstractInterface::variantPropDirectRead() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusVariant expectedValue = targetObj.m_variantProp = QDBusVariant(42); + QCOMPARE(p->variantProp().variant(), expectedValue.variant()); +} + +void tst_QDBusAbstractInterface::variantPropDirectWrite() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47)); + p->setVariantProp(expectedValue); + QCOMPARE(targetObj.m_variantProp.variant().userType(), expectedValue.variant().userType()); + QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant()); +} + +void tst_QDBusAbstractInterface::complexPropDirectRead() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + RegisteredType expectedValue = targetObj.m_complexProp = RegisteredType("This is a test"); + QCOMPARE(p->complexProp(), targetObj.m_complexProp); +} + +void tst_QDBusAbstractInterface::complexPropDirectWrite() +{ + Pinger p = getPinger(); + QVERIFY2(p, "Not connected to D-Bus"); + + RegisteredType expectedValue = RegisteredType("This is a value"); + p->setComplexProp(expectedValue); + QCOMPARE(targetObj.m_complexProp, expectedValue); +} + +void tst_QDBusAbstractInterface::getVoidSignal_data() +{ + QTest::addColumn<QString>("service"); + QTest::addColumn<QString>("path"); + + QTest::newRow("specific") << QDBusConnection::sessionBus().baseService() << "/"; + QTest::newRow("service-wildcard") << QString() << "/"; + QTest::newRow("path-wildcard") << QDBusConnection::sessionBus().baseService() << QString(); + QTest::newRow("full-wildcard") << QString() << QString(); +} + +void tst_QDBusAbstractInterface::getVoidSignal() +{ + QFETCH(QString, service); + QFETCH(QString, path); + Pinger p = getPinger(service, path); + QVERIFY2(p, "Not connected to D-Bus"); + + // we need to connect the signal somewhere in order for D-Bus to enable the rules + QTestEventLoop::instance().connect(p.data(), SIGNAL(voidSignal()), SLOT(exitLoop())); + QSignalSpy s(p.data(), SIGNAL(voidSignal())); + + emit targetObj.voidSignal(); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QVERIFY(s.size() == 1); + QVERIFY(s.at(0).size() == 0); +} + +void tst_QDBusAbstractInterface::getStringSignal_data() +{ + getVoidSignal_data(); +} + +void tst_QDBusAbstractInterface::getStringSignal() +{ + QFETCH(QString, service); + QFETCH(QString, path); + Pinger p = getPinger(service, path); + QVERIFY2(p, "Not connected to D-Bus"); + + // we need to connect the signal somewhere in order for D-Bus to enable the rules + QTestEventLoop::instance().connect(p.data(), SIGNAL(stringSignal(QString)), SLOT(exitLoop())); + QSignalSpy s(p.data(), SIGNAL(stringSignal(QString))); + + QString expectedValue = "Good morning"; + emit targetObj.stringSignal(expectedValue); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QVERIFY(s.size() == 1); + QVERIFY(s[0].size() == 1); + QCOMPARE(s[0][0].userType(), int(QVariant::String)); + QCOMPARE(s[0][0].toString(), expectedValue); +} + +void tst_QDBusAbstractInterface::getComplexSignal_data() +{ + getVoidSignal_data(); +} + +void tst_QDBusAbstractInterface::getComplexSignal() +{ + QFETCH(QString, service); + QFETCH(QString, path); + Pinger p = getPinger(service, path); + QVERIFY2(p, "Not connected to D-Bus"); + + // we need to connect the signal somewhere in order for D-Bus to enable the rules + QTestEventLoop::instance().connect(p.data(), SIGNAL(complexSignal(RegisteredType)), SLOT(exitLoop())); + QSignalSpy s(p.data(), SIGNAL(complexSignal(RegisteredType))); + + RegisteredType expectedValue("Good evening"); + emit targetObj.complexSignal(expectedValue); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QVERIFY(s.size() == 1); + QVERIFY(s[0].size() == 1); + QCOMPARE(s[0][0].userType(), qMetaTypeId<RegisteredType>()); + QCOMPARE(s[0][0].value<RegisteredType>(), expectedValue); +} + +void tst_QDBusAbstractInterface::createErrors_data() +{ + QTest::addColumn<QString>("service"); + QTest::addColumn<QString>("path"); + QTest::addColumn<QString>("errorName"); + + QTest::newRow("invalid-service") << "this isn't valid" << "/" << "com.trolltech.QtDBus.Error.InvalidService"; + QTest::newRow("invalid-path") << QDBusConnection::sessionBus().baseService() << "this isn't valid" + << "com.trolltech.QtDBus.Error.InvalidObjectPath"; +} + +void tst_QDBusAbstractInterface::createErrors() +{ + QFETCH(QString, service); + QFETCH(QString, path); + Pinger p = getPinger(service, path); + QVERIFY2(p, "Not connected to D-Bus"); + + QVERIFY(!p->isValid()); + QTEST(p->lastError().name(), "errorName"); +} + +void tst_QDBusAbstractInterface::callErrors_data() +{ + createErrors_data(); + QTest::newRow("service-wildcard") << QString() << "/" << "com.trolltech.QtDBus.Error.InvalidService"; + QTest::newRow("path-wildcard") << QDBusConnection::sessionBus().baseService() << QString() + << "com.trolltech.QtDBus.Error.InvalidObjectPath"; + QTest::newRow("full-wildcard") << QString() << QString() << "com.trolltech.QtDBus.Error.InvalidService"; +} + +void tst_QDBusAbstractInterface::callErrors() +{ + QFETCH(QString, service); + QFETCH(QString, path); + Pinger p = getPinger(service, path); + QVERIFY2(p, "Not connected to D-Bus"); + + // we shouldn't be able to make this call: + QDBusReply<QString> r = p->stringMethod(); + QVERIFY(!r.isValid()); + QTEST(r.error().name(), "errorName"); + QCOMPARE(p->lastError().name(), r.error().name()); +} + +void tst_QDBusAbstractInterface::asyncCallErrors_data() +{ + callErrors_data(); +} + +void tst_QDBusAbstractInterface::asyncCallErrors() +{ + QFETCH(QString, service); + QFETCH(QString, path); + Pinger p = getPinger(service, path); + QVERIFY2(p, "Not connected to D-Bus"); + + // we shouldn't be able to make this call: + QDBusPendingReply<QString> r = p->stringMethod(); + QVERIFY(r.isError()); + QTEST(r.error().name(), "errorName"); + QCOMPARE(p->lastError().name(), r.error().name()); +} + +void tst_QDBusAbstractInterface::propertyReadErrors_data() +{ + callErrors_data(); +} + +void tst_QDBusAbstractInterface::propertyReadErrors() +{ + QFETCH(QString, service); + QFETCH(QString, path); + Pinger p = getPinger(service, path); + QVERIFY2(p, "Not connected to D-Bus"); + + // we shouldn't be able to get this value: + QVariant v = p->property("stringProp"); + QVERIFY(v.isNull()); + QVERIFY(!v.isValid()); + QTEST(p->lastError().name(), "errorName"); +} + +void tst_QDBusAbstractInterface::propertyWriteErrors_data() +{ + callErrors_data(); +} + +void tst_QDBusAbstractInterface::propertyWriteErrors() +{ + QFETCH(QString, service); + QFETCH(QString, path); + Pinger p = getPinger(service, path); + QVERIFY2(p, "Not connected to D-Bus"); + + // we shouldn't be able to get this value: + if (p->isValid()) + QCOMPARE(int(p->lastError().type()), int(QDBusError::NoError)); + QVERIFY(!p->setProperty("stringProp", "")); + QTEST(p->lastError().name(), "errorName"); +} + +void tst_QDBusAbstractInterface::directPropertyReadErrors_data() +{ + callErrors_data(); +} + +void tst_QDBusAbstractInterface::directPropertyReadErrors() +{ + QFETCH(QString, service); + QFETCH(QString, path); + Pinger p = getPinger(service, path); + QVERIFY2(p, "Not connected to D-Bus"); + + // we shouldn't be able to get this value: + QString v = p->stringProp(); + QVERIFY(v.isNull()); + QTEST(p->lastError().name(), "errorName"); +} + +void tst_QDBusAbstractInterface::directPropertyWriteErrors_data() +{ + callErrors_data(); +} + +void tst_QDBusAbstractInterface::directPropertyWriteErrors() +{ + QFETCH(QString, service); + QFETCH(QString, path); + Pinger p = getPinger(service, path); + QVERIFY2(p, "Not connected to D-Bus"); + + // we shouldn't be able to get this value: + // but there's no direct way of verifying that the setting failed + if (p->isValid()) + QCOMPARE(int(p->lastError().type()), int(QDBusError::NoError)); + p->setStringProp(""); + QTEST(p->lastError().name(), "errorName"); +} + +QTEST_MAIN(tst_QDBusAbstractInterface) +#include "tst_qdbusabstractinterface.moc" diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index c4d4b08..60afe4e 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -60,6 +60,9 @@ class MyObject: public QObject Q_CLASSINFO("D-Bus Introspection", "" " <interface name=\"com.trolltech.QtDBus.MyObject\" >\n" " <property access=\"readwrite\" type=\"i\" name=\"prop1\" />\n" +" <property name=\"complexProp\" type=\"ai\" access=\"readwrite\">\n" +" <annotation name=\"com.trolltech.QtDBus.QtTypeName\" value=\"QList<int>\"/>\n" +" </property>\n" " <signal name=\"somethingHappened\" >\n" " <arg direction=\"out\" type=\"s\" />\n" " </signal>\n" @@ -73,8 +76,17 @@ class MyObject: public QObject " <arg direction=\"out\" type=\"v\" name=\"pong1\" />\n" " <arg direction=\"out\" type=\"v\" name=\"pong2\" />\n" " </method>\n" +" <method name=\"ping\" >\n" +" <arg direction=\"in\" type=\"ai\" name=\"ping\" />\n" +" <arg direction=\"out\" type=\"ai\" name=\"ping\" />\n" +" <annotation name=\"com.trolltech.QtDBus.QtTypeName.In0\" value=\"QList<int>\"/>\n" +" <annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"QList<int>\"/>\n" +" </method>\n" " </interface>\n" "") + Q_PROPERTY(int prop1 READ prop1 WRITE setProp1) + Q_PROPERTY(QList<int> complexProp READ complexProp WRITE setComplexProp) + public: static int callCount; static QVariantList callArgs; @@ -84,6 +96,30 @@ public: subObject->setObjectName("subObject"); } + int m_prop1; + int prop1() const + { + ++callCount; + return m_prop1; + } + void setProp1(int value) + { + ++callCount; + m_prop1 = value; + } + + QList<int> m_complexProp; + QList<int> complexProp() const + { + ++callCount; + return m_complexProp; + } + void setComplexProp(const QList<int> &value) + { + ++callCount; + m_complexProp = value; + } + public slots: void ping(QDBusMessage msg) @@ -144,8 +180,16 @@ private slots: void introspect(); void callMethod(); void invokeMethod(); + void invokeMethodWithReturn(); + void invokeMethodWithMultiReturn(); + void invokeMethodWithComplexReturn(); void signal(); + + void propertyRead(); + void propertyWrite(); + void complexPropertyRead(); + void complexPropertyWrite(); }; void tst_QDBusInterface::initTestCase() @@ -154,7 +198,7 @@ void tst_QDBusInterface::initTestCase() QVERIFY(con.isConnected()); QTest::qWait(500); - con.registerObject("/", &obj, QDBusConnection::ExportAdaptors + con.registerObject("/", &obj, QDBusConnection::ExportAllProperties | QDBusConnection::ExportAllSlots | QDBusConnection::ExportChildObjects); } @@ -228,11 +272,12 @@ void tst_QDBusInterface::introspect() const QMetaObject *mo = iface.metaObject(); - QCOMPARE(mo->methodCount() - mo->methodOffset(), 3); + QCOMPARE(mo->methodCount() - mo->methodOffset(), 4); QVERIFY(mo->indexOfSignal(TEST_SIGNAL_NAME "(QString)") != -1); - QCOMPARE(mo->propertyCount() - mo->propertyOffset(), 1); + QCOMPARE(mo->propertyCount() - mo->propertyOffset(), 2); QVERIFY(mo->indexOfProperty("prop1") != -1); + QVERIFY(mo->indexOfProperty("complexProp") != -1); } void tst_QDBusInterface::callMethod() @@ -281,6 +326,87 @@ void tst_QDBusInterface::invokeMethod() QCOMPARE(dv.variant().toString(), QString("foo")); } +void tst_QDBusInterface::invokeMethodWithReturn() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), + TEST_INTERFACE_NAME); + + // make the call without a return type + MyObject::callCount = 0; + QDBusVariant arg("foo"); + QDBusVariant retArg; + QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QDBusVariant, retArg), Q_ARG(QDBusVariant, arg))); + QCOMPARE(MyObject::callCount, 1); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 1); + QVariant v = MyObject::callArgs.at(0); + QDBusVariant dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), arg.variant().toString()); + + // verify that we got the reply as expected + QCOMPARE(retArg.variant(), arg.variant()); +} + +void tst_QDBusInterface::invokeMethodWithMultiReturn() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), + TEST_INTERFACE_NAME); + + // make the call without a return type + MyObject::callCount = 0; + QDBusVariant arg("foo"), arg2("bar"); + QDBusVariant retArg, retArg2; + QVERIFY(QMetaObject::invokeMethod(&iface, "ping", + Q_RETURN_ARG(QDBusVariant, retArg), + Q_ARG(QDBusVariant, arg), + Q_ARG(QDBusVariant, arg2), + Q_ARG(QDBusVariant&, retArg2))); + QCOMPARE(MyObject::callCount, 1); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 2); + QVariant v = MyObject::callArgs.at(0); + QDBusVariant dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), arg.variant().toString()); + + v = MyObject::callArgs.at(1); + dv = qdbus_cast<QDBusVariant>(v); + QCOMPARE(dv.variant().type(), QVariant::String); + QCOMPARE(dv.variant().toString(), arg2.variant().toString()); + + // verify that we got the replies as expected + QCOMPARE(retArg.variant(), arg.variant()); + QCOMPARE(retArg2.variant(), arg2.variant()); +} + +void tst_QDBusInterface::invokeMethodWithComplexReturn() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), + TEST_INTERFACE_NAME); + + // make the call without a return type + MyObject::callCount = 0; + QList<int> arg = QList<int>() << 42 << -47; + QList<int> retArg; + QVERIFY(QMetaObject::invokeMethod(&iface, "ping", Q_RETURN_ARG(QList<int>, retArg), Q_ARG(QList<int>, arg))); + QCOMPARE(MyObject::callCount, 1); + + // verify what the callee received + QCOMPARE(MyObject::callArgs.count(), 1); + QVariant v = MyObject::callArgs.at(0); + QCOMPARE(v.userType(), qMetaTypeId<QDBusArgument>()); + QCOMPARE(qdbus_cast<QList<int> >(v), arg); + + // verify that we got the reply as expected + QCOMPARE(retArg, arg); +} + void tst_QDBusInterface::signal() { QDBusConnection con = QDBusConnection::sessionBus(); @@ -322,6 +448,68 @@ void tst_QDBusInterface::signal() } } +void tst_QDBusInterface::propertyRead() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), + TEST_INTERFACE_NAME); + + int arg = obj.m_prop1 = 42; + MyObject::callCount = 0; + + QVariant v = iface.property("prop1"); + QVERIFY(v.isValid()); + QCOMPARE(v.userType(), int(QVariant::Int)); + QCOMPARE(v.toInt(), arg); + QCOMPARE(MyObject::callCount, 1); +} + +void tst_QDBusInterface::propertyWrite() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), + TEST_INTERFACE_NAME); + + int arg = 42; + obj.m_prop1 = 0; + MyObject::callCount = 0; + + QVERIFY(iface.setProperty("prop1", arg)); + QCOMPARE(MyObject::callCount, 1); + QCOMPARE(obj.m_prop1, arg); +} + +void tst_QDBusInterface::complexPropertyRead() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), + TEST_INTERFACE_NAME); + + QList<int> arg = obj.m_complexProp = QList<int>() << 42 << -47; + MyObject::callCount = 0; + + QVariant v = iface.property("complexProp"); + QVERIFY(v.isValid()); + QCOMPARE(v.userType(), qMetaTypeId<QList<int> >()); + QCOMPARE(v.value<QList<int> >(), arg); + QCOMPARE(MyObject::callCount, 1); +} + +void tst_QDBusInterface::complexPropertyWrite() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), + TEST_INTERFACE_NAME); + + QList<int> arg = QList<int>() << -47 << 42; + obj.m_complexProp.clear(); + MyObject::callCount = 0; + + QVERIFY(iface.setProperty("complexProp", qVariantFromValue(arg))); + QCOMPARE(MyObject::callCount, 1); + QCOMPARE(obj.m_complexProp, arg); +} + QTEST_MAIN(tst_QDBusInterface) #include "tst_qdbusinterface.moc" diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp index e5b2ebb..e304712 100644 --- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp @@ -84,12 +84,17 @@ private slots: void sendArgument_data(); void sendArgument(); - void sendErrors(); + void sendSignalErrors(); + void sendCallErrors_data(); + void sendCallErrors(); private: QProcess proc; }; +struct UnregisteredType { }; +Q_DECLARE_METATYPE(UnregisteredType) + class WaitForQPong: public QObject { Q_OBJECT @@ -784,7 +789,7 @@ void tst_QDBusMarshall::sendArgument() QCOMPARE(extracted, value); } -void tst_QDBusMarshall::sendErrors() +void tst_QDBusMarshall::sendSignalErrors() { QDBusConnection con = QDBusConnection::sessionBus(); @@ -793,7 +798,7 @@ void tst_QDBusMarshall::sendErrors() "signalName"); msg << qVariantFromValue(QDBusObjectPath()); - QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\""); + QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments"); QVERIFY(!con.send(msg)); msg.setArguments(QVariantList()); @@ -803,9 +808,117 @@ void tst_QDBusMarshall::sendErrors() path.setPath("abc"); msg << qVariantFromValue(path); - QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\""); + QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments"); + QVERIFY(!con.send(msg)); + + QDBusSignature sig; + msg.setArguments(QVariantList() << qVariantFromValue(sig)); + QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments"); + QVERIFY(!con.send(msg)); + + QTest::ignoreMessage(QtWarningMsg, "QDBusSignature: invalid signature \"a\""); + sig.setSignature("a"); + msg.setArguments(QVariantList()); + msg << qVariantFromValue(sig); + QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments"); QVERIFY(!con.send(msg)); } +void tst_QDBusMarshall::sendCallErrors_data() +{ + QTest::addColumn<QString>("service"); + QTest::addColumn<QString>("path"); + QTest::addColumn<QString>("interface"); + QTest::addColumn<QString>("method"); + QTest::addColumn<QVariantList>("arguments"); + QTest::addColumn<QString>("errorName"); + QTest::addColumn<QString>("errorMsg"); + QTest::addColumn<QString>("ignoreMsg"); + + // this error comes from the bus server + QTest::newRow("empty-service") << "" << objectPath << interfaceName << "ping" << QVariantList() + << "org.freedesktop.DBus.Error.UnknownMethod" + << "Method \"ping\" with signature \"\" on interface \"com.trolltech.autotests.qpong\" doesn't exist\n" << (const char*)0; + + QTest::newRow("invalid-service") << "this isn't valid" << objectPath << interfaceName << "ping" << QVariantList() + << "com.trolltech.QtDBus.Error.InvalidService" + << "Invalid service name: this isn't valid" << ""; + + QTest::newRow("empty-path") << serviceName << "" << interfaceName << "ping" << QVariantList() + << "com.trolltech.QtDBus.Error.InvalidObjectPath" + << "Object path cannot be empty" << ""; + QTest::newRow("invalid-path") << serviceName << "//" << interfaceName << "ping" << QVariantList() + << "com.trolltech.QtDBus.Error.InvalidObjectPath" + << "Invalid object path: //" << ""; + + // empty interfaces are valid + QTest::newRow("invalid-interface") << serviceName << objectPath << "this isn't valid" << "ping" << QVariantList() + << "com.trolltech.QtDBus.Error.InvalidInterface" + << "Invalid interface class: this isn't valid" << ""; + + QTest::newRow("empty-method") << serviceName << objectPath << interfaceName << "" << QVariantList() + << "com.trolltech.QtDBus.Error.InvalidMember" + << "method name cannot be empty" << ""; + QTest::newRow("invalid-method") << serviceName << objectPath << interfaceName << "this isn't valid" << QVariantList() + << "com.trolltech.QtDBus.Error.InvalidMember" + << "Invalid method name: this isn't valid" << ""; + + QTest::newRow("invalid-variant1") << serviceName << objectPath << interfaceName << "ping" + << (QVariantList() << QVariant()) + << "org.freedesktop.DBus.Error.Failed" + << "Marshalling failed: Variant containing QVariant::Invalid passed in arguments" + << "QDBusMarshaller: cannot add an invalid QVariant"; + QTest::newRow("invalid-variant1") << serviceName << objectPath << interfaceName << "ping" + << (QVariantList() << qVariantFromValue(QDBusVariant())) + << "org.freedesktop.DBus.Error.Failed" + << "Marshalling failed: Variant containing QVariant::Invalid passed in arguments" + << "QDBusMarshaller: cannot add a null QDBusVariant"; + + QTest::newRow("builtin-unregistered") << serviceName << objectPath << interfaceName << "ping" + << (QVariantList() << QLocale::c()) + << "org.freedesktop.DBus.Error.Failed" + << "Marshalling failed: Unregistered type QLocale passed in arguments" + << "QDBusMarshaller: type `QLocale' (18) is not registered with D-BUS. Use qDBusRegisterMetaType to register it"; + + // this type is known to the meta type system, but not registered with D-Bus + qRegisterMetaType<UnregisteredType>(); + QTest::newRow("extra-unregistered") << serviceName << objectPath << interfaceName << "ping" + << (QVariantList() << qVariantFromValue(UnregisteredType())) + << "org.freedesktop.DBus.Error.Failed" + << "Marshalling failed: Unregistered type UnregisteredType passed in arguments" + << QString("QDBusMarshaller: type `UnregisteredType' (%1) is not registered with D-BUS. Use qDBusRegisterMetaType to register it") + .arg(qMetaTypeId<UnregisteredType>()); +} + +void tst_QDBusMarshall::sendCallErrors() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + + QFETCH(QString, service); + QFETCH(QString, path); + QFETCH(QString, interface); + QFETCH(QString, method); + QFETCH(QVariantList, arguments); + QFETCH(QString, errorMsg); + + QFETCH(QString, ignoreMsg); + if (!ignoreMsg.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, ignoreMsg.toLatin1()); + if (!ignoreMsg.isNull()) + QTest::ignoreMessage(QtWarningMsg, + QString("QDBusConnection: error: could not send message to service \"%1\" path \"%2\" interface \"%3\" member \"%4\": %5") + .arg(service, path, interface, method, errorMsg) + .toLatin1()); + + QDBusMessage msg = QDBusMessage::createMethodCall(service, path, interface, method); + msg.setArguments(arguments); + + QDBusMessage reply = con.call(msg, QDBus::Block); + QCOMPARE(reply.type(), QDBusMessage::ErrorMessage); + QTEST(reply.errorName(), "errorName"); + QCOMPARE(reply.errorMessage(), errorMsg); +} + QTEST_MAIN(tst_QDBusMarshall) #include "tst_qdbusmarshall.moc" diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index e4fec1d..50cab0e 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -160,6 +160,7 @@ private slots: void task251321_sideBarHiddenEntries(); void task251341_sideBarRemoveEntries(); void task254490_selectFileMultipleTimes(); + void task257579_sideBarWithNonCleanUrls(); private: QByteArray userSettings; @@ -231,6 +232,7 @@ void tst_QFiledialog::currentChangedSignal() // only emited from the views, sidebar, or lookin combo void tst_QFiledialog::directoryEnteredSignal() { +#if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd(0, "", QDir::root().path()); fd.setOptions(QFileDialog::DontUseNativeDialog); fd.show(); @@ -274,6 +276,7 @@ void tst_QFiledialog::directoryEnteredSignal() QTest::mouseDClick(listView->viewport(), Qt::LeftButton, 0, listView->visualRect(folder).center()); QTRY_COMPARE(spyDirectoryEntered.count(), 1); */ +#endif } Q_DECLARE_METATYPE(QFileDialog::FileMode) @@ -1314,16 +1317,14 @@ void tst_QFiledialog::hooks() void tst_QFiledialog::listRoot() { +#if defined QT_BUILD_INTERNAL QFileInfoGatherer::fetchedRoot = false; QString dir(QDir::currentPath()); QNonNativeFileDialog fd(0, QString(), dir); fd.show(); -#if defined Q_AUTOTEST_EXPORT QCOMPARE(QFileInfoGatherer::fetchedRoot,false); -#endif fd.setDirectory(""); QTest::qWait(500); -#if defined Q_AUTOTEST_EXPORT QCOMPARE(QFileInfoGatherer::fetchedRoot,true); #endif } @@ -1347,6 +1348,7 @@ struct FriendlyQFileDialog : public QFileDialog void tst_QFiledialog::deleteDirAndFiles() { +#if defined QT_BUILD_INTERNAL QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4FullDelete"; QDir dir; QVERIFY(dir.mkpath(tempPath + "/foo")); @@ -1373,6 +1375,7 @@ void tst_QFiledialog::deleteDirAndFiles() QFileInfo info(tempPath); QTest::qWait(2000); QVERIFY(!info.exists()); +#endif } void tst_QFiledialog::filter() @@ -1583,6 +1586,7 @@ QString &dir, const QString &filter) void tst_QFiledialog::task227304_proxyOnFileDialog() { +#if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0); fd.setProxyModel(new FilterDirModel(QDir::currentPath())); fd.show(); @@ -1616,6 +1620,7 @@ void tst_QFiledialog::task227304_proxyOnFileDialog() QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center()); QTest::qWait(250); //We shouldn't crash +#endif } void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior() @@ -1727,6 +1732,7 @@ void tst_QFiledialog::task235069_hideOnEscape() void tst_QFiledialog::task236402_dontWatchDeletedDir() { +#if defined QT_BUILD_INTERNAL //THIS TEST SHOULD NOT DISPLAY WARNINGS QDir current = QDir::currentPath(); //make sure it is the first on the list @@ -1746,6 +1752,7 @@ void tst_QFiledialog::task236402_dontWatchDeletedDir() QTest::qWait(200); fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/"); QTest::qWait(1000); +#endif } void tst_QFiledialog::task203703_returnProperSeparator() @@ -1870,6 +1877,7 @@ void tst_QFiledialog::task218353_relativePaths() void tst_QFiledialog::task251321_sideBarHiddenEntries() { +#if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd; QDir current = QDir::currentPath(); @@ -1899,8 +1907,10 @@ void tst_QFiledialog::task251321_sideBarHiddenEntries() hiddenSubDir.rmdir("happy"); hiddenDir.rmdir("subdir"); current.rmdir(".hidden"); +#endif } +#if defined QT_BUILD_INTERNAL class MyQSideBar : public QSidebar { public : @@ -1918,9 +1928,11 @@ public : model()->removeRow(indexes.at(i).row()); } }; +#endif void tst_QFiledialog::task251341_sideBarRemoveEntries() { +#if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd; QDir current = QDir::currentPath(); @@ -1980,6 +1992,7 @@ void tst_QFiledialog::task251341_sideBarRemoveEntries() QCOMPARE(mySideBar.urls(), expected); current.rmdir("testDir"); +#endif } void tst_QFiledialog::task254490_selectFileMultipleTimes() @@ -2014,5 +2027,25 @@ void tst_QFiledialog::task254490_selectFileMultipleTimes() t->deleteLater(); } +void tst_QFiledialog::task257579_sideBarWithNonCleanUrls() +{ + QDir tempDir = QDir::temp(); + QLatin1String dirname("autotest_task257579"); + tempDir.rmdir(dirname); //makes sure it doesn't exist any more + QVERIFY(tempDir.mkdir(dirname)); + QString url = QString::fromLatin1("%1/%2/..").arg(tempDir.absolutePath()).arg(dirname); + QNonNativeFileDialog fd; + fd.setSidebarUrls(QList<QUrl>() << QUrl::fromLocalFile(url)); + QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar"); + QCOMPARE(sidebar->urls().count(), 1); + QVERIFY(sidebar->urls().first().toLocalFile() != url); + QCOMPARE(sidebar->urls().first().toLocalFile(), QDir::cleanPath(url)); + QCOMPARE(sidebar->model()->index(0,0).data().toString(), tempDir.dirName()); + + //all tests are finished, we can remove the temporary dir + QVERIFY(tempDir.rmdir(dirname)); +} + + QTEST_MAIN(tst_QFiledialog) #include "tst_qfiledialog.moc" diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index e415b02..d49083f 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -254,6 +254,7 @@ void tst_QFileSystemModel::naturalCompare_data() void tst_QFileSystemModel::naturalCompare() { +#ifdef QT_BUILD_INTERNAL QFETCH(QString, s1); QFETCH(QString, s2); QFETCH(int, caseSensitive); @@ -271,6 +272,7 @@ void tst_QFileSystemModel::naturalCompare() // created. The scheduler takes its time to recognize ended threads. QTest::qWait(300); #endif +#endif } void tst_QFileSystemModel::readOnly() diff --git a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp index 62bfdf7..e2515ae 100644 --- a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp +++ b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp @@ -122,7 +122,10 @@ void tst_QFontComboBox::currentFont_data() { QTest::addColumn<QFont>("currentFont"); // Normalize the names - QTest::newRow("default") << QFont(QFontInfo(QFont()).family()); + QFont defaultFont; + QTest::newRow("default") << defaultFont; + defaultFont.setPointSize(defaultFont.pointSize() + 10); + QTest::newRow("default") << defaultFont; QFontDatabase db; QStringList list = db.families(); for (int i = 0; i < list.count(); ++i) { @@ -141,6 +144,7 @@ void tst_QFontComboBox::currentFont() QFont oldCurrentFont = box.currentFont(); box.setCurrentFont(currentFont); + QCOMPARE(box.currentFont(), currentFont); QString boxFontFamily = QFontInfo(box.currentFont()).family(); QRegExp foundry(" \\[.*\\]"); if (!currentFont.family().contains(foundry)) diff --git a/tests/auto/qfontdialog/tst_qfontdialog.cpp b/tests/auto/qfontdialog/tst_qfontdialog.cpp index 1444ee0..cbdd440 100644 --- a/tests/auto/qfontdialog/tst_qfontdialog.cpp +++ b/tests/auto/qfontdialog/tst_qfontdialog.cpp @@ -156,7 +156,7 @@ void tst_QFontDialog::setFont() class FriendlyFontDialog : public QFontDialog { - friend tst_QFontDialog; + friend class tst_QFontDialog; Q_DECLARE_PRIVATE(QFontDialog); }; @@ -170,8 +170,12 @@ void tst_QFontDialog::task256466_wrongStyle() for (int i = 0; i < familyList->model()->rowCount(); ++i) { QModelIndex currentFamily = familyList->model()->index(i, 0); familyList->setCurrentIndex(currentFamily); - QCOMPARE(dialog.currentFont(), fdb.font(currentFamily.data().toString(), - styleList->currentIndex().data().toString(), sizeList->currentIndex().data().toInt())); + const QFont current = dialog.currentFont(), + expected = fdb.font(currentFamily.data().toString(), + styleList->currentIndex().data().toString(), sizeList->currentIndex().data().toInt()); + QCOMPARE(current.family(), expected.family()); + QCOMPARE(current.style(), expected.style()); + QCOMPARE(current.pointSizeF(), expected.pointSizeF()); } } diff --git a/tests/auto/qgl/qgl.pro b/tests/auto/qgl/qgl.pro index 55e329d..420c4bb 100644 --- a/tests/auto/qgl/qgl.pro +++ b/tests/auto/qgl/qgl.pro @@ -3,7 +3,8 @@ ############################################################ load(qttest_p4) -contains(QT_CONFIG, opengl):QT += opengl +requires(contains(QT_CONFIG,opengl)) +QT += opengl SOURCES += tst_qgl.cpp diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 078c559..96f5ddd 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -44,9 +44,7 @@ #include <qcoreapplication.h> #include <qdebug.h> -#ifndef QT_NO_OPENGL #include <qgl.h> -#endif #include <QGraphicsView> #include <QGraphicsProxyWidget> @@ -78,7 +76,6 @@ tst_QGL::~tst_QGL() { } -#ifndef QT_NO_OPENGL class MyGLContext : public QGLContext { public: @@ -96,13 +93,10 @@ public: bool autoBufferSwap() const { return QGLWidget::autoBufferSwap(); } void setAutoBufferSwap(bool on) { QGLWidget::setAutoBufferSwap(on); } }; -#endif + // Testing get/set functions void tst_QGL::getSetCheck() { -#ifdef QT_NO_OPENGL - QSKIP("QGL not yet supported", SkipAll); -#else if (!QGLFormat::hasOpenGL()) QSKIP("QGL not supported on this platform", SkipAll); @@ -246,10 +240,9 @@ void tst_QGL::getSetCheck() QCOMPARE(false, obj3.autoBufferSwap()); obj3.setAutoBufferSwap(true); QCOMPARE(true, obj3.autoBufferSwap()); -#endif } -#ifndef QT_NO_OPENGL +#ifdef QT_BUILD_INTERNAL QT_BEGIN_NAMESPACE extern QGLFormat::OpenGLVersionFlags qOpenGLVersionFlagsFromString(const QString &versionString); QT_END_NAMESPACE @@ -257,9 +250,7 @@ QT_END_NAMESPACE void tst_QGL::openGLVersionCheck() { -#ifdef QT_NO_OPENGL - QSKIP("QGL not yet supported", SkipAll); -#else +#ifdef QT_BUILD_INTERNAL if (!QGLFormat::hasOpenGL()) QSKIP("QGL not supported on this platform", SkipAll); @@ -366,9 +357,6 @@ public: void tst_QGL::graphicsViewClipping() { -#ifdef QT_NO_OPENGL - QSKIP("QGL not supported", SkipAll); -#else const int size = 64; UnclippedWidget *widget = new UnclippedWidget; widget->setFixedSize(size, size); @@ -403,7 +391,6 @@ void tst_QGL::graphicsViewClipping() p.end(); QCOMPARE(image, expected); -#endif } void tst_QGL::partialGLWidgetUpdates_data() @@ -420,9 +407,6 @@ void tst_QGL::partialGLWidgetUpdates_data() void tst_QGL::partialGLWidgetUpdates() { -#ifdef QT_NO_OPENGL - QSKIP("QGL not yet supported", SkipAll); -#else if (!QGLFormat::hasOpenGL()) QSKIP("QGL not supported on this platform", SkipAll); @@ -466,7 +450,6 @@ void tst_QGL::partialGLWidgetUpdates() QCOMPARE(widget.paintEventRegion, QRegion(50, 50, 50, 50)); else QCOMPARE(widget.paintEventRegion, QRegion(widget.rect())); -#endif } QTEST_MAIN(tst_QGL) diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 3b13bcc..1d0663a 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -179,6 +179,7 @@ private slots: void windowFlags(); void comboboxWindowFlags(); void updateAndDelete(); + void inputMethod(); }; // Subclass that exposes the protected functions. @@ -1573,7 +1574,7 @@ void tst_QGraphicsProxyWidget::resize_simple() QGraphicsProxyWidget proxy; QWidget *widget = new QWidget; - widget->setGeometry(0, 0, size.width(), size.height()); + widget->setGeometry(0, 0, (int)size.width(), (int)size.height()); proxy.setWidget(widget); widget->show(); QCOMPARE(widget->pos(), QPoint()); @@ -3256,10 +3257,51 @@ void tst_QGraphicsProxyWidget::updateAndDelete() QCOMPARE(view.paintEventRegion, expectedRegion); } +class InputMethod_LineEdit : public QLineEdit +{ + bool event(QEvent *e) + { + if (e->type() == QEvent::InputMethod) + ++inputMethodEvents; + return QLineEdit::event(e); + } +public: + int inputMethodEvents; +}; + +void tst_QGraphicsProxyWidget::inputMethod() +{ + QGraphicsScene scene; + + // check that the proxy is initialized with the correct input method sensitivity + for (int i = 0; i < 2; ++i) + { + QLineEdit *lineEdit = new QLineEdit; + lineEdit->setAttribute(Qt::WA_InputMethodEnabled, !!i); + QGraphicsProxyWidget *proxy = scene.addWidget(lineEdit); + QCOMPARE(!!(proxy->flags() & QGraphicsItem::ItemAcceptsInputMethod), !!i); + } + + // check that input method events are only forwarded to widgets with focus + for (int i = 0; i < 2; ++i) + { + InputMethod_LineEdit *lineEdit = new InputMethod_LineEdit; + lineEdit->setAttribute(Qt::WA_InputMethodEnabled, true); + QGraphicsProxyWidget *proxy = scene.addWidget(lineEdit); + + if (i) + lineEdit->setFocus(); + + lineEdit->inputMethodEvents = 0; + QInputMethodEvent event; + qApp->sendEvent(proxy, &event); + QCOMPARE(lineEdit->inputMethodEvents, i); + } +} + QTEST_MAIN(tst_QGraphicsProxyWidget) #include "tst_qgraphicsproxywidget.moc" #else // QT_NO_STYLE_CLEANLOOKS QTEST_NOOP_MAIN #endif - diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 24acd63..e9d6f1d 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -252,6 +252,8 @@ private slots: void stickyFocus_data(); void stickyFocus(); void sendEvent(); + void inputMethod_data(); + void inputMethod(); // task specific tests below me void task139710_bspTreeCrash(); @@ -3634,5 +3636,61 @@ void tst_QGraphicsScene::sendEvent() QCOMPARE(spy->count(), 1); } +void tst_QGraphicsScene::inputMethod_data() +{ + QTest::addColumn<int>("flags"); + QTest::addColumn<bool>("callFocusItem"); + QTest::newRow("0") << 0 << false; + QTest::newRow("1") << (int)QGraphicsItem::ItemAcceptsInputMethod << false; + QTest::newRow("2") << (int)QGraphicsItem::ItemIsFocusable << false; + QTest::newRow("3") << + (int)(QGraphicsItem::ItemAcceptsInputMethod|QGraphicsItem::ItemIsFocusable) << true; +} + +class InputMethodTester : public QGraphicsRectItem +{ + void inputMethodEvent(QInputMethodEvent *) { ++eventCalls; } + QVariant inputMethodQuery(Qt::InputMethodQuery) const { ++queryCalls; return QVariant(); } +public: + int eventCalls; + mutable int queryCalls; +}; + +void tst_QGraphicsScene::inputMethod() +{ + QFETCH(int, flags); + QFETCH(bool, callFocusItem); + + InputMethodTester *item = new InputMethodTester; + item->setFlags((QGraphicsItem::GraphicsItemFlags)flags); + + QGraphicsScene scene; + scene.addItem(item); + QInputMethodEvent event; + + scene.setFocusItem(item); + QCOMPARE(!!(item->flags() & QGraphicsItem::ItemIsFocusable), scene.focusItem() == item); + + item->eventCalls = 0; + qApp->sendEvent(&scene, &event); + QCOMPARE(item->eventCalls, callFocusItem ? 1 : 0); + + item->queryCalls = 0; + scene.inputMethodQuery((Qt::InputMethodQuery)0); + QCOMPARE(item->queryCalls, callFocusItem ? 1 : 0); + + scene.setFocusItem(0); + QCOMPARE(item->eventCalls, callFocusItem ? 2 : 0); // verify correct delivery of "reset" event + QCOMPARE(item->queryCalls, callFocusItem ? 1 : 0); // verify that value is unaffected + + item->eventCalls = 0; + qApp->sendEvent(&scene, &event); + QCOMPARE(item->eventCalls, 0); + + item->queryCalls = 0; + scene.inputMethodQuery((Qt::InputMethodQuery)0); + QCOMPARE(item->queryCalls, 0); +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 297c437..77ab977 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -63,6 +63,7 @@ #include <QtGui/QBoxLayout> #include <QtGui/QStyle> #include <QtGui/QPushButton> +#include <QtGui/QInputContext> #include <private/qgraphicsview_p.h> //TESTED_CLASS= @@ -199,6 +200,8 @@ private slots: void exposeRegion(); void update_data(); void update(); + void inputMethodSensitivity(); + void inputContextReset(); // task specific tests below me void task172231_untransformableItems(); @@ -3427,6 +3430,7 @@ void tst_QGraphicsView::update_data() QTest::newRow("large3") << QRect(-100, -100, 400, 400); QTest::newRow("viewport rect") << QRect(0, 0, 200, 200); } + void tst_QGraphicsView::update() { QFETCH(QRect, updateRect); @@ -3466,6 +3470,121 @@ void tst_QGraphicsView::update() QVERIFY(!viewPrivate->fullUpdatePending); } +void tst_QGraphicsView::inputMethodSensitivity() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + + QGraphicsRectItem *item = new QGraphicsRectItem; + + view.setAttribute(Qt::WA_InputMethodEnabled, true); + + scene.addItem(item); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + scene.removeItem(item); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + item->setFlag(QGraphicsItem::ItemAcceptsInputMethod); + scene.addItem(item); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + scene.removeItem(item); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + scene.addItem(item); + scene.setFocusItem(item); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + scene.removeItem(item); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + item->setFlag(QGraphicsItem::ItemIsFocusable); + scene.addItem(item); + scene.setFocusItem(item); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true); + + item->setFlag(QGraphicsItem::ItemAcceptsInputMethod, false); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + item->setFlag(QGraphicsItem::ItemAcceptsInputMethod, true); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true); + + // introduce another item that is focusable but does not accept input methods + QGraphicsRectItem *item2 = new QGraphicsRectItem; + item2->setFlag(QGraphicsItem::ItemIsFocusable); + scene.addItem(item2); + scene.setFocusItem(item2); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + scene.setFocusItem(item); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true); + + view.setScene(0); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + view.setScene(&scene); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true); + + scene.setFocusItem(item2); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + view.setScene(0); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + scene.setFocusItem(item); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + + view.setScene(&scene); + QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true); +} + +class InputContextTester : public QInputContext +{ + QString identifierName() { return QString(); } + bool isComposing() const { return false; } + QString language() { return QString(); } + void reset() { ++resets; } +public: + int resets; +}; + +void tst_QGraphicsView::inputContextReset() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + + InputContextTester inputContext; + view.setInputContext(&inputContext); + + QGraphicsItem *item1 = new QGraphicsRectItem; + item1->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod); + + inputContext.resets = 0; + scene.addItem(item1); + QCOMPARE(inputContext.resets, 0); + + inputContext.resets = 0; + scene.setFocusItem(item1); + QCOMPARE(inputContext.resets, 0); + + inputContext.resets = 0; + scene.setFocusItem(0); + QCOMPARE(inputContext.resets, 1); + + // introduce another item that is focusable but does not accept input methods + QGraphicsItem *item2 = new QGraphicsRectItem; + item1->setFlags(QGraphicsItem::ItemIsFocusable); + + inputContext.resets = 0; + scene.setFocusItem(item2); + QCOMPARE(inputContext.resets, 0); + + inputContext.resets = 0; + scene.setFocusItem(item1); + QCOMPARE(inputContext.resets, 0); +} + void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged() { QGraphicsView view; diff --git a/tests/auto/qhelpgenerator/data/test.qhp b/tests/auto/qhelpgenerator/data/test.qhp index e9ac7f2..a97c00d 100644 --- a/tests/auto/qhelpgenerator/data/test.qhp +++ b/tests/auto/qhelpgenerator/data/test.qhp @@ -38,9 +38,8 @@ </keywords> <files> <file>classic.css</file> - <file>test.html</file> - <file>people.html</file> - <file>./sub/about.html</file> + <file>[pt]*.html</file> + <file>./sub/abou?.html</file> </files> </filterSection> <filterSection> @@ -69,4 +68,4 @@ <file>cars.html</file> </files> </filterSection> -</QtHelpProject>
\ No newline at end of file +</QtHelpProject> diff --git a/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro index 3283873..e19d962 100644 --- a/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -2,4 +2,6 @@ load(qttest_p4) SOURCES += tst_qhttpnetworkconnection.cpp INCLUDEPATH += $$(QTDIR)/src/3rdparty/zlib +requires(contains(QT_CONFIG,private_tests)) + QT = core network diff --git a/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro b/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro index 2e41fcd..f86250a 100644 --- a/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro +++ b/tests/auto/qhttpnetworkreply/qhttpnetworkreply.pro @@ -2,4 +2,6 @@ load(qttest_p4) SOURCES += tst_qhttpnetworkreply.cpp INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/zlib +requires(contains(QT_CONFIG,private_tests)) + QT = core network diff --git a/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp b/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp index d9a7d56..e235ff5 100644 --- a/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp +++ b/tests/auto/qitemeditorfactory/tst_qitemeditorfactory.cpp @@ -59,13 +59,13 @@ void tst_QItemEditorFactory::createEditor() QCOMPARE(w->metaObject()->className(), "QExpandingLineEdit"); } -void tst_QItemEditorFactory::createCustomEditor() +//we make it inherit from QObject so that we can use QPointer +class MyEditor : public QObject, public QStandardItemEditorCreator<QDoubleSpinBox> { - //we make it inherit from QObject so that we can use QPointer - class MyEditor : public QObject, public QStandardItemEditorCreator<QDoubleSpinBox> - { - }; +}; +void tst_QItemEditorFactory::createCustomEditor() +{ QPointer<MyEditor> creator = new MyEditor; QPointer<MyEditor> creator2 = new MyEditor; diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp index aeb57ef..2e4b850 100644 --- a/tests/auto/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp @@ -270,7 +270,7 @@ void tst_QKeySequence::checkMultipleNames() void tst_QKeySequence::ensureSorted() { //### accessing static members from private classes does not work on msvc at the moment -#ifndef Q_WS_WIN +#if defined(QT_BUILD_INTERNAL) && !defined(Q_WS_WIN) uint N = QKeySequencePrivate::numberOfKeyBindings; uint val = QKeySequencePrivate::keyBindings[0].shortcut; for ( uint i = 1 ; i < N ; ++i) { diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index 4f1eb1d..a41eecd 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -80,6 +80,8 @@ private slots: void sendData_data(); void sendData(); + void readBufferOverflow(); + void fullPath(); void hitMaximumConnections_data(); @@ -102,6 +104,7 @@ private slots: void recycleServer(); void multiConnect(); + void writeOnlySocket(); void debug(); @@ -531,6 +534,37 @@ void tst_QLocalSocket::sendData() QCOMPARE(spy.count(), (canListen ? 1 : 0)); } +void tst_QLocalSocket::readBufferOverflow() +{ + const int readBufferSize = 128; + const int dataBufferSize = readBufferSize * 2; + const QString serverName = QLatin1String("myPreciousTestServer"); + LocalServer server; + server.listen(serverName); + QVERIFY(server.isListening()); + + LocalSocket client; + client.setReadBufferSize(readBufferSize); + client.connectToServer(serverName); + + bool timedOut = true; + QVERIFY(server.waitForNewConnection(3000, &timedOut)); + QVERIFY(!timedOut); + + QCOMPARE(client.state(), QLocalSocket::ConnectedState); + QVERIFY(server.hasPendingConnections()); + + QLocalSocket* serverSocket = server.nextPendingConnection(); + char* buffer = (char*)qMalloc(dataBufferSize); + memset(buffer, 0, dataBufferSize); + serverSocket->write(buffer, dataBufferSize); + serverSocket->flush(); + qFree(buffer); + + QVERIFY(client.waitForReadyRead()); + QCOMPARE(client.readAll().size(), dataBufferSize); +} + // QLocalSocket/Server can take a name or path, check that it works as expected void tst_QLocalSocket::fullPath() { @@ -873,6 +907,22 @@ void tst_QLocalSocket::multiConnect() QVERIFY(server.nextPendingConnection() != 0); } +void tst_QLocalSocket::writeOnlySocket() +{ + QLocalServer server; + QVERIFY(server.listen("writeOnlySocket")); + + QLocalSocket client; + client.connectToServer("writeOnlySocket", QIODevice::WriteOnly); + QVERIFY(client.waitForConnected()); + + QVERIFY(server.waitForNewConnection()); + QLocalSocket* serverSocket = server.nextPendingConnection(); + + QCOMPARE(client.bytesAvailable(), qint64(0)); + QCOMPARE(client.state(), QLocalSocket::ConnectedState); +} + void tst_QLocalSocket::debug() { // Make sure this compiles diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp index e46c2e1..6ae7a3e 100644 --- a/tests/auto/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp @@ -1400,6 +1400,7 @@ void AddDockWidget::apply(QMainWindow *mw) const } } +#ifdef QT_BUILD_INTERNAL struct MoveSeparator { MoveSeparator() {} @@ -1436,6 +1437,7 @@ void MoveSeparator::apply(QMainWindow *mw) const l->layoutState.dockAreaLayout.separatorMove(path, QPoint(0, 0), QPoint(delta, delta)); } +#endif QMap<QString, QRect> dockWidgetGeometries(QMainWindow *mw) { @@ -1463,6 +1465,7 @@ QMap<QString, QRect> dockWidgetGeometries(QMainWindow *mw) void tst_QMainWindow::saveRestore_data() { +#ifdef QT_BUILD_INTERNAL QTest::addColumn<AddList >("addList"); QTest::addColumn<MoveList >("moveList"); @@ -1497,10 +1500,12 @@ void tst_QMainWindow::saveRestore_data() << MoveSeparator(-30, "right1") << MoveSeparator(30, "right2a") ); +#endif } void tst_QMainWindow::saveRestore() { +#ifdef QT_BUILD_INTERNAL QFETCH(AddList, addList); QFETCH(MoveList, moveList); @@ -1570,6 +1575,7 @@ void tst_QMainWindow::saveRestore() mainWindow.show(); COMPARE_DOCK_WIDGET_GEOS(dockWidgetGeos, dockWidgetGeometries(&mainWindow)); } +#endif } void tst_QMainWindow::iconSizeChanged() diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp index 500465c..1245de1 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -1576,8 +1576,9 @@ void tst_QMenuBar::menubarSizeHint() return 11; case PM_MenuBarPanelWidth: return 1; + default: + return QWindowsStyle::pixelMetric(metric, option, widget); } - return QWindowsStyle::pixelMetric(metric, option, widget); } } style; diff --git a/tests/auto/qnativesocketengine/qnativesocketengine.pro b/tests/auto/qnativesocketengine/qnativesocketengine.pro index 320f24c..ad40d53 100644 --- a/tests/auto/qnativesocketengine/qnativesocketengine.pro +++ b/tests/auto/qnativesocketengine/qnativesocketengine.pro @@ -3,6 +3,8 @@ SOURCES += tst_qnativesocketengine.cpp include(../qnativesocketengine/qsocketengine.pri) +requires(contains(QT_CONFIG,private_tests)) + MOC_DIR=tmp QT = core network diff --git a/tests/auto/qnetworkreply/qnetworkreply.pro b/tests/auto/qnetworkreply/qnetworkreply.pro index 0bcf067..fd8454c 100644 --- a/tests/auto/qnetworkreply/qnetworkreply.pro +++ b/tests/auto/qnetworkreply/qnetworkreply.pro @@ -1,4 +1,6 @@ TEMPLATE = subdirs SUBDIRS = test +requires(contains(QT_CONFIG,private_tests)) + !wince*:SUBDIRS += echo diff --git a/tests/auto/qpathclipper/qpathclipper.pro b/tests/auto/qpathclipper/qpathclipper.pro index 675e463..dc9d60f 100644 --- a/tests/auto/qpathclipper/qpathclipper.pro +++ b/tests/auto/qpathclipper/qpathclipper.pro @@ -3,6 +3,8 @@ INCLUDEPATH += . HEADERS += paths.h SOURCES += tst_qpathclipper.cpp paths.cpp +requires(contains(QT_CONFIG,private_tests)) + unix:!mac:LIBS+=-lm diff --git a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp index fceefd2..40ad539 100644 --- a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp @@ -1106,6 +1106,7 @@ void tst_QPlainTextEdit::mimeDataReimplementations() QCOMPARE(ed.canInsertCallCount, 0); QCOMPARE(ed.insertCallCount, 0); +#ifdef QT_BUILD_INTERNAL QTextControl *control = qFindChild<QTextControl *>(&ed); QVERIFY(control); @@ -1120,6 +1121,7 @@ void tst_QPlainTextEdit::mimeDataReimplementations() QCOMPARE(ed.createMimeDataCallCount, 1); QCOMPARE(ed.canInsertCallCount, 1); QCOMPARE(ed.insertCallCount, 1); +#endif } void tst_QPlainTextEdit::shiftEnterShouldInsertLineSeparator() diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index a30e9f9..e76c8ef 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -111,6 +111,7 @@ private slots: void operationsInStates(); void oneKeyValue(); void updateOnSetKeyValues(); + void restart(); }; tst_QPropertyAnimation::tst_QPropertyAnimation() @@ -395,8 +396,13 @@ void tst_QPropertyAnimation::duration0() animation.setEndValue(43); QVERIFY(!animation.currentValue().isValid()); QCOMPARE(animation.currentValue().toInt(), 0); + animation.setStartValue(42); + QVERIFY(animation.currentValue().isValid()); + QCOMPARE(animation.currentValue().toInt(), 42); + QCOMPARE(o.property("ole").toInt(), 42); animation.setDuration(0); + QCOMPARE(animation.currentValue().toInt(), 43); //it is at the end animation.start(); QCOMPARE(animation.state(), QAnimationGroup::Stopped); QCOMPARE(animation.currentTime(), 0); @@ -559,6 +565,9 @@ void tst_QPropertyAnimation::startWithoutStartValue() QTest::qWait(200); QCOMPARE(anim.state(), QVariantAnimation::Stopped); + current = anim.currentValue().toInt(); + QCOMPARE(current, 100); + QCOMPARE(o.property("ole").toInt(), current); anim.setEndValue(110); anim.start(); @@ -954,5 +963,53 @@ void tst_QPropertyAnimation::updateOnSetKeyValues() QCOMPARE(animation2.currentValue().toInt(), animation.currentValue().toInt()); } + +//this class will 'throw' an error in the test lib +// if the property ole is set to ErrorValue +class MyErrorObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int ole READ ole WRITE setOle) +public: + + static const int ErrorValue = 10000; + + MyErrorObject() : m_ole(0) { } + int ole() const { return m_ole; } + void setOle(int o) + { + QVERIFY(o != ErrorValue); + m_ole = o; + } + +private: + int m_ole; + + +}; + +void tst_QPropertyAnimation::restart() +{ + //here we check that be restarting an animation + //it doesn't get an bogus intermediate value (end value) + //because the time is not yet reset to 0 + MyErrorObject o; + o.setOle(100); + QCOMPARE(o.property("ole").toInt(), 100); + + QPropertyAnimation anim(&o, "ole"); + anim.setEndValue(200); + anim.start(); + anim.setCurrentTime(anim.duration()); + QCOMPARE(anim.state(), QAbstractAnimation::Stopped); + QCOMPARE(o.property("ole").toInt(), 200); + + //we'll check that the animation never gets a wrong value when starting it + //after having changed the end value + anim.setEndValue(MyErrorObject::ErrorValue); + anim.start(); +} + + QTEST_MAIN(tst_QPropertyAnimation) #include "tst_qpropertyanimation.moc" diff --git a/tests/auto/qregion/tst_qregion.cpp b/tests/auto/qregion/tst_qregion.cpp index 3ffa87e..2ad202d 100644 --- a/tests/auto/qregion/tst_qregion.cpp +++ b/tests/auto/qregion/tst_qregion.cpp @@ -96,7 +96,7 @@ private slots: #ifdef Q_OS_WIN void handle(); #endif -#ifdef Q_WS_X11 +#if defined(Q_WS_X11) && defined(QT_BUILD_INTERNAL) void clipRectangles(); #endif @@ -865,7 +865,7 @@ void tst_QRegion::handle() } #endif -#ifdef Q_WS_X11 +#if defined(Q_WS_X11) && defined(QT_BUILD_INTERNAL) void tst_QRegion::clipRectangles() { QRegion region(30, 30, 30, 30); @@ -967,6 +967,7 @@ void tst_QRegion::regionToPath_data() void tst_QRegion::regionToPath() { +#ifdef QT_BUILD_INTERNAL extern QPainterPath qt_regionToPath(const QRegion ®ion); QFETCH(QPainterPath, path); @@ -1002,6 +1003,7 @@ void tst_QRegion::regionToPath() QCOMPARE(ia, ib); QCOMPARE(a.boundingRect(), b.boundingRect()); } +#endif } QTEST_MAIN(tst_QRegion) diff --git a/tests/auto/qscriptengine/script/com/__init__.js b/tests/auto/qscriptengine/script/com/__init__.js index 381816a..7db3ee4 100644 --- a/tests/auto/qscriptengine/script/com/__init__.js +++ b/tests/auto/qscriptengine/script/com/__init__.js @@ -3,3 +3,7 @@ __setupPackage__("com"); com.wasDefinedAlready = wasDefinedAlready; com.name = __extension__; com.level = 1; + +com.postInitCallCount = 0; +com.originalPostInit = __postInit__; +__postInit__ = function() { ++com.postInitCallCount; }; diff --git a/tests/auto/qscriptengine/script/com/trolltech/__init__.js b/tests/auto/qscriptengine/script/com/trolltech/__init__.js index f12b17d..a55b132 100644 --- a/tests/auto/qscriptengine/script/com/trolltech/__init__.js +++ b/tests/auto/qscriptengine/script/com/trolltech/__init__.js @@ -3,3 +3,7 @@ __setupPackage__("com.trolltech"); com.trolltech.wasDefinedAlready = wasDefinedAlready; com.trolltech.name = __extension__; com.trolltech.level = com.level + 1; + +com.trolltech.postInitCallCount = 0; +com.trolltech.originalPostInit = __postInit__; +__postInit__ = function() { ++com.trolltech.postInitCallCount; }; diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index c17454d..57c5167 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -1583,6 +1583,7 @@ void tst_QScriptEngine::importExtension() QScriptValue ret = eng.importExtension("this.extension.does.not.exist"); QCOMPARE(eng.hasUncaughtException(), true); QCOMPARE(ret.isError(), true); + QCOMPARE(ret.toString(), QString::fromLatin1("Error: Unable to import this.extension.does.not.exist: no such extension")); } { @@ -1601,6 +1602,8 @@ void tst_QScriptEngine::importExtension() .strictlyEquals(QScriptValue(&eng, "com")), true); QCOMPARE(com.property("level") .strictlyEquals(QScriptValue(&eng, 1)), true); + QVERIFY(com.property("originalPostInit").isUndefined()); + QVERIFY(com.property("postInitCallCount").strictlyEquals(1)); QScriptValue trolltech = com.property("trolltech"); QCOMPARE(trolltech.isObject(), true); @@ -1610,6 +1613,8 @@ void tst_QScriptEngine::importExtension() .strictlyEquals(QScriptValue(&eng, "com.trolltech")), true); QCOMPARE(trolltech.property("level") .strictlyEquals(QScriptValue(&eng, 2)), true); + QVERIFY(trolltech.property("originalPostInit").isUndefined()); + QVERIFY(trolltech.property("postInitCallCount").strictlyEquals(1)); } QStringList imp = eng.importedExtensions(); QCOMPARE(imp.size(), 2); @@ -1625,6 +1630,8 @@ void tst_QScriptEngine::importExtension() eng.globalObject().setProperty("__import__", eng.newFunction(__import__)); QScriptValue ret = eng.importExtension("com.trolltech.recursive"); QCOMPARE(eng.hasUncaughtException(), true); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QString::fromLatin1("Error: recursive import of com.trolltech.recursive")); QStringList imp = eng.importedExtensions(); QCOMPARE(imp.size(), 2); QCOMPARE(imp.at(0), QString::fromLatin1("com")); diff --git a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp index 14d3283..ee914ab 100644 --- a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp +++ b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp @@ -605,6 +605,12 @@ void tst_QScriptExtQObject::getSetStaticProperty() QVERIFY(!(mobj.propertyFlags("mySlot") & QScriptValue::Undeletable)); QVERIFY(!(mobj.propertyFlags("mySlot") & QScriptValue::SkipInEnumeration)); QVERIFY(mobj.propertyFlags("mySlot") & QScriptValue::QObjectMember); + + // signature-based property + QVERIFY(!(mobj.propertyFlags("mySlot()") & QScriptValue::ReadOnly)); + QVERIFY(!(mobj.propertyFlags("mySlot()") & QScriptValue::Undeletable)); + QVERIFY(!(mobj.propertyFlags("mySlot()") & QScriptValue::SkipInEnumeration)); + QVERIFY(mobj.propertyFlags("mySlot()") & QScriptValue::QObjectMember); } // property change in C++ should be reflected in script @@ -847,6 +853,9 @@ void tst_QScriptExtQObject::getSetStaticProperty() QVERIFY(slot.isFunction()); QScriptValue sameSlot = m_engine->evaluate("myObject.mySlot"); QVERIFY(sameSlot.strictlyEquals(slot)); + sameSlot = m_engine->evaluate("myObject['mySlot()']"); + QEXPECT_FAIL("", "Signature-based method lookup creates new function wrapper object", Continue); + QVERIFY(sameSlot.strictlyEquals(slot)); } } @@ -897,6 +906,20 @@ void tst_QScriptExtQObject::getSetChildren() QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('child')") .strictlyEquals(QScriptValue(m_engine, true)), true); + QScriptValue mobj = m_engine->evaluate("myObject"); + QVERIFY(mobj.propertyFlags("child") & QScriptValue::ReadOnly); + QVERIFY(mobj.propertyFlags("child") & QScriptValue::Undeletable); + QVERIFY(mobj.propertyFlags("child") & QScriptValue::SkipInEnumeration); + QVERIFY(!(mobj.propertyFlags("child") & QScriptValue::QObjectMember)); + + { + QScriptValue scriptChild = m_engine->evaluate("myObject.child"); + QVERIFY(scriptChild.isQObject()); + QCOMPARE(scriptChild.toQObject(), (QObject*)child); + QScriptValue sameChild = m_engine->evaluate("myObject.child"); + QVERIFY(sameChild.strictlyEquals(scriptChild)); + } + // add a grandchild MyQObject *grandChild = new MyQObject(child); grandChild->setObjectName("grandChild"); diff --git a/tests/auto/qsettings/tst_qsettings.cpp b/tests/auto/qsettings/tst_qsettings.cpp index f0f446d..77fef1f 100644 --- a/tests/auto/qsettings/tst_qsettings.cpp +++ b/tests/auto/qsettings/tst_qsettings.cpp @@ -713,6 +713,7 @@ void tst_QSettings::testErrorHandling_data() void tst_QSettings::testErrorHandling() { +#ifdef QT_BUILD_INTERNAL #ifdef Q_OS_WIN QSKIP("Windows doesn't support most file modes, including read-only directories, so this test is moot.", SkipAll); #else @@ -776,6 +777,7 @@ void tst_QSettings::testErrorHandling() QCOMPARE((int)settings.status(), statusAfterSetAndSync); } #endif // !Q_OS_WIN +#endif } Q_DECLARE_METATYPE(QVariant) @@ -821,6 +823,7 @@ void tst_QSettings::testIniParsing_data() void tst_QSettings::testIniParsing() { +#ifdef QT_BUILD_INTERNAL qRegisterMetaType<QVariant>("QVariant"); qRegisterMetaType<QSettings::Status>("QSettings::Status"); @@ -854,6 +857,7 @@ void tst_QSettings::testIniParsing() } QCOMPARE(settings.status(), status); +#endif } /* @@ -1058,6 +1062,7 @@ void tst_QSettings::testVariantTypes_data() void tst_QSettings::testVariantTypes() { +#ifdef QT_BUILD_INTERNAL #define testVal(key, val, tp, rtype) \ { \ QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP"); \ @@ -1141,6 +1146,7 @@ void tst_QSettings::testVariantTypes() } #undef testVal +#endif } void tst_QSettings::remove() @@ -1801,9 +1807,7 @@ void tst_QSettings::testNormalizedKey_data() void tst_QSettings::testNormalizedKey() { -#ifdef QTEST_REDUCED_EXPORTS - QSKIP("We can't test QSettingsPrivate on Windows", SkipAll); -#else +#ifdef QT_BUILD_INTERNAL QFETCH(QString, inKey); QFETCH(QString, outKey); @@ -1981,6 +1985,7 @@ void tst_QSettings::fromFile() void tst_QSettings::setIniCodec() { +#ifdef QT_BUILD_INTERNAL QByteArray expeContents4, expeContents5; QByteArray actualContents4, actualContents5; @@ -2040,6 +2045,7 @@ void tst_QSettings::setIniCodec() QCOMPARE(settings4.allKeys().first(), settings5.allKeys().first()); QCOMPARE(settings4.value(settings4.allKeys().first()).toString(), settings5.value(settings5.allKeys().first()).toString()); +#endif } static bool containsSubList(QStringList mom, QStringList son) @@ -2316,6 +2322,7 @@ void tst_QSettings::testArrays() settings1.endArray(); } +#ifdef QT_BUILD_INTERNAL static QByteArray iniEscapedKey(const QString &str) { QByteArray result; @@ -2360,6 +2367,7 @@ static QStringList iniUnescapedStringList(const QByteArray &ba) #endif return result; } +#endif QString escapeWeirdChars(const QString &s) { @@ -2383,6 +2391,7 @@ QString escapeWeirdChars(const QString &s) void tst_QSettings::testEscapes() { +#ifdef QT_BUILD_INTERNAL QSettings settings(QSettings::UserScope, "software.org", "KillerAPP"); #define testEscapedKey(plainKey, escKey) \ @@ -2505,6 +2514,7 @@ void tst_QSettings::testEscapes() testBadEscape("@Rect)", "@Rect)"); testBadEscape("@Rect(1 2 3)", "@Rect(1 2 3)"); testBadEscape("@@Rect(1 2 3)", "@Rect(1 2 3)"); +#endif } void tst_QSettings::testCompatFunctions() @@ -3355,6 +3365,7 @@ void tst_QSettings::childGroups_data() void tst_QSettings::childGroups() { +#ifdef QT_BUILD_INTERNAL QFETCH(QSettings::Format, format); { @@ -3408,6 +3419,7 @@ void tst_QSettings::childGroups() QCOMPARE(settings.childGroups(), QStringList() << "alpha" << "gamma" << "omicron" << "zeta"); } +#endif } void tst_QSettings::childKeys_data() @@ -3417,6 +3429,7 @@ void tst_QSettings::childKeys_data() void tst_QSettings::childKeys() { +#ifdef QT_BUILD_INTERNAL QFETCH(QSettings::Format, format); { @@ -3470,6 +3483,7 @@ void tst_QSettings::childKeys() QCOMPARE(settings.childKeys(), QStringList() << "alpha" << "beta" << "gamma"); } +#endif } void tst_QSettings::allKeys_data() @@ -3479,6 +3493,7 @@ void tst_QSettings::allKeys_data() void tst_QSettings::allKeys() { +#ifdef QT_BUILD_INTERNAL QFETCH(QSettings::Format, format); QStringList allKeys; @@ -3527,6 +3542,7 @@ void tst_QSettings::allKeys() QCOMPARE(settings.allKeys(), allKeys); } +#endif } void tst_QSettings::registerFormat() diff --git a/tests/auto/qsharedpointer/externaltests.cpp b/tests/auto/qsharedpointer/externaltests.cpp index 75ac5f1..8077b84 100644 --- a/tests/auto/qsharedpointer/externaltests.cpp +++ b/tests/auto/qsharedpointer/externaltests.cpp @@ -59,7 +59,7 @@ static QString makespec() { static const char default_makespec[] = DEFAULT_MAKESPEC; const char *p; - for (p = default_makespec + sizeof(default_makespec); p >= default_makespec; --p) + for (p = default_makespec + sizeof(default_makespec) - 1; p >= default_makespec; --p) if (*p == '/' || *p == '\\') break; @@ -122,6 +122,7 @@ namespace QTest { enum Target { Compile, Link, Run }; QList<QByteArray> qmakeLines; + QStringList extraProgramSources; QByteArray programHeader; QExternalTest::QtModules qtModules; QExternalTest::ApplicationType appType; @@ -199,6 +200,16 @@ namespace QTest { d->appType = type; } + QStringList QExternalTest::extraProgramSources() const + { + return d->extraProgramSources; + } + + void QExternalTest::setExtraProgramSources(const QStringList &extra) + { + d->extraProgramSources = extra; + } + QByteArray QExternalTest::programHeader() const { return d->programHeader; @@ -483,6 +494,13 @@ namespace QTest { else projectFile.write("\nCONFIG += release\n"); + QByteArray extraSources = QFile::encodeName(extraProgramSources.join(" ")); + if (!extraSources.isEmpty()) { + projectFile.write("SOURCES += "); + projectFile.write(extraSources); + projectFile.putChar('\n'); + } + // Add Qt modules if (qtModules & QExternalTest::QtCore) projectFile.write("QT += core\n"); diff --git a/tests/auto/qsharedpointer/externaltests.h b/tests/auto/qsharedpointer/externaltests.h index 24a3236..ecc107e 100644 --- a/tests/auto/qsharedpointer/externaltests.h +++ b/tests/auto/qsharedpointer/externaltests.h @@ -45,6 +45,7 @@ #include <QList> #include <QByteArray> +#include <QStringList> QT_BEGIN_NAMESPACE namespace QTest { @@ -102,6 +103,9 @@ namespace QTest { ApplicationType applicationType() const; void setApplicationType(ApplicationType type); + QStringList extraProgramSources() const; + void setExtraProgramSources(const QStringList &list); + QByteArray programHeader() const; void setProgramHeader(const QByteArray &header); diff --git a/tests/auto/qsharedpointer/externaltests.pri b/tests/auto/qsharedpointer/externaltests.pri index 717acac..1fdcf65 100644 --- a/tests/auto/qsharedpointer/externaltests.pri +++ b/tests/auto/qsharedpointer/externaltests.pri @@ -1,4 +1,5 @@ SOURCES += $$PWD/externaltests.cpp +HEADERS += $$PWD/externaltests.h cleanedQMAKESPEC = $$replace(QMAKESPEC, \\\\, /) DEFINES += DEFAULT_MAKESPEC=\\\"$$cleanedQMAKESPEC\\\" diff --git a/tests/auto/qsharedpointer/forwarddeclaration.cpp b/tests/auto/qsharedpointer/forwarddeclaration.cpp new file mode 100644 index 0000000..1dbbeec --- /dev/null +++ b/tests/auto/qsharedpointer/forwarddeclaration.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#define QT_SHAREDPOINTER_TRACK_POINTERS +#include "qsharedpointer.h" + +class ForwardDeclared; +ForwardDeclared *forwardPointer(); + +void externalForwardDeclaration() +{ + struct Wrapper { QSharedPointer<ForwardDeclared> pointer; }; +} + diff --git a/tests/auto/qsharedpointer/forwarddeclared.cpp b/tests/auto/qsharedpointer/forwarddeclared.cpp new file mode 100644 index 0000000..4ab467a --- /dev/null +++ b/tests/auto/qsharedpointer/forwarddeclared.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "forwarddeclared.h" + +ForwardDeclared *forwardPointer() +{ + return new ForwardDeclared; +} + +int forwardDeclaredDestructorRunCount; +ForwardDeclared::~ForwardDeclared() +{ + ++forwardDeclaredDestructorRunCount; +} diff --git a/tests/auto/qsharedpointer/forwarddeclared.h b/tests/auto/qsharedpointer/forwarddeclared.h new file mode 100644 index 0000000..a4cc2b4 --- /dev/null +++ b/tests/auto/qsharedpointer/forwarddeclared.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FORWARDDECLARED_H +#define FORWARDDECLARED_H + +extern int forwardDeclaredDestructorRunCount; +class ForwardDeclared +{ +public: + ~ForwardDeclared(); +}; + +ForwardDeclared *forwardPointer(); + +#endif // FORWARDDECLARED_H diff --git a/tests/auto/qsharedpointer/qsharedpointer.pro b/tests/auto/qsharedpointer/qsharedpointer.pro index e329803..90fde06 100644 --- a/tests/auto/qsharedpointer/qsharedpointer.pro +++ b/tests/auto/qsharedpointer/qsharedpointer.pro @@ -1,7 +1,9 @@ load(qttest_p4) - -SOURCES += tst_qsharedpointer.cpp +SOURCES += tst_qsharedpointer.cpp \ + forwarddeclaration.cpp \ + forwarddeclared.cpp QT = core -DEFINES += SRCDIR=\\\"$$PWD\\\" - +DEFINES += SRCDIR=\\\"$$PWD/\\\" +requires(contains(QT_CONFIG,private_tests)) include(externaltests.pri) +HEADERS += forwarddeclared.h diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index db93fc9..5cb435a 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -56,6 +56,7 @@ private slots: void memoryManagement(); void downCast(); void upCast(); + void objectCast(); void differentPointers(); void virtualBaseDifferentPointers(); #ifndef QTEST_NO_RTTI @@ -221,16 +222,37 @@ void tst_QSharedPointer::basics() } class ForwardDeclared; +ForwardDeclared *forwardPointer(); +void externalForwardDeclaration(); +extern int forwardDeclaredDestructorRunCount; + void tst_QSharedPointer::forwardDeclaration1() { - class Wrapper { QSharedPointer<ForwardDeclared> pointer; }; + externalForwardDeclaration(); + + struct Wrapper { QSharedPointer<ForwardDeclared> pointer; }; + + forwardDeclaredDestructorRunCount = 0; + { + Wrapper w; + w.pointer = QSharedPointer<ForwardDeclared>(forwardPointer()); + QVERIFY(!w.pointer.isNull()); + } + QCOMPARE(forwardDeclaredDestructorRunCount, 1); } -class ForwardDeclared { }; +#include "forwarddeclared.h" + void tst_QSharedPointer::forwardDeclaration2() { - class Wrapper { QSharedPointer<ForwardDeclared> pointer; }; - Wrapper w; + forwardDeclaredDestructorRunCount = 0; + { + struct Wrapper { QSharedPointer<ForwardDeclared> pointer; }; + Wrapper w1, w2; + w1.pointer = QSharedPointer<ForwardDeclared>(forwardPointer()); + QVERIFY(!w1.pointer.isNull()); + } + QCOMPARE(forwardDeclaredDestructorRunCount, 1); } void tst_QSharedPointer::memoryManagement() @@ -424,6 +446,109 @@ void tst_QSharedPointer::upCast() QCOMPARE(int(baseptr.d->strongref), 1); } +class OtherObject: public QObject +{ + Q_OBJECT +}; + +void tst_QSharedPointer::objectCast() +{ + { + OtherObject *data = new OtherObject; + QSharedPointer<QObject> baseptr = QSharedPointer<QObject>(data); + QVERIFY(baseptr == data); + QVERIFY(data == baseptr); + + // perform object cast + QSharedPointer<OtherObject> ptr = qSharedPointerObjectCast<OtherObject>(baseptr); + QVERIFY(!ptr.isNull()); + QCOMPARE(ptr.data(), data); + QVERIFY(ptr == data); + + // again: + ptr = baseptr.objectCast<OtherObject>(); + QVERIFY(ptr == data); + +#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION + // again: + ptr = qobject_cast<OtherObject *>(baseptr); + QVERIFY(ptr == data); + + // again: + ptr = qobject_cast<QSharedPointer<OtherObject> >(baseptr); + QVERIFY(ptr == data); +#endif + } + + { + const OtherObject *data = new OtherObject; + QSharedPointer<const QObject> baseptr = QSharedPointer<const QObject>(data); + QVERIFY(baseptr == data); + QVERIFY(data == baseptr); + + // perform object cast + QSharedPointer<const OtherObject> ptr = qSharedPointerObjectCast<const OtherObject>(baseptr); + QVERIFY(!ptr.isNull()); + QCOMPARE(ptr.data(), data); + QVERIFY(ptr == data); + + // again: + ptr = baseptr.objectCast<const OtherObject>(); + QVERIFY(ptr == data); + +#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION + // again: + ptr = qobject_cast<const OtherObject *>(baseptr); + QVERIFY(ptr == data); + + // again: + ptr = qobject_cast<QSharedPointer<const OtherObject> >(baseptr); + QVERIFY(ptr == data); +#endif + } + + { + OtherObject *data = new OtherObject; + QPointer<OtherObject> qptr = data; + QSharedPointer<OtherObject> ptr = QSharedPointer<OtherObject>(data); + QWeakPointer<QObject> weakptr = ptr; + + { + // perform object cast + QSharedPointer<OtherObject> otherptr = qSharedPointerObjectCast<OtherObject>(weakptr); + QVERIFY(otherptr == ptr); + + // again: + otherptr = qobject_cast<OtherObject *>(weakptr); + QVERIFY(otherptr == ptr); + + // again: + otherptr = qobject_cast<QSharedPointer<OtherObject> >(weakptr); + QVERIFY(otherptr == ptr); + } + + // drop the reference: + ptr.clear(); + QVERIFY(ptr.isNull()); + QVERIFY(qptr.isNull()); + QVERIFY(weakptr.toStrongRef().isNull()); + + // verify that the object casts fail without crash + QSharedPointer<OtherObject> otherptr = qSharedPointerObjectCast<OtherObject>(weakptr); + QVERIFY(otherptr.isNull()); + +#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION + // again: + otherptr = qobject_cast<OtherObject *>(weakptr); + QVERIFY(otherptr.isNull()); + + // again: + otherptr = qobject_cast<QSharedPointer<OtherObject> >(weakptr); + QVERIFY(otherptr.isNull()); +#endif + } +} + void tst_QSharedPointer::differentPointers() { { @@ -915,8 +1040,10 @@ void tst_QSharedPointer::invalidConstructs_data() // use of forward-declared class QTest::newRow("forward-declaration") - << &QTest::QExternalTest::tryCompileFail - << "QSharedPointer<ForwardDeclared> ptr;"; + << &QTest::QExternalTest::tryRun + << "forwardDeclaredDestructorRunCount = 0;\n" + "{ QSharedPointer<ForwardDeclared> ptr = QSharedPointer<ForwardDeclared>(forwardPointer()); }\n" + "exit(forwardDeclaredDestructorRunCount);"; // upcast without cast operator: QTest::newRow("upcast1") @@ -939,6 +1066,20 @@ void tst_QSharedPointer::invalidConstructs_data() << "QSharedPointer<const Data> baseptr = QSharedPointer<const Data>(new Data);\n" "QSharedPointer<Data> ptr;" "ptr = baseptr;"; + QTest::newRow("const-dropping-static-cast") + << &QTest::QExternalTest::tryCompileFail + << "QSharedPointer<const Data> baseptr = QSharedPointer<const Data>(new Data);\n" + "qSharedPointerCast<DerivedData>(baseptr);"; +#ifndef QTEST_NO_RTTI + QTest::newRow("const-dropping-dynamic-cast") + << &QTest::QExternalTest::tryCompileFail + << "QSharedPointer<const Data> baseptr = QSharedPointer<const Data>(new Data);\n" + "qSharedPointerDynamicCast<DerivedData>(baseptr);"; +#endif + QTest::newRow("const-dropping-object-cast") + << &QTest::QExternalTest::tryCompileFail + << "QSharedPointer<const QObject> baseptr = QSharedPointer<const QObject>(new QObject);\n" + "qSharedPointerObjectCast<QCoreApplication>(baseptr);"; // arithmethics through automatic cast operators QTest::newRow("arithmethic1") @@ -982,6 +1123,10 @@ void tst_QSharedPointer::invalidConstructs_data() << &QTest::QExternalTest::tryCompileFail << "QSharedPointer<Data> ptr1;\n" "QSharedPointer<int> ptr2 = qSharedPointerConstCast<int>(ptr1);"; + QTest::newRow("invalid-cast4") + << &QTest::QExternalTest::tryCompileFail + << "QSharedPointer<Data> ptr1;\n" + "QSharedPointer<int> ptr2 = qSharedPointerObjectCast<int>(ptr1);"; } void tst_QSharedPointer::invalidConstructs() @@ -996,13 +1141,19 @@ void tst_QSharedPointer::invalidConstructs() QTest::QExternalTest test; test.setDebugMode(true); test.setQtModules(QTest::QExternalTest::QtCore); + test.setExtraProgramSources(QStringList() << SRCDIR "forwarddeclared.cpp"); test.setProgramHeader( "#define QT_SHAREDPOINTER_TRACK_POINTERS\n" "#include <QtCore/qsharedpointer.h>\n" + "#include <QtCore/qcoreapplication.h>\n" "\n" "struct Data { int i; };\n" "struct DerivedData: public Data { int j; };\n" - "struct ForwardDeclared;"); + "\n" + "extern int forwardDeclaredDestructorRunCount;\n" + "struct ForwardDeclared;\n" + "ForwardDeclared *forwardPointer();\n" + ); QFETCH(QString, code); static bool sane = true; diff --git a/tests/auto/qsocketnotifier/qsocketnotifier.pro b/tests/auto/qsocketnotifier/qsocketnotifier.pro index 10ed3a5..ec924c1 100644 --- a/tests/auto/qsocketnotifier/qsocketnotifier.pro +++ b/tests/auto/qsocketnotifier/qsocketnotifier.pro @@ -2,6 +2,8 @@ load(qttest_p4) SOURCES += tst_qsocketnotifier.cpp QT = core network +requires(contains(QT_CONFIG,private_tests)) + include(../qnativesocketengine/qsocketengine.pri) diff --git a/tests/auto/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/qsocks5socketengine/qsocks5socketengine.pro index 2949ee2..d19b732 100644 --- a/tests/auto/qsocks5socketengine/qsocks5socketengine.pro +++ b/tests/auto/qsocks5socketengine/qsocks5socketengine.pro @@ -11,3 +11,4 @@ QT = core network +requires(contains(QT_CONFIG,private_tests)) diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h index c6b65a4..9c8c313 100644 --- a/tests/auto/qsqldatabase/tst_databases.h +++ b/tests/auto/qsqldatabase/tst_databases.h @@ -105,7 +105,11 @@ inline static QString qTableName( const QString& prefix, QSqlDriver* driver = 0 inline static bool testWhiteSpaceNames( const QString &name ) { - return name != QLatin1String("QTDS7"); +/* return name.startsWith( "QPSQL" ) + || name.startsWith( "QODBC" ) + || name.startsWith( "QSQLITE" ) + || name.startsWith( "QMYSQL" );*/ + return name != QLatin1String("QSQLITE2"); } inline static QString toHex( const QString& binary ) @@ -245,10 +249,11 @@ public: // addDb( "QODBC3", "DRIVER={SQL Native Client};SERVER=silence.nokia.troll.no\\SQLEXPRESS", "troll", "trond", "" ); // addDb( "QODBC", "DRIVER={MySQL ODBC 3.51 Driver};SERVER=mysql5-nokia.trolltech.com.au;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); -// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=horsehead.nokia.troll.no;DATABASE=testdb;PORT=4101;UID=troll;PWD=trondk;TDS_Version=8.0", "troll", "trondk", "" ); -// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=silence.nokia.troll.no;DATABASE=testdb;PORT=2392;UID=troll;PWD=trond;TDS_Version=8.0", "troll", "trond", "" ); -// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "testuser", "Ee4Gabf6_", "" ); -// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2008-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=mysql4-nokia.trolltech.com.au;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=horsehead.nokia.troll.no;DATABASE=testdb;PORT=4101;UID=troll;PWD=trondk", "troll", "trondk", "" ); +// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=silence.nokia.troll.no;DATABASE=testdb;PORT=2392;UID=troll;PWD=trond", "troll", "trond", "" ); +// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "", "", "" ); +// addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2008-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "", "", "" ); // addDb( "QTDS7", "testdb", "testuser", "Ee4Gabf6_", "bq-winserv2003" ); // addDb( "QTDS7", "testdb", "testuser", "Ee4Gabf6_", "bq-winserv2008" ); // addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" ); @@ -469,6 +474,16 @@ public: return db.databaseName().contains( "Access Driver", Qt::CaseInsensitive ); } + static bool isPostgreSQL( QSqlDatabase db ) + { + return db.driverName().startsWith("QPSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("PostgreSQL") ); + } + + static bool isMySQL( QSqlDatabase db ) + { + return db.driverName().startsWith("QMYSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("MySQL") ); + } + // -1 on fail, else Oracle version static int getOraVersion( QSqlDatabase db ) { diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 23b1eb5..82e25d7 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -188,7 +188,7 @@ private slots: void oci_fieldLength_data() { generic_data("QOCI"); } void oci_fieldLength(); - void sqlite_bindAndFetchUInt_data() { generic_data("QSQLITE3"); } + void sqlite_bindAndFetchUInt_data() { generic_data("QSQLITE"); } void sqlite_bindAndFetchUInt(); void sqlStatementUseIsNull_189093_data() { generic_data(); } @@ -256,6 +256,8 @@ static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db) QString autoName = tst_Databases::autoFieldName(db); if (tst_Databases::isMSAccess(db)) qs.append(" (id int not null"); + else if (tst_Databases::isPostgreSQL(db)) + qs.append(" (id serial not null"); else qs.append(QString("(id integer not null %1 primary key").arg(autoName)); @@ -1240,7 +1242,7 @@ void tst_QSqlDatabase::recordSQLServer() FieldDef("varchar(20)", QVariant::String, QString("Blah1")), FieldDef("bigint", QVariant::LongLong, 12345), FieldDef("int", QVariant::Int, 123456), - FieldDef("tinyint", QVariant::Int, 255), + FieldDef("tinyint", QVariant::UInt, 255), #ifdef QT3_SUPPORT FieldDef("image", QVariant::ByteArray, Q3CString("Blah1")), #endif @@ -1345,6 +1347,8 @@ void tst_QSqlDatabase::transaction() } QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 41")); + if(db.driverName().startsWith("QODBC") && dbName.contains("MySQL")) + QEXPECT_FAIL("", "Some odbc drivers don't actually roll back despite telling us they do, especially the mysql driver", Continue); QVERIFY(!q.next()); populateTestTables(db); @@ -1355,11 +1359,13 @@ void tst_QSqlDatabase::bigIntField() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + QString drvName = db.driverName(); QSqlQuery q(db); q.setForwardOnly(true); + if (drvName.startsWith("QOCI")) + q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt64); - QString drvName = db.driverName(); if (drvName.startsWith("QMYSQL")) { QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + " (id int, t_s64bit bigint, t_u64bit bigint unsigned)")); } else if (drvName.startsWith("QPSQL") @@ -1368,6 +1374,8 @@ void tst_QSqlDatabase::bigIntField() QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + "(id int, t_s64bit bigint, t_u64bit bigint)")); } else if (drvName.startsWith("QOCI")) { QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + " (id int, t_s64bit int, t_u64bit int)")); + //} else if (drvName.startsWith("QIBASE")) { + // QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + " (id int, t_s64bit int64, t_u64bit int64)")); } else { QSKIP("no 64 bit integer support", SkipAll); } @@ -1397,10 +1405,15 @@ void tst_QSqlDatabase::bigIntField() } QVERIFY(q.exec("select * from " + qTableName("qtest_bigint") + " order by id")); QVERIFY(q.next()); + QCOMPARE(q.value(1).toDouble(), (double)ll); QCOMPARE(q.value(1).toLongLong(), ll); + if(drvName.startsWith("QOCI")) + QEXPECT_FAIL("", "Oracle driver lacks support for unsigned int64 types", Continue); QCOMPARE(q.value(2).toULongLong(), ull); QVERIFY(q.next()); QCOMPARE(q.value(1).toLongLong(), -ll); + if(drvName.startsWith("QOCI")) + QEXPECT_FAIL("", "Oracle driver lacks support for unsigned int64 types", Continue); QCOMPARE(q.value(2).toULongLong(), ull); } @@ -1413,7 +1426,8 @@ void tst_QSqlDatabase::caseSensivity() bool cs = false; if (db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QSQLITE") - || db.driverName().startsWith("QTDS")) + || db.driverName().startsWith("QTDS") + || db.driverName().startsWith("QODBC")) cs = true; QSqlRecord rec = db.record(qTableName("qtest")); @@ -1512,6 +1526,7 @@ void tst_QSqlDatabase::psql_escapedIdentifiers() QString field1Name = QString("fIeLdNaMe"); QString field2Name = QString("ZuLu"); + q.exec(QString("DROP SCHEMA \"%1\" CASCADE").arg(schemaName)); QString createSchema = QString("CREATE SCHEMA \"%1\"").arg(schemaName); QVERIFY_SQL(q, exec(createSchema)); QString createTable = QString("CREATE TABLE \"%1\".\"%2\" (\"%3\" int PRIMARY KEY, \"%4\" varchar(20))").arg(schemaName).arg(tableName).arg(field1Name).arg(field2Name); @@ -1643,6 +1658,8 @@ void tst_QSqlDatabase::precisionPolicy() q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt32); QVERIFY_SQL(q, exec(query)); + if(db.driverName().startsWith("QOCI")) + QEXPECT_FAIL("", "Oracle fails to move to next when data columns are oversize", Abort); QVERIFY_SQL(q, next()); if(db.driverName().startsWith("QSQLITE")) QEXPECT_FAIL("", "SQLite returns this value as determined by contents of the field, not the declaration", Continue); @@ -2270,6 +2287,10 @@ void tst_QSqlDatabase::sqlite_bindAndFetchUInt() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + if (db.driverName().startsWith("QSQLITE2")) { + QSKIP("SQLite3 specific test", SkipSingle); + return; + } QSqlQuery q(db); QString tableName = qTableName("uint_test"); diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index ab7f0c9..f3dd920 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -188,6 +188,9 @@ private slots: void task_205701_data() { generic_data("QMYSQL"); } void task_205701(); + void task_233829_data() { generic_data("QPSQL"); } + void task_233829(); + private: // returns all database connections @@ -293,6 +296,9 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) << qTableName( "oraRowId" ) << qTableName( "qtest_batch" ); + if ( db.driverName().startsWith("QPSQL") ) + tablenames << qTableName("task_233829"); + if ( db.driverName().startsWith("QSQLITE") ) tablenames << qTableName( "record_sqlite" ); @@ -302,7 +308,7 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) tablenames << qTableName( "qtest_lockedtable" ); tablenames << qTableName( "Planet" ); - + tablenames << qTableName( "task_250026" ); tablenames << qTableName( "task_234422" ); @@ -318,7 +324,10 @@ void tst_QSqlQuery::createTestTables( QSqlDatabase db ) // in the MySQL server startup script q.exec( "set table_type=innodb" ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest" ) + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) ); + if(tst_Databases::isPostgreSQL(db)) + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest" ) + " (id serial NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id)) WITH OIDS" ) ); + else + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest" ) + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) ); if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) ) QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null" ) + " (id int null, t_varchar varchar(20) null)" ) ); @@ -486,7 +495,9 @@ void tst_QSqlQuery::mysqlOutValues() QVERIFY_SQL( q, exec( "create procedure " + qTableName( "qtestproc" ) + " () " "BEGIN select * from " + qTableName( "qtest" ) + " order by id; END" ) ); QVERIFY_SQL( q, exec( "call " + qTableName( "qtestproc" ) + "()" ) ); + QEXPECT_FAIL("", "There's a mysql bug that means only selects think they return data when running in prepared mode", Continue); QVERIFY_SQL( q, next() ); + QEXPECT_FAIL("", "There's a mysql bug that means only selects think they return data when running in prepared mode", Continue); QCOMPARE( q.value( 1 ).toString(), QString( "VarChar1" ) ); QVERIFY_SQL( q, exec( "drop procedure " + qTableName( "qtestproc" ) ) ); @@ -1870,7 +1881,7 @@ void tst_QSqlQuery::invalidQuery() QVERIFY( !q.next() ); QVERIFY( !q.isActive() ); - if ( !db.driverName().startsWith( "QOCI" ) && !db.driverName().startsWith( "QDB2" ) ) { + if ( !db.driverName().startsWith( "QOCI" ) && !db.driverName().startsWith( "QDB2" ) && !db.driverName().startsWith( "QODBC" ) ) { // oracle and db2 just prepares everything without complaining if ( db.driver()->hasFeature( QSqlDriver::PreparedQueries ) ) QVERIFY( !q.prepare( "blahfasel" ) ); @@ -2007,7 +2018,7 @@ void tst_QSqlQuery::oraArrayBind() q.bindValue( 0, list, QSql::In ); - QVERIFY_SQL( q, execBatch( QSqlQuery::ValuesAsRows ) ); + QVERIFY_SQL( q, execBatch( QSqlQuery::ValuesAsColumns ) ); QVERIFY_SQL( q, prepare( "BEGIN " "ora_array_test.get_table(?); " @@ -2019,7 +2030,7 @@ void tst_QSqlQuery::oraArrayBind() q.bindValue( 0, list, QSql::Out ); - QVERIFY_SQL( q, execBatch( QSqlQuery::ValuesAsRows ) ); + QVERIFY_SQL( q, execBatch( QSqlQuery::ValuesAsColumns ) ); QVariantList out_list = q.boundValue( 0 ).toList(); @@ -2565,7 +2576,7 @@ void tst_QSqlQuery::blobsPreparedQuery() QString typeName( "BLOB" ); if ( db.driverName().startsWith( "QPSQL" ) ) typeName = "BYTEA"; - else if ( db.driverName().startsWith( "QODBC" ) ) + else if ( db.driverName().startsWith( "QODBC" ) && tst_Databases::isSqlServer( db )) typeName = "IMAGE"; QVERIFY_SQL( q, exec( QString( "CREATE TABLE %1(id INTEGER, data %2)" ).arg( tableName ).arg( typeName ) ) ); @@ -2771,5 +2782,24 @@ void tst_QSqlQuery::task_234422() #endif +void tst_QSqlQuery::task_233829() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + + QSqlQuery q( db ); + QString tableName = qTableName("task_233829"); + QVERIFY_SQL(q,exec("CREATE TABLE " + tableName + "(dbl1 double precision,dbl2 double precision) without oids;")); + + QString queryString("INSERT INTO " + tableName +"(dbl1, dbl2) VALUES(?,?)"); + + double k = 0.0; + QVERIFY_SQL(q,prepare(queryString)); + q.bindValue(0,0.0 / k); // nan + q.bindValue(1,0.0 / k); // nan + QVERIFY_SQL(q,exec()); +} + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index e2dace8..1e23d3d 100644 --- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -145,8 +145,17 @@ void tst_QSqlRelationalTableModel::recreateTestTables(QSqlDatabase db) void tst_QSqlRelationalTableModel::initTestCase() { - foreach (const QString &dbname, dbs.dbNames) - recreateTestTables(QSqlDatabase::database(dbname)); + foreach (const QString &dbname, dbs.dbNames) { + QSqlDatabase db=QSqlDatabase::database(dbname); + if (db.driverName().startsWith("QIBASE")) + db.exec("SET DIALECT 3"); + else if (tst_Databases::isSqlServer(db)) { + QSqlQuery q(db); + QVERIFY_SQL(q, exec("SET ANSI_DEFAULTS ON")); + QVERIFY_SQL(q, exec("SET IMPLICIT_TRANSACTIONS OFF")); + } + recreateTestTables(db); + } } void tst_QSqlRelationalTableModel::cleanupTestCase() @@ -167,10 +176,10 @@ void tst_QSqlRelationalTableModel::dropTestTables( QSqlDatabase db ) << qTableName( "reltest3" ) << qTableName( "reltest4" ) << qTableName( "reltest5" ) - << qTableName( "rel test6", db.driver() ) - << qTableName( "rel test7", db.driver() ) - << qTableName("CASETEST1", db.driver() ) - << qTableName("casetest1", db.driver() ); + << qTableName( "rel test6" ) + << qTableName( "rel test7" ) + << qTableName("CASETEST1" ) + << qTableName("casetest1" ); tst_Databases::safeDropTables( db, tableNames ); } @@ -490,6 +499,7 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() model.setTable(qTableName("reltest1")); model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setSort(0, Qt::AscendingOrder); if (!db.driverName().startsWith("QTDS")) model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title")); @@ -914,8 +924,8 @@ void tst_QSqlRelationalTableModel::casing() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - if (db.driverName().startsWith("QSQLITE")) - QSKIP("The casing test for SQLITE is irrelevant since SQLITE is case insensitive", SkipAll); + if (db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QIBASE") || tst_Databases::isSqlServer(db)) + QSKIP("The casing test for this database is irrelevant since this database does not treat different cases as separate entities", SkipAll); QSqlQuery q(db); QVERIFY_SQL( q, exec("create table " + qTableName("CASETEST1", db.driver()).toUpper() + diff --git a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp index fa44034..fba7b1b 100644 --- a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -1454,6 +1454,7 @@ static QStandardItem *itemFromText(QStandardItem *parent, const QString &text) return item; } +#ifdef QT_BUILD_INTERNAL static QModelIndex indexFromText(QStandardItemModel *model, const QString &text) { QStandardItem *item = itemFromText(model->invisibleRootItem(), text); @@ -1467,9 +1468,11 @@ struct FriendlyTreeView : public QTreeView friend class tst_QStandardItemModel; Q_DECLARE_PRIVATE(QTreeView) }; +#endif void tst_QStandardItemModel::treeDragAndDrop() { +#ifdef QT_BUILD_INTERNAL const int nRow = 5; const int nCol = 3; @@ -1605,6 +1608,7 @@ void tst_QStandardItemModel::treeDragAndDrop() QVERIFY(compareModels(&model, &checkModel)); } +#endif } void tst_QStandardItemModel::removeRowsAndColumns() diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index a859866..efcb983 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -1015,6 +1015,7 @@ void tst_QStateMachine::rootState() void tst_QStateMachine::addAndRemoveState() { +#ifdef QT_BUILD_INTERNAL QStateMachine machine; QStatePrivate *root_d = QStatePrivate::get(machine.rootState()); QCOMPARE(root_d->childStates().size(), 0); @@ -1075,6 +1076,7 @@ void tst_QStateMachine::addAndRemoveState() delete s2; // ### how to deal with this? // machine.removeState(machine.errorState()); +#endif } void tst_QStateMachine::stateEntryAndExit() diff --git a/tests/auto/qstringbuilder/tst_qstringbuilder.cpp b/tests/auto/qstringbuilder/tst_qstringbuilder.cpp index fdbaf21..72889bc 100644 --- a/tests/auto/qstringbuilder/tst_qstringbuilder.cpp +++ b/tests/auto/qstringbuilder/tst_qstringbuilder.cpp @@ -85,28 +85,18 @@ #undef QT_NO_CAST_TO_ASCII #endif - #include <QtTest/QtTest> //TESTED_CLASS=QStringBuilder //TESTED_FILES=qstringbuilder.cpp -#include <qtest.h> - #define LITERAL "some literal" class tst_QStringBuilder : public QObject { Q_OBJECT -public: - tst_QStringBuilder() {} - ~tst_QStringBuilder() {} - -public slots: - void init() {} - void cleanup() {} - +private slots: void scenario(); }; @@ -119,6 +109,7 @@ void tst_QStringBuilder::scenario() QLatin1Char achar('c'); QString r2(QLatin1String(LITERAL LITERAL)); QString r; + QByteArray ba(LITERAL); r = l1literal P l1literal; QCOMPARE(r, r2); @@ -139,6 +130,10 @@ void tst_QStringBuilder::scenario() QCOMPARE(r, r2); r = LITERAL P string; QCOMPARE(r, r2); + r = ba P string; + QCOMPARE(r, r2); + r = string P ba; + QCOMPARE(r, r2); #endif } diff --git a/tests/auto/qstylesheetstyle/qstylesheetstyle.pro b/tests/auto/qstylesheetstyle/qstylesheetstyle.pro index 6acb0b4..f6101f4 100644 --- a/tests/auto/qstylesheetstyle/qstylesheetstyle.pro +++ b/tests/auto/qstylesheetstyle/qstylesheetstyle.pro @@ -13,3 +13,4 @@ contains(QT_CONFIG, qt3support): QT += qt3support # Input SOURCES += tst_qstylesheetstyle.cpp RESOURCES += resources.qrc +requires(contains(QT_CONFIG,private_tests)) diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp index f11aff9..2bbe897 100644 --- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp +++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp @@ -80,6 +80,9 @@ private slots: void opacity(); void paths(); void displayMode(); + void strokeInherit(); + void testFillInheritance(); + void testStopOffsetOpacity(); #ifndef QT_NO_COMPRESS void testGzLoading(); @@ -624,9 +627,11 @@ void tst_QSvgRenderer::testGzLoading() QVERIFY(autoDetectGzData.isValid()); } +#ifdef QT_BUILD_INTERNAL QT_BEGIN_NAMESPACE QByteArray qt_inflateGZipDataFrom(QIODevice *device); QT_END_NAMESPACE +#endif void tst_QSvgRenderer::testGzHelper_data() { @@ -659,6 +664,7 @@ void tst_QSvgRenderer::testGzHelper_data() void tst_QSvgRenderer::testGzHelper() { +#ifdef QT_BUILD_INTERNAL QFETCH(QByteArray, in); QFETCH(QByteArray, out); @@ -667,6 +673,7 @@ void tst_QSvgRenderer::testGzHelper() QVERIFY(buffer.isReadable()); QByteArray result = qt_inflateGZipDataFrom(&buffer); QCOMPARE(result, out); +#endif } #endif @@ -925,5 +932,278 @@ void tst_QSvgRenderer::displayMode() } } +void tst_QSvgRenderer::strokeInherit() +{ + static const char *svgs[] = { + // Reference. + "<svg viewBox=\"0 0 200 30\">" + " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\"" + " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\"" + " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">" + " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\"/>" + " </g>" + " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">" + " <polyline fill=\"none\" points=\"10 25 80 25\"/>" + " </g>" + "</svg>", + // stroke + "<svg viewBox=\"0 0 200 30\">" + " <g stroke=\"none\" stroke-width=\"20\" stroke-linecap=\"butt\"" + " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\"" + " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">" + " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke=\"blue\"/>" + " </g>" + " <g stroke=\"yellow\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">" + " <polyline fill=\"none\" points=\"10 25 80 25\" stroke=\"green\"/>" + " </g>" + "</svg>", + // stroke-width + "<svg viewBox=\"0 0 200 30\">" + " <g stroke=\"blue\" stroke-width=\"0\" stroke-linecap=\"butt\"" + " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\"" + " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">" + " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-width=\"20\"/>" + " </g>" + " <g stroke=\"green\" stroke-width=\"10\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">" + " <polyline fill=\"none\" points=\"10 25 80 25\" stroke-width=\"0\"/>" + " </g>" + "</svg>", + // stroke-linecap + "<svg viewBox=\"0 0 200 30\">" + " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"round\"" + " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\"" + " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">" + " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-linecap=\"butt\"/>" + " </g>" + " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">" + " <polyline fill=\"none\" points=\"10 25 80 25\"/>" + " </g>" + "</svg>", + // stroke-linejoin + "<svg viewBox=\"0 0 200 30\">" + " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\"" + " stroke-linejoin=\"round\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\"" + " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">" + " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-linejoin=\"miter\"/>" + " </g>" + " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">" + " <polyline fill=\"none\" points=\"10 25 80 25\"/>" + " </g>" + "</svg>", + // stroke-miterlimit + "<svg viewBox=\"0 0 200 30\">" + " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\"" + " stroke-linejoin=\"miter\" stroke-miterlimit=\"2\" stroke-dasharray=\"20,10\"" + " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">" + " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-miterlimit=\"1\"/>" + " </g>" + " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">" + " <polyline fill=\"none\" points=\"10 25 80 25\"/>" + " </g>" + "</svg>", + // stroke-dasharray + "<svg viewBox=\"0 0 200 30\">" + " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\"" + " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"1,1,1,1,1,1,3,1,3,1,3,1,1,1,1,1,1,3\"" + " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">" + " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-dasharray=\"20,10\"/>" + " </g>" + " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"none\" stroke-dashoffset=\"4.5\">" + " <polyline fill=\"none\" points=\"10 25 80 25\" stroke-dasharray=\"3,3,1\"/>" + " </g>" + "</svg>", + // stroke-dashoffset + "<svg viewBox=\"0 0 200 30\">" + " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\"" + " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\"" + " stroke-dashoffset=\"0\" stroke-opacity=\"0.5\">" + " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-dashoffset=\"10\"/>" + " </g>" + " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"0\">" + " <polyline fill=\"none\" points=\"10 25 80 25\" stroke-dashoffset=\"4.5\"/>" + " </g>" + "</svg>", + // stroke-opacity + "<svg viewBox=\"0 0 200 30\">" + " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\"" + " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\"" + " stroke-dashoffset=\"10\" stroke-opacity=\"0\">" + " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-opacity=\"0.5\"/>" + " </g>" + " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">" + " <polyline fill=\"none\" points=\"10 25 80 25\"/>" + " </g>" + "</svg>" + }; + + const int COUNT = sizeof(svgs) / sizeof(svgs[0]); + QImage images[COUNT]; + QPainter p; + + for (int i = 0; i < COUNT; ++i) { + QByteArray data(svgs[i]); + QSvgRenderer renderer(data); + QVERIFY(renderer.isValid()); + images[i] = QImage(200, 30, QImage::Format_ARGB32_Premultiplied); + images[i].fill(-1); + p.begin(&images[i]); + renderer.render(&p); + p.end(); + if (i != 0) { + QCOMPARE(images[0], images[i]); + } + } +} + +void tst_QSvgRenderer::testFillInheritance() +{ + static const char *svgs[] = { + //reference + "<svg viewBox = \"0 0 200 200\">" + " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" fill= \"red\" stroke = \"blue\" fill-opacity = \"0.5\" fill-rule = \"evenodd\"/>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" fill= \"red\" stroke = \"blue\" fill-opacity = \"0.5\" fill-rule = \"evenodd\"/>" + " <rect x = \"40\" y = \"40\" width = \"70\" height =\"20\" fill = \"green\" fill-opacity = \"0\"/>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <g fill = \"red\" fill-opacity = \"0.5\" fill-rule = \"evenodd\">" + " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" stroke = \"blue\"/>" + " </g>" + " <rect x = \"40\" y = \"40\" width = \"70\" height =\"20\" fill = \"green\" fill-opacity = \"0\"/>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <g fill = \"green\" fill-rule = \"nonzero\">" + " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" stroke = \"blue\" fill = \"red\" fill-opacity = \"0.5\" fill-rule = \"evenodd\"/>" + " </g>" + " <g fill-opacity = \"0.8\" fill = \"red\">" + " <rect x = \"40\" y = \"40\" width = \"70\" height =\"20\" fill = \"green\" fill-opacity = \"0\"/>" + " </g>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <g fill = \"red\" >" + " <g fill-opacity = \"0.5\">" + " <g fill-rule = \"evenodd\">" + " <g>" + " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" stroke = \"blue\"/>" + " </g>" + " </g>" + " </g>" + " </g>" + " <g fill-opacity = \"0.8\" >" + " <rect x = \"40\" y = \"40\" width = \"70\" height =\"20\" fill = \"none\"/>" + " </g>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <g fill = \"none\" fill-opacity = \"0\">" + " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" stroke = \"blue\" fill = \"red\" fill-opacity = \"0.5\" fill-rule = \"evenodd\"/>" + " </g>" + " <g fill-opacity = \"0\" >" + " <rect x = \"40\" y = \"40\" width = \"70\" height =\"20\" fill = \"green\"/>" + " </g>" + "</svg>" + }; + + const int COUNT = sizeof(svgs) / sizeof(svgs[0]); + QImage images[COUNT]; + QPainter p; + + for (int i = 0; i < COUNT; ++i) { + QByteArray data(svgs[i]); + QSvgRenderer renderer(data); + QVERIFY(renderer.isValid()); + images[i] = QImage(200, 200, QImage::Format_ARGB32_Premultiplied); + images[i].fill(-1); + p.begin(&images[i]); + renderer.render(&p); + p.end(); + if (i != 0) { + QCOMPARE(images[0], images[i]); + } + } +} +void tst_QSvgRenderer::testStopOffsetOpacity() +{ + static const char *svgs[] = { + //reference + "<svg viewBox=\"0 0 64 64\">" + "<radialGradient id=\"MyGradient1\" gradientUnits=\"userSpaceOnUse\" cx=\"50\" cy=\"50\" r=\"30\" fx=\"20\" fy=\"20\">" + "<stop offset=\"0.0\" style=\"stop-color:red\" stop-opacity=\"0.3\"/>" + "<stop offset=\"0.5\" style=\"stop-color:green\" stop-opacity=\"1\"/>" + "<stop offset=\"1\" style=\"stop-color:yellow\" stop-opacity=\"1\"/>" + "</radialGradient>" + "<radialGradient id=\"MyGradient2\" gradientUnits=\"userSpaceOnUse\" cx=\"50\" cy=\"70\" r=\"70\" fx=\"20\" fy=\"20\">" + "<stop offset=\"0.0\" style=\"stop-color:blue\" stop-opacity=\"0.3\"/>" + "<stop offset=\"0.5\" style=\"stop-color:violet\" stop-opacity=\"1\"/>" + "<stop offset=\"1\" style=\"stop-color:orange\" stop-opacity=\"1\"/>" + "</radialGradient>" + "<rect x=\"5\" y=\"5\" width=\"55\" height=\"55\" fill=\"url(#MyGradient1)\" stroke=\"black\" />" + "<rect x=\"20\" y=\"20\" width=\"35\" height=\"35\" fill=\"url(#MyGradient2)\"/>" + "</svg>", + //Stop Offset + "<svg viewBox=\"0 0 64 64\">" + "<radialGradient id=\"MyGradient1\" gradientUnits=\"userSpaceOnUse\" cx=\"50\" cy=\"50\" r=\"30\" fx=\"20\" fy=\"20\">" + "<stop offset=\"abc\" style=\"stop-color:red\" stop-opacity=\"0.3\"/>" + "<stop offset=\"0.5\" style=\"stop-color:green\" stop-opacity=\"1\"/>" + "<stop offset=\"1\" style=\"stop-color:yellow\" stop-opacity=\"1\"/>" + "</radialGradient>" + "<radialGradient id=\"MyGradient2\" gradientUnits=\"userSpaceOnUse\" cx=\"50\" cy=\"70\" r=\"70\" fx=\"20\" fy=\"20\">" + "<stop offset=\"-3.bc\" style=\"stop-color:blue\" stop-opacity=\"0.3\"/>" + "<stop offset=\"0.5\" style=\"stop-color:violet\" stop-opacity=\"1\"/>" + "<stop offset=\"1\" style=\"stop-color:orange\" stop-opacity=\"1\"/>" + "</radialGradient>" + "<rect x=\"5\" y=\"5\" width=\"55\" height=\"55\" fill=\"url(#MyGradient1)\" stroke=\"black\" />" + "<rect x=\"20\" y=\"20\" width=\"35\" height=\"35\" fill=\"url(#MyGradient2)\"/>" + "</svg>", + //Stop Opacity + "<svg viewBox=\"0 0 64 64\">" + "<radialGradient id=\"MyGradient1\" gradientUnits=\"userSpaceOnUse\" cx=\"50\" cy=\"50\" r=\"30\" fx=\"20\" fy=\"20\">" + "<stop offset=\"0.0\" style=\"stop-color:red\" stop-opacity=\"0.3\"/>" + "<stop offset=\"0.5\" style=\"stop-color:green\" stop-opacity=\"x.45\"/>" + "<stop offset=\"1\" style=\"stop-color:yellow\" stop-opacity=\"-3.abc\"/>" + "</radialGradient>" + "<radialGradient id=\"MyGradient2\" gradientUnits=\"userSpaceOnUse\" cx=\"50\" cy=\"70\" r=\"70\" fx=\"20\" fy=\"20\">" + "<stop offset=\"0.0\" style=\"stop-color:blue\" stop-opacity=\"0.3\"/>" + "<stop offset=\"0.5\" style=\"stop-color:violet\" stop-opacity=\"-0.xy\"/>" + "<stop offset=\"1\" style=\"stop-color:orange\" stop-opacity=\"z.5\"/>" + "</radialGradient>" + "<rect x=\"5\" y=\"5\" width=\"55\" height=\"55\" fill=\"url(#MyGradient1)\" stroke=\"black\" />" + "<rect x=\"20\" y=\"20\" width=\"35\" height=\"35\" fill=\"url(#MyGradient2)\"/>" + "</svg>", + //Stop offset and Stop opacity + "<svg viewBox=\"0 0 64 64\">" + "<radialGradient id=\"MyGradient1\" gradientUnits=\"userSpaceOnUse\" cx=\"50\" cy=\"50\" r=\"30\" fx=\"20\" fy=\"20\">" + "<stop offset=\"abc\" style=\"stop-color:red\" stop-opacity=\"0.3\"/>" + "<stop offset=\"0.5\" style=\"stop-color:green\" stop-opacity=\"x.45\"/>" + "<stop offset=\"1\" style=\"stop-color:yellow\" stop-opacity=\"-3.abc\"/>" + "</radialGradient>" + "<radialGradient id=\"MyGradient2\" gradientUnits=\"userSpaceOnUse\" cx=\"50\" cy=\"70\" r=\"70\" fx=\"20\" fy=\"20\">" + "<stop offset=\"-3.bc\" style=\"stop-color:blue\" stop-opacity=\"0.3\"/>" + "<stop offset=\"0.5\" style=\"stop-color:violet\" stop-opacity=\"-0.xy\"/>" + "<stop offset=\"1\" style=\"stop-color:orange\" stop-opacity=\"z.5\"/>" + "</radialGradient>" + "<rect x=\"5\" y=\"5\" width=\"55\" height=\"55\" fill=\"url(#MyGradient1)\" stroke=\"black\" />" + "<rect x=\"20\" y=\"20\" width=\"35\" height=\"35\" fill=\"url(#MyGradient2)\"/>" + "</svg>" + }; + + QImage images[4]; + QPainter p; + + for (int i = 0; i < 4; ++i) { + QByteArray data(svgs[i]); + QSvgRenderer renderer(data); + QVERIFY(renderer.isValid()); + images[i] = QImage(64, 64, QImage::Format_ARGB32_Premultiplied); + images[i].fill(-1); + p.begin(&images[i]); + renderer.render(&p); + p.end(); + } + QCOMPARE(images[0], images[1]); + QCOMPARE(images[0], images[2]); + QCOMPARE(images[0], images[3]); +} + QTEST_MAIN(tst_QSvgRenderer) #include "tst_qsvgrenderer.moc" diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index ae023ba..6fa57f0 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -175,6 +175,8 @@ private slots: // task-specific tests: void task173773_updateVerticalHeader(); void task227953_setRootIndex(); + void task240266_veryBigColumn(); + void task248688_autoScrollNavigation(); void mouseWheel_data(); void mouseWheel(); @@ -586,7 +588,7 @@ void tst_QTableView::keyboardNavigation() QModelIndex index = model.index(rowCount - 1, columnCount - 1); view.setCurrentIndex(index); - QApplication::instance()->processEvents(); + QApplication::processEvents(); int row = rowCount - 1; int column = columnCount - 1; @@ -618,7 +620,7 @@ void tst_QTableView::keyboardNavigation() } QTest::keyClick(&view, key); - QApplication::instance()->processEvents(); + QApplication::processEvents(); QModelIndex index = model.index(row, column); QCOMPARE(view.currentIndex(), index); @@ -3127,6 +3129,56 @@ void tst_QTableView::task227953_setRootIndex() QVERIFY(!tableView.verticalHeader()->isHidden()); } +void tst_QTableView::task240266_veryBigColumn() +{ + QTableView table; + table.setFixedSize(500, 300); //just to make sure we have the 2 first columns visible + QStandardItemModel model(1, 3); + table.setModel(&model); + table.setColumnWidth(0, 100); //normal column + table.setColumnWidth(1, 100); //normal column + table.setColumnWidth(2, 9000); //very big column + table.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(100); + + QScrollBar *scroll = table.horizontalScrollBar(); + QCOMPARE(scroll->minimum(), 0); + QCOMPARE(scroll->maximum(), model.columnCount() - 1); + QCOMPARE(scroll->singleStep(), 1); + + //1 is not always a very correct value for pageStep. Ideally this should be dynamic. + //Maybe something for Qt 5 ;-) + QCOMPARE(scroll->pageStep(), 1); + +} + +void tst_QTableView::task248688_autoScrollNavigation() +{ + //we make sure that when navigating with the keyboard the view is correctly scrolled + //to the current item + QStandardItemModel model(16, 16); + QTableView view; + view.setModel(&model); + + view.hideColumn(8); + view.hideRow(8); + view.show(); + for (int r = 0; r < model.rowCount(); ++r) { + if (view.isRowHidden(r)) + continue; + for (int c = 0; c < model.columnCount(); ++c) { + if (view.isColumnHidden(c)) + continue; + QModelIndex index = model.index(r, c); + view.setCurrentIndex(index); + QVERIFY(view.viewport()->rect().contains(view.visualRect(index))); + } + } +} + void tst_QTableView::mouseWheel_data() { diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp index 3bc1517..d54645c 100644 --- a/tests/auto/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/qtextedit/tst_qtextedit.cpp @@ -1460,6 +1460,7 @@ void tst_QTextEdit::mimeDataReimplementations() QCOMPARE(ed.canInsertCallCount, 0); QCOMPARE(ed.insertCallCount, 0); +#ifdef QT_BUILD_INTERNAL QTextControl *control = qFindChild<QTextControl *>(&ed); QVERIFY(control); @@ -1474,6 +1475,7 @@ void tst_QTextEdit::mimeDataReimplementations() QCOMPARE(ed.createMimeDataCallCount, 1); QCOMPARE(ed.canInsertCallCount, 1); QCOMPARE(ed.insertCallCount, 1); +#endif } void tst_QTextEdit::ctrlEnterShouldInsertLineSeparator_NOT() @@ -2066,6 +2068,7 @@ void tst_QTextEdit::cursorRect() void tst_QTextEdit::setDocumentPreservesPalette() { +#ifdef QT_BUILD_INTERNAL QTextControl *control = qFindChild<QTextControl *>(ed); QVERIFY(control); @@ -2085,6 +2088,7 @@ void tst_QTextEdit::setDocumentPreservesPalette() QVERIFY(control->document() == newDoc); QVERIFY(whitePal.color(QPalette::Active, QPalette::Text) == control->palette().color(QPalette::Active, QPalette::Text)); +#endif } class PublicTextEdit : public QTextEdit diff --git a/tests/auto/qtextpiecetable/qtextpiecetable.pro b/tests/auto/qtextpiecetable/qtextpiecetable.pro index 318a8c7..0926b83 100644 --- a/tests/auto/qtextpiecetable/qtextpiecetable.pro +++ b/tests/auto/qtextpiecetable/qtextpiecetable.pro @@ -2,7 +2,6 @@ load(qttest_p4) SOURCES += tst_qtextpiecetable.cpp HEADERS += ../qtextdocument/common.h -!win32:DEFINES += QTEST_REDUCED_EXPORTS - - +requires(!win32) +requires(contains(QT_CONFIG,private_tests)) diff --git a/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp index accbabb..0e60c16 100644 --- a/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp +++ b/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp @@ -42,9 +42,7 @@ #include <QtTest/QtTest> -#ifdef QTEST_REDUCED_EXPORTS #define private public -#endif #include <qtextdocument.h> #include <private/qtextdocument_p.h> @@ -65,7 +63,6 @@ public: tst_QTextPieceTable(); -#ifdef QTEST_REDUCED_EXPORTS public slots: void init(); void cleanup(); @@ -112,13 +109,7 @@ private slots: void removeFrameDirect(); void removeWithChildFrame(); void clearWithFrames(); -#else -public slots: - void init(); - void cleanup(); -private slots: - void skip(); -#endif + private: QTextDocument *doc; QTextDocumentPrivate *table; @@ -130,8 +121,6 @@ tst_QTextPieceTable::tst_QTextPieceTable() { doc = 0; table = 0; } -#ifdef QTEST_REDUCED_EXPORTS - void tst_QTextPieceTable::init() { doc = new QTextDocument(0); @@ -1148,25 +1137,6 @@ void tst_QTextPieceTable::clearWithFrames() QVERIFY(true); } -#else // QTEST_REDUCED_EXPORTS - -void tst_QTextPieceTable::init() -{ -} - -void tst_QTextPieceTable::cleanup() -{ -} - -void tst_QTextPieceTable::skip() -{ - QSKIP( "Not tested on win32", SkipAll ); -} - - -#endif // QTEST_REDUCED_EXPORTS - - QTEST_MAIN(tst_QTextPieceTable) diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index ea551da..723f882 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -3057,12 +3057,15 @@ void tst_QUrl::nameprep_testsuite_data() << QString() << 0 << 0; } +#ifdef QT_BUILD_INTERNAL QT_BEGIN_NAMESPACE extern QString qt_nameprep(const QString &source); QT_END_NAMESPACE +#endif void tst_QUrl::nameprep_testsuite() { +#ifdef QT_BUILD_INTERNAL QFETCH(QString, in); QFETCH(QString, out); QFETCH(QString, profile); @@ -3082,6 +3085,7 @@ void tst_QUrl::nameprep_testsuite() QEXPECT_FAIL("Larger test (expanding)", "Investigate further", Continue); QCOMPARE(qt_nameprep(in), out); +#endif } void tst_QUrl::ace_testsuite_data() diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 04ec77d..fa36496 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -353,6 +353,7 @@ private slots: void toplevelLineEditFocus(); void focusWidget_task254563(); + void rectOutsideCoordinatesLimit_task144779(); private: bool ensureScreenSize(int width, int height); @@ -9117,5 +9118,39 @@ void tst_QWidget::focusWidget_task254563() QVERIFY(top.focusWidget() != widget); //dangling pointer } +void tst_QWidget::rectOutsideCoordinatesLimit_task144779() +{ + QWidget main; + QPalette palette; + palette.setColor(QPalette::Window, Qt::red); + main.setPalette(palette); + main.resize(400, 400); + + QWidget *offsetWidget = new QWidget(&main); + offsetWidget->setGeometry(0, -14600, 400, 15000); + + // big widget is too big for the coordinates, it must be limited by wrect + // if wrect is not at the right position because of offsetWidget, bigwidget + // is not painted correctly + QWidget *bigWidget = new QWidget(offsetWidget); + bigWidget->setGeometry(0, 0, 400, 50000); + palette.setColor(QPalette::Window, Qt::green); + bigWidget->setPalette(palette); + bigWidget->setAutoFillBackground(true); + + main.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&main); +#endif + QTest::qWait(100); + QPixmap pixmap = QPixmap::grabWindow(main.winId()); + + QPixmap correct(main.size()); + correct.fill(Qt::green); + + QRect center(100, 100, 200, 200); // to avoid the decorations + QCOMPARE(pixmap.toImage().copy(center), correct.toImage().copy(center)); +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" diff --git a/tests/auto/xmlpatternsdiagnosticsts/xmlpatternsdiagnosticsts.pro b/tests/auto/xmlpatternsdiagnosticsts/xmlpatternsdiagnosticsts.pro index e90b335..3d82eaf 100644 --- a/tests/auto/xmlpatternsdiagnosticsts/xmlpatternsdiagnosticsts.pro +++ b/tests/auto/xmlpatternsdiagnosticsts/xmlpatternsdiagnosticsts.pro @@ -2,3 +2,4 @@ TEMPLATE = subdirs CONFIG += ordered SUBDIRS = ../xmlpatternsxqts test +requires(contains(QT_CONFIG,private_tests)) diff --git a/tests/auto/xmlpatternsview/xmlpatternsview.pro b/tests/auto/xmlpatternsview/xmlpatternsview.pro index 3544264..04ee4d0 100644 --- a/tests/auto/xmlpatternsview/xmlpatternsview.pro +++ b/tests/auto/xmlpatternsview/xmlpatternsview.pro @@ -6,3 +6,4 @@ SUBDIRS = ../xmlpatternsxqts test contains(QT_CONFIG,xmlpatterns) { SUBDIRS += view } +requires(contains(QT_CONFIG,private_tests)) diff --git a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro index 368a028..a3b13da 100644 --- a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro +++ b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro @@ -9,3 +9,6 @@ contains(QT_CONFIG,xmlpatterns) { # Needed on the win32-g++ setup and on the test machine arsia. INCLUDEPATH += $$QT_BUILD_TREE/include/QtXmlPatterns/private \ ../../../include/QtXmlPatterns/private + +requires(contains(QT_CONFIG,private_tests)) + diff --git a/tests/auto/xmlpatternsxslts/xmlpatternsxslts.pro b/tests/auto/xmlpatternsxslts/xmlpatternsxslts.pro index 4a688c4..9b63a52 100644 --- a/tests/auto/xmlpatternsxslts/xmlpatternsxslts.pro +++ b/tests/auto/xmlpatternsxslts/xmlpatternsxslts.pro @@ -23,3 +23,4 @@ wince*: { DEPLOYMENT += testdata } +requires(contains(QT_CONFIG,private_tests)) |