diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-09-18 12:54:44 (GMT) |
---|---|---|
committer | Lars Knoll <lars.knoll@nokia.com> | 2009-09-18 12:54:44 (GMT) |
commit | 0e7e62eb6afbc1f20d08b837643009cec8eaacb9 (patch) | |
tree | 1eb5f9fb0194b8a9ffa1d9ab961a0ac68db7508a /tests | |
parent | b88bcd68a62ab8ed348bc698f7342346963bb7c0 (diff) | |
parent | 421e02d7b48b4a852a4aa1e6feb781a64f0981b4 (diff) | |
download | Qt-0e7e62eb6afbc1f20d08b837643009cec8eaacb9.zip Qt-0e7e62eb6afbc1f20d08b837643009cec8eaacb9.tar.gz Qt-0e7e62eb6afbc1f20d08b837643009cec8eaacb9.tar.bz2 |
Merge commit 'origin/4.6' into kinetic-declarativeui
Conflicts:
configure.exe
Diffstat (limited to 'tests')
49 files changed, 3929 insertions, 129 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index e8add04..3df24ac 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -143,6 +143,7 @@ SUBDIRS += \ qgraphicsitem \ qgraphicsitemanimation \ qgraphicsanchorlayout \ + qgraphicsanchorlayout1 \ qgraphicslayout \ qgraphicslayoutitem \ qgraphicslinearlayout \ 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 1ad6ec8..6a1f625 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before @@ -3,18 +3,18 @@ <context> <name>FindDialog</name> <message> - <location filename="project.ui" line="15"/> + <location filename="project.ui" line="57"/> <source>Qt Assistant - Find text</source> <!--should be changed to unfinished, since we are changing the sourcetext in the UI file--> <translation>Qt Assistant - Finn tekst</translation> </message> <message> - <location filename="project.ui" line="18"/> + <location filename="project.ui" line="60"/> <source>300px</source> <translation>300px</translation> </message> <message> - <location filename="project.ui" line="21"/> + <location filename="project.ui" line="63"/> <source>400px</source> <translation type="unfinished"></translation> </message> diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index a117d09..4b4d0a0 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -54,6 +54,8 @@ # define STRINGIFY(x) #x # define TOSTRING(x) STRINGIFY(x) # define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/" +#elif defined(Q_OS_UNIX) +# include <unistd.h> #endif #if defined(Q_OS_VXWORKS) diff --git a/tests/auto/qdirmodel/tst_qdirmodel.cpp b/tests/auto/qdirmodel/tst_qdirmodel.cpp index ec05a08..be46527 100644 --- a/tests/auto/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/qdirmodel/tst_qdirmodel.cpp @@ -614,17 +614,24 @@ void tst_QDirModel::task196768_sorting() QTreeView view; QPersistentModelIndex index = model.index(path); + qDebug() << "Path" << path << "count" << model.rowCount(index) << "index" << index; + view.setModel(&model); + qDebug() << "After setModel" << index; QModelIndex index2 = model.index(path); + qDebug() << "A" << index << index2; QCOMPARE(index.data(), index2.data()); view.setRootIndex(index); index2 = model.index(path); + qDebug() << "B" << index << index2; QCOMPARE(index.data(), index2.data()); view.setCurrentIndex(index); index2 = model.index(path); + qDebug() << "C" << index << index2; QCOMPARE(index.data(), index2.data()); view.setSortingEnabled(true); index2 = model.index(path); + qDebug() << "After sorting" << index << index2; QCOMPARE(index.data(), index2.data()); } diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp index e7bb93f..502e983 100644 --- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp @@ -775,9 +775,11 @@ void tst_QDoubleSpinBox::editingFinished() layout->addWidget(box2); testFocusWidget->show(); + QApplication::setActiveWindow(testFocusWidget); QTest::qWait(10); - QTRY_VERIFY(box->isActiveWindow()); + QTRY_VERIFY(testFocusWidget->isActiveWindow()); box->setFocus(); + QTRY_VERIFY(box->hasFocus()); QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished())); diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 853bf88..71e38df 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -411,10 +411,14 @@ void tst_QFileInfo::absolutePath_data() QString drivePrefix; #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) drivePrefix = QDir::currentPath().left(2); + QString nonCurrentDrivePrefix = + drivePrefix.left(1).compare("X", Qt::CaseInsensitive) == 0 ? QString("Y:") : QString("X:"); // Make sure drive-relative paths return correct absolute paths (task 255326) - QTest::newRow("c:my.dll") << "c:my.dll" << QDir::currentPath() << "my.dll"; - QTest::newRow("x:my.dll") << "x:my.dll" << "X:/" << "my.dll"; + QTest::newRow("<current drive>:my.dll") << drivePrefix + "my.dll" << QDir::currentPath() << "my.dll"; + QTest::newRow("<not current drive>:my.dll") << nonCurrentDrivePrefix + "my.dll" + << nonCurrentDrivePrefix + "/" + << "my.dll"; #endif QTest::newRow("0") << "/machine/share/dir1/" << drivePrefix + "/machine/share/dir1" << ""; QTest::newRow("1") << "/machine/share/dir1" << drivePrefix + "/machine/share" << "dir1"; @@ -450,13 +454,19 @@ void tst_QFileInfo::absFilePath_data() QTest::newRow("relativeFileInSubDir") << "temp/tmp.txt" << QDir::currentPath() + "/" + "temp/tmp.txt"; #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QString curr = QDir::currentPath(); + curr.remove(0, 2); // Make it a absolute path with no drive specifier: \depot\qt-4.2\tests\auto\qfileinfo QTest::newRow(".") << curr << QDir::currentPath(); QTest::newRow("absFilePath") << "c:\\home\\andy\\tmp.txt" << "C:/home/andy/tmp.txt"; // Make sure drive-relative paths return correct absolute paths (task 255326) - QTest::newRow("c:my.dll") << "c:temp/my.dll" << QDir::currentPath() + "/temp/my.dll"; - QTest::newRow("x:my.dll") << "x:temp/my.dll" << "X:/temp/my.dll"; + QString drivePrefix = QDir::currentPath().left(2); + QString nonCurrentDrivePrefix = + drivePrefix.left(1).compare("X", Qt::CaseInsensitive) == 0 ? QString("Y:") : QString("X:"); + + QTest::newRow("<current drive>:my.dll") << drivePrefix + "temp/my.dll" << QDir::currentPath() + "/temp/my.dll"; + QTest::newRow("<not current drive>:my.dll") << nonCurrentDrivePrefix + "temp/my.dll" + << nonCurrentDrivePrefix + "/temp/my.dll"; #else QTest::newRow("absFilePath") << "/home/andy/tmp.txt" << "/home/andy/tmp.txt"; #endif diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index a0b8b5d..21f7359 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -683,8 +683,16 @@ void tst_QGL::openGLVersionCheck() // However, the complicated parts are in openGLVersionFlags(const QString &versionString) // tested above +#if defined(QT_OPENGL_ES_1) + QVERIFY(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Common_Version_1_0); +#elif defined(QT_OPENGL_ES_1_CL) + QVERIFY(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_CommonLite_Version_1_0); +#elif defined(QT_OPENGL_ES_2) + QVERIFY(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0); +#else QVERIFY(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_1); -#endif +#endif //defined(QT_OPENGL_ES_1) +#endif //QT_BUILD_INTERNAL } class UnclippedWidget : public QWidget @@ -959,6 +967,11 @@ void tst_QGL::multipleFBOInterleavedRendering() QVERIFY(fbo2Painter.begin(fbo2)); QVERIFY(fbo3Painter.begin(fbo3)); + // Confirm we're using the GL2 engine, as interleaved rendering isn't supported + // on the GL1 engine: + if (fbo1Painter.paintEngine()->type() != QPaintEngine::OpenGL2) + QSKIP("Interleaved GL rendering requires OpenGL 2.0 or higher", SkipSingle); + QPainterPath intersectingPath; intersectingPath.moveTo(0, 0); intersectingPath.lineTo(100, 0); diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 5bb3746..385fb3e 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -65,6 +65,8 @@ private slots: void setSpacing(); void hardComplexS60(); void delete_anchor(); + void conflicts(); + void sizePolicy(); }; class RectWidget : public QGraphicsWidget @@ -100,7 +102,7 @@ static void setAnchor(QGraphicsAnchorLayout *l, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge, - qreal spacing) + qreal spacing = 0) { QGraphicsAnchor *anchor = l->addAnchor(firstItem, firstEdge, secondItem, secondEdge); anchor->setSpacing(spacing); @@ -249,6 +251,11 @@ void tst_QGraphicsAnchorLayout::layoutDirection() QGraphicsWidget *b = createItem(min, pref, max, "b"); QGraphicsWidget *c = createItem(min, pref, QSizeF(100, 20), "c"); + a->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + b->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + c->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; l->setContentsMargins(0, 5, 10, 15); // horizontal @@ -1099,7 +1106,128 @@ void tst_QGraphicsAnchorLayout::delete_anchor() delete p; delete view; +} + +void tst_QGraphicsAnchorLayout::sizePolicy() +{ + QGraphicsScene scene; + QSizeF minSize(0, 0); + QSizeF prefSize(50, 50); + QSizeF maxSize(100, 100); + QGraphicsWidget *w1 = createItem(minSize, prefSize, maxSize, "w1"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setSpacing(0); + l->setContentsMargins(0, 0, 0, 0); + + // horizontal + QGraphicsAnchor *anchor = l->addAnchor(l, Qt::AnchorLeft, w1, Qt::AnchorLeft); + anchor->setSpacing(0); + + anchor = l->addAnchor(w1, Qt::AnchorRight, l, Qt::AnchorRight); + anchor->setSpacing(0); + + // vertical + anchor = l->addAnchor(l, Qt::AnchorTop, w1, Qt::AnchorTop); + anchor->setSpacing(0); + + anchor = l->addAnchor(w1, Qt::AnchorBottom, l, Qt::AnchorBottom); + anchor->setSpacing(0); + + QGraphicsWidget *p = new QGraphicsWidget; + p->setLayout(l); + + scene.addItem(p); + QGraphicsView *view = new QGraphicsView(&scene); + + // QSizePolicy::Minimum + w1->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + QApplication::processEvents(); + w1->adjustSize(); + + QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(50, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(50, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(100, 100)); + + // QSizePolicy::Maximum + w1->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); + QApplication::processEvents(); + w1->adjustSize(); + + QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(0, 0)); + QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(50, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(50, 50)); + + // QSizePolicy::Fixed + w1->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + QApplication::processEvents(); + w1->adjustSize(); + + QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(50, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(50, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(50, 50)); + + // QSizePolicy::Preferred + w1->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + QApplication::processEvents(); + w1->adjustSize(); + + QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(0, 0)); + QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(50, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(100, 100)); + + // QSizePolicy::Ignored + w1->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + QApplication::processEvents(); + w1->adjustSize(); + + QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(0, 0)); + QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(0, 0)); + QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(100, 100)); + + delete p; + delete view; +} + +void tst_QGraphicsAnchorLayout::conflicts() +{ + QGraphicsWidget *a = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "a"); + QGraphicsWidget *b = createItem(QSizeF(10,10), QSizeF(20,10), QSizeF(30,10), "b"); + QGraphicsWidget *c = createItem(QSizeF(10,10), QSizeF(20,10), QSizeF(30,10), "c"); + + QGraphicsAnchorLayout *l; + QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window); + + l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + // with the following setup, 'a' cannot be larger than 30 we will first have a Simplex conflict + + // horizontal + setAnchor(l, l, Qt::AnchorLeft, b, Qt::AnchorLeft); + setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft); + setAnchor(l, c, Qt::AnchorRight, l, Qt::AnchorRight); + setAnchor(l, b, Qt::AnchorHorizontalCenter, a, Qt::AnchorLeft); + setAnchor(l, a, Qt::AnchorRight, c, Qt::AnchorHorizontalCenter); + + // vertical + setAnchor(l, l, Qt::AnchorTop, a, Qt::AnchorTop); + setAnchor(l, a, Qt::AnchorBottom, b, Qt::AnchorTop); + setAnchor(l, a, Qt::AnchorBottom, c, Qt::AnchorTop); + setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom); + setAnchor(l, c, Qt::AnchorBottom, l, Qt::AnchorBottom); + + p->setLayout(l); + + QCOMPARE(l->hasConflicts(), true); + + a->setMinimumSize(QSizeF(29,10)); + QCOMPARE(l->hasConflicts(), false); + // It will currently fail if we uncomment this: + //QEXPECT_FAIL("", "The constraints are just within their bounds in order to be feasible", Continue); + //a->setMinimumSize(QSizeF(30,10)); + //QCOMPARE(l->hasConflicts(), false); } QTEST_MAIN(tst_QGraphicsAnchorLayout) diff --git a/tests/auto/qgraphicsanchorlayout1/qgraphicsanchorlayout1.pro b/tests/auto/qgraphicsanchorlayout1/qgraphicsanchorlayout1.pro new file mode 100644 index 0000000..27f48e0 --- /dev/null +++ b/tests/auto/qgraphicsanchorlayout1/qgraphicsanchorlayout1.pro @@ -0,0 +1,3 @@ +load(qttest_p4) +SOURCES += tst_qgraphicsanchorlayout1.cpp + diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp new file mode 100644 index 0000000..8228ab9 --- /dev/null +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -0,0 +1,3096 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> +#include <QtTest/QtTest> +#include <QTest> +#include <QMetaType> +#include <QGraphicsAnchorLayout> + +#define TEST_COMPLEX_CASES + + +//---------------------- AnchorLayout helper class ---------------------------- +class TheAnchorLayout : public QGraphicsAnchorLayout +{ +public: + TheAnchorLayout() : QGraphicsAnchorLayout() + { + setContentsMargins( 0,0,0,0 ); + setSpacing( 0 ); + } + + // ###: Remove me when isValid() is supported + bool isValid() + { + return true; + } + + void setAnchor( + QGraphicsLayoutItem *startItem, + Qt::AnchorPoint startEdge, + QGraphicsLayoutItem *endItem, + Qt::AnchorPoint endEdge, + qreal value) + { + QGraphicsAnchor *anchor = addAnchor( startItem, startEdge, endItem, endEdge); + if (anchor) + anchor->setSpacing(value); + } + + int indexOf(const QGraphicsLayoutItem* item) const + { + for ( int i=0; i< count(); i++) { + if ( itemAt(i) == item ) { + return i; + } + } + return -1; + } + + void removeItem(QGraphicsLayoutItem* item) + { + removeAt(indexOf(item)); + } + + void removeAnchor( + QGraphicsLayoutItem *startItem, + Qt::AnchorPoint startEdge, + QGraphicsLayoutItem *endItem, + Qt::AnchorPoint endEdge) + { + delete QGraphicsAnchorLayout::anchor(startItem, startEdge, endItem, endEdge); + } +}; +//----------------------------------------------------------------------------- + + +struct BasicLayoutTestData +{ + inline BasicLayoutTestData( + int index1, Qt::AnchorPoint edge1, + int index2, Qt::AnchorPoint edge2, + qreal distance) + : firstIndex(index1), firstEdge(edge1), + secondIndex(index2), secondEdge(edge2), + spacing(distance) + { + } + + int firstIndex; + Qt::AnchorPoint firstEdge; + int secondIndex; + Qt::AnchorPoint secondEdge; + qreal spacing; +}; + +struct AnchorItemSizeHint +{ + inline AnchorItemSizeHint( + qreal hmin, qreal hpref, qreal hmax, + qreal vmin, qreal vpref, qreal vmax ) + : hmin(hmin), hpref(hpref), hmax(hmax), vmin(vmin), vpref(vpref), vmax(vmax) + { + } + qreal hmin, hpref, hmax; + qreal vmin, vpref, vmax; +}; + +// some test results + +struct BasicLayoutTestResult +{ + inline BasicLayoutTestResult( + int resultIndex, const QRectF& resultRect ) + : index(resultIndex), rect(resultRect) + { + } + + int index; + QRectF rect; +}; + +typedef QList<BasicLayoutTestData> BasicLayoutTestDataList; +Q_DECLARE_METATYPE(BasicLayoutTestDataList) + +typedef QList<BasicLayoutTestResult> BasicLayoutTestResultList; +Q_DECLARE_METATYPE(BasicLayoutTestResultList) + +typedef QList<AnchorItemSizeHint> AnchorItemSizeHintList; +Q_DECLARE_METATYPE(AnchorItemSizeHintList) + + +//---------------------- Test Widget used on all tests ------------------------ +class TestWidget : public QGraphicsWidget +{ +public: + inline TestWidget(QGraphicsItem *parent = 0) + : QGraphicsWidget(parent) + { + setContentsMargins( 0,0,0,0 ); + } + ~TestWidget() + { + } + +protected: + QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; +}; + +QSizeF TestWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ + Q_UNUSED( constraint ); + if (which == Qt::MinimumSize) { + return QSizeF(5,5); + } + + if (which == Qt::PreferredSize) { + return QSizeF(50,50); + } + + return QSizeF(500,500); +} +//----------------------------------------------------------------------------- + + + +//----------------------------- Test class ------------------------------------ +class tst_QGraphicsAnchorLayout1 : public QObject +{ + Q_OBJECT + +private slots: + void testCount(); + + void testRemoveAt(); + void testRemoveItem(); + + void testItemAt(); + void testIndexOf(); + + void testAddAndRemoveAnchor(); + void testIsValid(); + void testSpecialCases(); + + void testBasicLayout_data(); + void testBasicLayout(); + + void testNegativeSpacing_data(); + void testNegativeSpacing(); + + void testMixedSpacing_data(); + void testMixedSpacing(); + + void testMulti_data(); + void testMulti(); + + void testCenterAnchors_data(); + void testCenterAnchors(); + + void testRemoveCenterAnchor_data(); + void testRemoveCenterAnchor(); + + void testSingleSizePolicy_data(); + void testSingleSizePolicy(); + + void testDoubleSizePolicy_data(); + void testDoubleSizePolicy(); + + void testSizeDistribution_data(); + void testSizeDistribution(); + + void testSizeHint(); + +#ifdef TEST_COMPLEX_CASES + void testComplexCases_data(); + void testComplexCases(); +#endif +}; + + +void tst_QGraphicsAnchorLayout1::testCount() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + + TheAnchorLayout *layout = new TheAnchorLayout(); + QVERIFY( layout->count() == 0 ); + + TestWidget *widget1 = new TestWidget(); + layout->setAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 1); + QCOMPARE( layout->count(), 1 ); + + // adding one more anchor for already added widget should not increase the count + layout->setAnchor(layout, Qt::AnchorRight, widget1, Qt::AnchorRight, 1); + QCOMPARE( layout->count(), 1 ); + + // create one more widget and attach with anchor layout + TestWidget *widget2 = new TestWidget(); + layout->setAnchor(layout, Qt::AnchorLeft, widget2, Qt::AnchorLeft, 1); + QCOMPARE( layout->count(), 2 ); + + widget->setLayout(layout); + delete widget; +} + +void tst_QGraphicsAnchorLayout1::testRemoveAt() +{ + TheAnchorLayout *layout = new TheAnchorLayout(); + QVERIFY( layout->count() == 0 ); + + TestWidget *widget1 = new TestWidget(); + layout->setAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 2); + QVERIFY( layout->count() == 1 ); + + TestWidget *widget2 = new TestWidget(); + layout->setAnchor(widget2, Qt::AnchorLeft, layout, Qt::AnchorLeft, 0.1); + QVERIFY( layout->count() == 2 ); + + layout->removeAt(0); + QVERIFY( layout->count() == 1 ); + + layout->removeAt(-55); + layout->removeAt(55); + QVERIFY( layout->count() == 1 ); + + layout->removeAt(0); + QVERIFY( layout->count() == 0 ); + + delete layout; + delete widget1; + delete widget2; +} + +void tst_QGraphicsAnchorLayout1::testRemoveItem() +{ + TheAnchorLayout *layout = new TheAnchorLayout(); + QCOMPARE( layout->count(), 0 ); + + TestWidget *widget1 = new TestWidget(); + layout->setAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 2); + QCOMPARE( layout->count(), 1 ); + + TestWidget *widget2 = new TestWidget(); + layout->setAnchor(layout, Qt::AnchorLeft, widget2, Qt::AnchorLeft, 0.1); + QCOMPARE( layout->count(), 2 ); + + layout->removeItem(0); + QCOMPARE( layout->count(), 2 ); + + layout->removeItem(widget1); + QCOMPARE( layout->count(), 1 ); + QCOMPARE( layout->indexOf(widget1), -1 ); + QCOMPARE( layout->indexOf(widget2), 0 ); + + layout->removeItem(widget1); + QCOMPARE( layout->count(), 1 ); + + layout->removeItem(widget2); + QVERIFY( layout->count() == 0 ); + + delete layout; + delete widget1; + delete widget2; +} + +void tst_QGraphicsAnchorLayout1::testItemAt() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + + TheAnchorLayout *layout = new TheAnchorLayout(); + + TestWidget *widget1 = new TestWidget(); + TestWidget *widget2 = new TestWidget(); + TestWidget *widget3 = new TestWidget(); + TestWidget *widget4 = new TestWidget(); + + layout->setAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 0.1); + layout->setAnchor(layout, Qt::AnchorLeft, widget2, Qt::AnchorLeft, 0.1); + layout->setAnchor(layout, Qt::AnchorLeft, widget3, Qt::AnchorLeft, 0.1); + layout->setAnchor(layout, Qt::AnchorLeft, widget4, Qt::AnchorLeft, 0.1); + + QVERIFY( layout->itemAt(0) == widget1 ); + + layout->removeAt(0); + + QVERIFY( layout->itemAt(0) == widget2 ); + + widget->setLayout(layout); + delete widget; +} + +void tst_QGraphicsAnchorLayout1::testIndexOf() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + + TheAnchorLayout *layout = new TheAnchorLayout(); + + TestWidget *widget1 = new TestWidget(); + TestWidget *widget2 = new TestWidget(); + TestWidget *widget3 = new TestWidget(); + TestWidget *widget4 = new TestWidget(); + + QCOMPARE( layout->indexOf(widget1), -1 ); + + layout->setAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 0.1); + layout->setAnchor(layout, Qt::AnchorLeft, widget2, Qt::AnchorLeft, 0.1); + layout->setAnchor(layout, Qt::AnchorLeft, widget3, Qt::AnchorLeft, 0.1); + + QCOMPARE( layout->indexOf(widget4), -1 ); + layout->setAnchor(layout, Qt::AnchorLeft, widget4, Qt::AnchorLeft, 0.1); + + QCOMPARE( layout->count(), 4 ); + for (int i = 0; i < layout->count(); ++i) { + QCOMPARE(layout->indexOf(layout->itemAt(i)), i); + } + + QCOMPARE( layout->indexOf(0), -1 ); + widget->setLayout(layout); + delete widget; +} + +void tst_QGraphicsAnchorLayout1::testAddAndRemoveAnchor() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + + TheAnchorLayout *layout = new TheAnchorLayout(); + + TestWidget *widget1 = new TestWidget(); + TestWidget *widget2 = new TestWidget(); + TestWidget *widget3 = new TestWidget(); + TestWidget *widget4 = new TestWidget(); + TestWidget *widget5 = new TestWidget(); + + layout->setAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 0.1); + layout->setAnchor(layout, Qt::AnchorLeft, widget2, Qt::AnchorLeft, 0.5); + layout->setAnchor(layout, Qt::AnchorLeft, widget3, Qt::AnchorLeft, 10); + layout->setAnchor(layout, Qt::AnchorLeft, widget4, Qt::AnchorLeft, 0.1); + QCOMPARE( layout->count(), 4 ); + + // test setting invalid anchors + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor NULL items"); + layout->setAnchor(0, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 1); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor NULL items"); + layout->setAnchor(layout, Qt::AnchorLeft, 0, Qt::AnchorLeft, 1); + QCOMPARE( layout->count(), 4 ); + + // test removing invalid anchors + layout->removeAnchor(widget4, Qt::AnchorRight, widget1, Qt::AnchorRight); + + // anchor one horizontal edge with vertical edge. it should not add this widget as a child + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor edges of different orientations"); + layout->setAnchor(layout, Qt::AnchorLeft, widget5, Qt::AnchorTop, 10); + QCOMPARE( layout->count(), 4 ); + + // ###: NOT SUPPORTED + // anchor two edges of a widget (to define width / height) + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + layout->setAnchor(widget5, Qt::AnchorLeft, widget5, Qt::AnchorRight, 10); + // QCOMPARE( layout->count(), 5 ); + QCOMPARE( layout->count(), 4 ); + + // anchor yet new widget properly + layout->setAnchor(layout, Qt::AnchorRight, widget5, Qt::AnchorRight, 20 ); + QCOMPARE( layout->count(), 5 ); + + // remove anchor for widget1. widget1 should be removed from layout since the + // last anchor was removed. + layout->removeAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft); + + QCOMPARE( layout->count(), 4 ); + QCOMPARE( (int)widget1->parentLayoutItem(), 0 ); + + // test that item is not removed from layout if other anchors remain set + layout->setAnchor(widget2, Qt::AnchorLeft, widget3, Qt::AnchorRight, 10); + layout->removeAnchor(layout, Qt::AnchorLeft, widget2, Qt::AnchorLeft); + QCOMPARE( layout->count(), 4 ); + + // remove all the anchors + layout->removeAnchor(widget2, Qt::AnchorLeft, widget3, Qt::AnchorRight); + layout->removeAnchor(layout, Qt::AnchorLeft, widget3, Qt::AnchorLeft); + layout->removeAnchor(layout, Qt::AnchorLeft, widget4, Qt::AnchorLeft); + layout->removeAnchor(widget5, Qt::AnchorLeft, widget5, Qt::AnchorRight); + layout->removeAnchor(layout, Qt::AnchorRight, widget5, Qt::AnchorRight); + + QCOMPARE( layout->count(), 0 ); + + // set one anchor "another way round" to get full coverage for "removeAnchor" + layout->setAnchor(widget1, Qt::AnchorLeft, layout, Qt::AnchorLeft, 0.1); + layout->removeAnchor(widget1, Qt::AnchorLeft, layout, Qt::AnchorLeft); + + QCOMPARE( layout->count(), 0 ); + + widget->setLayout(layout); + delete widget; +} + +void tst_QGraphicsAnchorLayout1::testIsValid() +{ + // ###: REMOVE ME + return; + + // Empty, valid + { + QGraphicsWidget *widget = new QGraphicsWidget; + TheAnchorLayout *layout = new TheAnchorLayout(); + widget->setLayout(layout); + widget->setGeometry(QRectF(0,0,100,100)); + + QCOMPARE(layout->isValid(), true); + delete widget; + } + + // One widget, valid + { + QGraphicsWidget *widget = new QGraphicsWidget; + TheAnchorLayout *layout = new TheAnchorLayout(); + + TestWidget *widget1 = new TestWidget(); + + layout->setAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 0.1); + layout->setAnchor(layout, Qt::AnchorTop, widget1, Qt::AnchorTop, 0.1); + layout->setAnchor(widget1, Qt::AnchorRight, layout, Qt::AnchorRight, 0.1); + layout->setAnchor(widget1, Qt::AnchorBottom, layout, Qt::AnchorBottom, 0.1); + + widget->setLayout(layout); + + widget->setGeometry(QRectF(0,0,100,100)); + QCOMPARE(layout->isValid(), true); + delete widget; + } + + // Overconstrained one widget, invalid + // ### Our understanding is that this case is valid. What happens though, + // is that the layout minimum and maximum vertical size hints become + // the same, 10.1. That means its height is fixed. + // What will "fail" then is the "setGeometry(0, 0, 100, 100)" call, + // after which the layout geometry will be (0, 0, 100, 10.1). + + { + QGraphicsWidget *widget = new QGraphicsWidget; + TheAnchorLayout *layout = new TheAnchorLayout(); + + TestWidget *widget1 = new TestWidget(); + + layout->setAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 0.1); + layout->setAnchor(layout, Qt::AnchorTop, widget1, Qt::AnchorTop, 0.1); + layout->setAnchor(widget1, Qt::AnchorRight, layout, Qt::AnchorRight, 0.1); + layout->setAnchor(widget1, Qt::AnchorBottom, layout, Qt::AnchorBottom, 0.1); + + layout->setAnchor(widget1, Qt::AnchorTop, layout, Qt::AnchorBottom, 10); + + widget->setLayout(layout); + + widget->setGeometry(QRectF(0,0,100,100)); + // ###: this shall change once isValid() is ready + // QCOMPARE(layout->isValid(), false); + QCOMPARE(layout->isValid(), true); + delete widget; + } + + // Underconstrained two widgets, valid + { + QGraphicsWidget *widget = new QGraphicsWidget; + TheAnchorLayout *layout = new TheAnchorLayout(); + + TestWidget *widget1 = new TestWidget(); + TestWidget *widget2 = new TestWidget(); + + layout->setAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 0.1); + layout->setAnchor(layout, Qt::AnchorRight, widget1, Qt::AnchorRight, -0.1); + + layout->setAnchor(layout, Qt::AnchorTop, widget2, Qt::AnchorTop, 0.1); + layout->setAnchor(layout, Qt::AnchorBottom, widget2, Qt::AnchorBottom, -0.1); + + widget->setLayout(layout); + + widget->setGeometry(QRectF(0,0,100,100)); + QCOMPARE(layout->isValid(), true); + delete widget; + } +} + +void tst_QGraphicsAnchorLayout1::testSpecialCases() +{ + // One widget, setLayout before defining layouts + { +#ifdef QT_DEBUG + QTest::ignoreMessage(QtWarningMsg, "QGraphicsLayout::addChildLayoutItem: QGraphicsWidget \"\"" + " in wrong parent; moved to correct parent"); +#endif + QGraphicsWidget *widget = new QGraphicsWidget; + TheAnchorLayout *layout = new TheAnchorLayout(); + widget->setLayout(layout); + + TestWidget *widget1 = new TestWidget(); + + layout->setAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 1); + layout->setAnchor(layout, Qt::AnchorTop, widget1, Qt::AnchorTop, 1); + layout->setAnchor(widget1, Qt::AnchorRight, layout, Qt::AnchorRight, 1); + layout->setAnchor(widget1, Qt::AnchorBottom, layout, Qt::AnchorBottom, 1); + widget->setGeometry(QRectF(0,0,100,100)); + QCOMPARE(widget1->geometry(), QRectF(1,1,98,98)); + delete widget1; + delete widget; + } + + // One widget, layout inside layout, layout inside layout inside layout + { +#ifdef QT_DEBUG + QTest::ignoreMessage(QtWarningMsg, "QGraphicsLayout::addChildLayoutItem: QGraphicsWidget \"\"" + " in wrong parent; moved to correct parent"); +#endif + QGraphicsWidget *widget = new QGraphicsWidget; + TheAnchorLayout *layout = new TheAnchorLayout(); + widget->setLayout(layout); + + TheAnchorLayout *layout1 = new TheAnchorLayout(); + TestWidget *widget1 = new TestWidget(); + layout1->setAnchor(layout1, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 1); + layout1->setAnchor(layout1, Qt::AnchorTop, widget1, Qt::AnchorTop, 1); + layout1->setAnchor(widget1, Qt::AnchorRight, layout1, Qt::AnchorRight, 1); + layout1->setAnchor(widget1, Qt::AnchorBottom, layout1, Qt::AnchorBottom, 1); + + TheAnchorLayout *layout2 = new TheAnchorLayout(); + TestWidget *widget2 = new TestWidget(); + layout2->setAnchor(layout2, Qt::AnchorLeft, widget2, Qt::AnchorLeft, 1); + layout2->setAnchor(layout2, Qt::AnchorTop, widget2, Qt::AnchorTop, 1); + layout2->setAnchor(widget2, Qt::AnchorRight, layout2, Qt::AnchorRight, 1); + layout2->setAnchor(widget2, Qt::AnchorBottom, layout2, Qt::AnchorBottom, 1); + + layout1->setAnchor(layout1, Qt::AnchorLeft, layout2, Qt::AnchorLeft, 1); + layout1->setAnchor(layout1, Qt::AnchorTop, layout2, Qt::AnchorTop, 1); + layout1->setAnchor(layout2, Qt::AnchorRight, layout1, Qt::AnchorRight, 1); + layout1->setAnchor(layout2, Qt::AnchorBottom, layout1, Qt::AnchorBottom, 1); + + layout->setAnchor(layout, Qt::AnchorLeft, layout1, Qt::AnchorLeft, 1); + layout->setAnchor(layout, Qt::AnchorTop, layout1, Qt::AnchorTop, 1); + layout->setAnchor(layout1, Qt::AnchorRight, layout, Qt::AnchorRight, 1); + layout->setAnchor(layout1, Qt::AnchorBottom, layout, Qt::AnchorBottom, 1); + + // remove and add again to improve test coverage. + layout->removeItem(layout1); + + layout->setAnchor(layout, Qt::AnchorLeft, layout1, Qt::AnchorLeft, 1); + layout->setAnchor(layout, Qt::AnchorTop, layout1, Qt::AnchorTop, 1); + layout->setAnchor(layout1, Qt::AnchorRight, layout, Qt::AnchorRight, 1); + layout->setAnchor(layout1, Qt::AnchorBottom, layout, Qt::AnchorBottom, 1); + + widget->setGeometry(QRectF(0,0,100,100)); + QCOMPARE(widget1->geometry(), QRectF(2,2,96,96)); + QCOMPARE(widget2->geometry(), QRectF(3,3,94,94)); + delete widget; + } + + // One widget, layout inside layout, setLayout after layout definition + { + QGraphicsWidget *widget = new QGraphicsWidget; + TheAnchorLayout *layout = new TheAnchorLayout(); + + TheAnchorLayout *layout1 = new TheAnchorLayout(); + + TestWidget *widget1 = new TestWidget(); + layout1->setAnchor(layout1, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 1); + layout1->setAnchor(layout1, Qt::AnchorTop, widget1, Qt::AnchorTop, 1); + layout1->setAnchor(widget1, Qt::AnchorRight, layout1, Qt::AnchorRight, 1); + layout1->setAnchor(widget1, Qt::AnchorBottom, layout1, Qt::AnchorBottom, 1); + + layout->setAnchor(layout, Qt::AnchorLeft, layout1, Qt::AnchorLeft, 1); + layout->setAnchor(layout, Qt::AnchorTop, layout1, Qt::AnchorTop, 1); + layout->setAnchor(layout1, Qt::AnchorRight, layout, Qt::AnchorRight, 1); + layout->setAnchor(layout1, Qt::AnchorBottom, layout, Qt::AnchorBottom, 1); + + widget->setLayout(layout); + widget->setGeometry(QRectF(0,0,100,100)); + QCOMPARE(widget1->geometry(), QRectF(2,2,96,96)); + delete widget; + } + + // One widget, layout inside layout, setLayout after layout definition, widget transferred from + // one layout to another + { + QGraphicsWidget *widget = new QGraphicsWidget; + TheAnchorLayout *layout = new TheAnchorLayout(); + widget->setLayout(layout); + + TheAnchorLayout *layout1 = new TheAnchorLayout(); + TestWidget *widget1 = new TestWidget(); + + // Additional layout + widget to improve coverage. + TheAnchorLayout *layout0 = new TheAnchorLayout(); + TestWidget *widget0 = new TestWidget(); + + // widget0 to layout0 + layout0->setAnchor(layout0, Qt::AnchorLeft, widget0, Qt::AnchorLeft, 1); + layout0->setAnchor(layout0, Qt::AnchorTop, widget0, Qt::AnchorTop, 1); + layout0->setAnchor(widget0, Qt::AnchorRight, layout0, Qt::AnchorRight, 1); + layout0->setAnchor(widget0, Qt::AnchorBottom, layout0, Qt::AnchorBottom, 1); + + // layout0 to layout + layout->setAnchor(layout, Qt::AnchorLeft, layout0, Qt::AnchorLeft, 1); + layout->setAnchor(layout, Qt::AnchorTop, layout0, Qt::AnchorTop, 1); + layout->setAnchor(layout0, Qt::AnchorRight, layout, Qt::AnchorRight, 50); + layout->setAnchor(layout0, Qt::AnchorBottom, layout, Qt::AnchorBottom, 1); + + // widget1 to layout1 + layout1->setAnchor(layout1, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 1); + layout1->setAnchor(layout1, Qt::AnchorTop, widget1, Qt::AnchorTop, 1); + layout1->setAnchor(widget1, Qt::AnchorRight, layout1, Qt::AnchorRight, 1); + layout1->setAnchor(widget1, Qt::AnchorBottom, layout1, Qt::AnchorBottom, 1); + + // layout1 to layout + layout->setAnchor(layout, Qt::AnchorLeft, layout1, Qt::AnchorLeft, 1); + layout->setAnchor(layout, Qt::AnchorTop, layout1, Qt::AnchorTop, 1); + layout->setAnchor(layout1, Qt::AnchorRight, layout, Qt::AnchorRight, 50); + layout->setAnchor(layout1, Qt::AnchorBottom, layout, Qt::AnchorBottom, 1); + + TheAnchorLayout *layout2 = new TheAnchorLayout(); + + // layout2 to layout + layout->setAnchor(layout, Qt::AnchorLeft, layout2, Qt::AnchorLeft, 50); + layout->setAnchor(layout, Qt::AnchorTop, layout2, Qt::AnchorTop, 1); + layout->setAnchor(layout2, Qt::AnchorRight, layout, Qt::AnchorRight, 1); + layout->setAnchor(layout2, Qt::AnchorBottom, layout, Qt::AnchorBottom, 1); + + // transfer widget1 to layout2 + layout2->setAnchor(layout2, Qt::AnchorLeft, widget1, Qt::AnchorLeft, 1); + layout2->setAnchor(layout2, Qt::AnchorTop, widget1, Qt::AnchorTop, 1); + layout2->setAnchor(widget1, Qt::AnchorRight, layout2, Qt::AnchorRight, 1); + layout2->setAnchor(widget1, Qt::AnchorBottom, layout2, Qt::AnchorBottom, 1); + + // ###: uncomment when simplification bug is solved + //widget->setGeometry(QRectF(0,0,100,100)); + //QCOMPARE(widget1->geometry(), QRectF(51,2,47,96)); + delete widget; + } + + // One widget, set first to one layout then to another. Child reparented. + // In addition widget as a direct child of another widget. Child reparented. + { + QGraphicsWidget *widget1 = new QGraphicsWidget; + TheAnchorLayout *layout1 = new TheAnchorLayout(); + widget1->setLayout(layout1); + + TestWidget *childWidget = new TestWidget(); + + // childWidget to layout1 + layout1->setAnchor(layout1, Qt::AnchorLeft, childWidget, Qt::AnchorLeft, 1); + layout1->setAnchor(layout1, Qt::AnchorTop, childWidget, Qt::AnchorTop, 1); + layout1->setAnchor(childWidget, Qt::AnchorRight, layout1, Qt::AnchorRight, 1); + layout1->setAnchor(childWidget, Qt::AnchorBottom, layout1, Qt::AnchorBottom, 1); + + widget1->setGeometry(QRectF(0,0,100,100)); + QCOMPARE(childWidget->geometry(), QRectF(1,1,98,98)); + QVERIFY(childWidget->parentLayoutItem() == layout1); + QGraphicsWidget *widget2 = new QGraphicsWidget; + TheAnchorLayout *layout2 = new TheAnchorLayout(); + widget2->setLayout(layout2); + + // childWidget to layout2 + layout2->setAnchor(layout2, Qt::AnchorLeft, childWidget, Qt::AnchorLeft, 1); + layout2->setAnchor(layout2, Qt::AnchorTop, childWidget, Qt::AnchorTop, 1); + layout2->setAnchor(childWidget, Qt::AnchorRight, layout2, Qt::AnchorRight, 1); + layout2->setAnchor(childWidget, Qt::AnchorBottom, layout2, Qt::AnchorBottom, 1); + + QGraphicsWidget *widget3 = new QGraphicsWidget; + QGraphicsWidget *widget4 = new QGraphicsWidget; + // widget4 is a direct child of widget3 (i.e. not in any layout) + widget4->setParentItem(widget3); + + // widget4 to layout2 + layout2->setAnchor(layout2, Qt::AnchorLeft, widget4, Qt::AnchorLeft, 1); + layout2->setAnchor(layout2, Qt::AnchorTop, widget4, Qt::AnchorTop, 1); + layout2->setAnchor(widget4, Qt::AnchorRight, layout2, Qt::AnchorRight, 1); + layout2->setAnchor(widget4, Qt::AnchorBottom, layout2, Qt::AnchorBottom, 1); + + widget2->setGeometry(QRectF(0,0,100,100)); + QCOMPARE(childWidget->geometry(), QRectF(1,1,98,98)); + QVERIFY(childWidget->parentLayoutItem() == layout2); + QCOMPARE(widget4->geometry(), QRectF(1,1,98,98)); + QVERIFY(widget4->parentLayoutItem() == layout2); + QVERIFY(widget4->parentItem() == widget2); + + delete widget4; + delete widget3; + delete widget1; + delete childWidget; + delete widget2; + } +} + +void tst_QGraphicsAnchorLayout1::testBasicLayout_data() +{ + QTest::addColumn<QSizeF>("size"); + QTest::addColumn<BasicLayoutTestDataList>("data"); + QTest::addColumn<BasicLayoutTestResultList>("result"); + + typedef BasicLayoutTestData BasicData; + typedef BasicLayoutTestResult BasicResult; + + // One widget, basic + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 20) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 30) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 40) + ; + + theResult + << BasicResult(0, QRectF(20, 10, 150, 50) ) + ; + + QTest::newRow("One, simple") << QSizeF(200, 100) << theData << theResult; + } + + // One widget, duplicates + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 20) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 30) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 40) + + << BasicData(0, Qt::AnchorTop, -1, Qt::AnchorTop, 0) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 0) + << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorRight, 0) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 0) + ; + + theResult + << BasicResult(0, QRectF(0, 0, 200, 100) ) + ; + + QTest::newRow("One, duplicates") << QSizeF(200, 100) << theData << theResult; + } + + // One widget, mixed + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorBottom, 80) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorRight, 150) + << BasicData(0, Qt::AnchorLeft, -1, Qt::AnchorRight, 150) + << BasicData(0, Qt::AnchorTop, -1, Qt::AnchorBottom, 80) + ; + + theResult + << BasicResult(0, QRectF(50, 20, 100, 60) ) + ; + + QTest::newRow("One, mixed") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets (same layout), different ordering + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + + << BasicData(1, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorLeft, 10) + << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 10) + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + ; + + theResult + << BasicResult(0, QRectF(10, 10, 180, 80) ) + << BasicResult(1, QRectF(10, 10, 180, 80) ) + ; + + QTest::newRow("Two, orderings") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, duplicate anchors + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 30) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 20) + + << BasicData(1, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorLeft, 10) + << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 10) + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(1, Qt::AnchorTop, -1, Qt::AnchorTop, 0) + << BasicData(-1, Qt::AnchorRight, 1, Qt::AnchorRight, 0) + ; + + theResult + << BasicResult(0, QRectF(30, 10, 160, 70) ) + << BasicResult(1, QRectF(10, 0, 190, 90) ) + ; + + QTest::newRow("Two, duplicates") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, mixed + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorBottom, 90) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorRight, 190) + << BasicData(0, Qt::AnchorLeft, -1, Qt::AnchorRight, 190) + << BasicData(0, Qt::AnchorTop, -1, Qt::AnchorBottom, 90) + + << BasicData(1, Qt::AnchorTop, -1, Qt::AnchorBottom, 20) + << BasicData(1, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorLeft, 10) + << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorRight, 20) + ; + + // ### SIMPLIFICATION BUG FOR ITEM 1 + // ### remove this when bug is solved + + theResult + << BasicResult(0, QRectF(10, 10, 180, 80) ) + << BasicResult(1, QRectF(10, 80, 10, 10) ) + ; + + QTest::newRow("Two, mixed") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, 1 horizontal connection, first completely defined + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 180) + + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorLeft, 10) + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 10) + << BasicData(1, Qt::AnchorBottom, -1, Qt::AnchorBottom, 20) + ; + + theResult + << BasicResult(0, QRectF(10, 10, 10, 80) ) + << BasicResult(1, QRectF(30, 10, 160, 70) ) + ; + + QTest::newRow("Two, 1h connected") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, 2 horizontal connections, first completely defined + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 180) + + // ### QGAL is not sensible to the argument order in this case + // To achieve the desired result we must explicitly set a negative + // spacing. + // << BasicData(0, Qt::AnchorLeft, 1, Qt::AnchorRight, 100) + << BasicData(0, Qt::AnchorLeft, 1, Qt::AnchorRight, -100) + + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorLeft, 30) + << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 10) + << BasicData(1, Qt::AnchorBottom, -1, Qt::AnchorBottom, 20) + ; + + theResult + << BasicResult(0, QRectF(10, 10, 10, 80) ) + << BasicResult(1, QRectF(50, 10, 60, 70) ) + ; + + QTest::newRow("Two, 2h connected") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, 1 vertical connection, first completely defined + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 180) + + << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorLeft, 30) + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(0, Qt::AnchorTop, 1, Qt::AnchorTop, 10) + << BasicData(1, Qt::AnchorBottom, -1, Qt::AnchorBottom, 20) + ; + + theResult + << BasicResult(0, QRectF(10, 10, 10, 80) ) + << BasicResult(1, QRectF(30, 20, 160, 60) ) + ; + + QTest::newRow("Two, 1v connected") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, 2 vertical connections, first completely defined + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 180) + + << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorLeft, 30) + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(0, Qt::AnchorTop, 1, Qt::AnchorTop, 10) + << BasicData(1, Qt::AnchorBottom, 0, Qt::AnchorBottom, 20) + ; + + theResult + << BasicResult(0, QRectF(10, 10, 10, 80) ) + << BasicResult(1, QRectF(30, 20, 160, 50) ) + ; + + QTest::newRow("Two, 2v connected") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, 1 horizontal and 1 vertical connection, first completely defined + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 180) + + << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorLeft, 80) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorRight, 100) + << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 10) + << BasicData(1, Qt::AnchorBottom, 0, Qt::AnchorBottom, 10) + ; + + theResult + << BasicResult(0, QRectF(10, 10, 10, 80) ) + << BasicResult(1, QRectF(80, 10, 40, 70) ) + ; + + QTest::newRow("Two, 1h+1v connected") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, 2 horizontal and 2 vertical connections, first completely defined + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 180) + + << BasicData(0, Qt::AnchorLeft, 1, Qt::AnchorLeft, 80) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorRight, 100) + << BasicData(0, Qt::AnchorTop, 1, Qt::AnchorTop, 10) + << BasicData(1, Qt::AnchorBottom, 0, Qt::AnchorBottom, 10) + ; + + theResult + << BasicResult(0, QRectF(10, 10, 10, 80) ) + << BasicResult(1, QRectF(90, 20, 30, 60) ) + ; + + QTest::newRow("Two, 2h+2v connected") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, 2 horizontal and 2 vertical connections, dependent on each other. + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorRight, 150) + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(0, Qt::AnchorBottom, 1, Qt::AnchorBottom, 10) + + << BasicData(0, Qt::AnchorLeft, 1, Qt::AnchorLeft, 90) + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(0, Qt::AnchorTop, 1, Qt::AnchorTop, 10) + << BasicData(1, Qt::AnchorBottom, -1, Qt::AnchorBottom, 20) + ; + + theResult + << BasicResult(0, QRectF(10, 10, 30, 60) ) + << BasicResult(1, QRectF(100, 20, 90, 60) ) + ; + + QTest::newRow("Two, 2h+2v connected2") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, connected, overlapping + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + // << BasicData(1, Qt::AnchorLeft, 0, Qt::AnchorRight, 30) + // ### QGAL has different semantics and assumes right edges are always + // to the left of left edges. Thus we need the minus sign here. + << BasicData(1, Qt::AnchorLeft, 0, Qt::AnchorRight, -30) + << BasicData(0, Qt::AnchorBottom, 1, Qt::AnchorBottom, 40) + + << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorLeft, 40) + << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 20) + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(1, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + ; + + theResult + << BasicResult(0, QRectF(10, 10, 60, 40) ) + << BasicResult(1, QRectF(40, 20, 150, 70) ) + ; + + QTest::newRow("Two, connected overlapping") << QSizeF(200, 100) << theData << theResult; + } +} + +void tst_QGraphicsAnchorLayout1::testNegativeSpacing_data() +{ + QTest::addColumn<QSizeF>("size"); + QTest::addColumn<BasicLayoutTestDataList>("data"); + QTest::addColumn<BasicLayoutTestResultList>("result"); + + typedef BasicLayoutTestData BasicData; + typedef BasicLayoutTestResult BasicResult; + + // One widget, negative spacing + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + /// ### QGAL assumes items are always inside the layout. + // In this case, the negative spacing would make the item + // grow beyond the layout edges, which is OK, but gives a + // different result. + // Changing the direction of anchors (-1 to 0 or vice-versa) + // has no effect in this case. + + theData + // << BasicData(0, Qt::AnchorTop, -1, Qt::AnchorTop, -10) + // << BasicData(0, Qt::AnchorLeft, -1, Qt::AnchorLeft, -20) + // << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorRight, -30) + // << BasicData(-1, Qt::AnchorBottom, 0, Qt::AnchorBottom, -40) + + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, -10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, -20) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, -30) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, -40) + + ; + + theResult + // << BasicResult(0, QRectF(20, 10, 150, 50) ) + << BasicResult(0, QRectF(-20, -10, 250, 150) ) + ; + + QTest::newRow("One, simple (n)") << QSizeF(200, 100) << theData << theResult; + } + + // One widget, duplicates, negative spacing + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(0, Qt::AnchorTop, -1, Qt::AnchorTop, -20) + << BasicData(0, Qt::AnchorLeft, -1, Qt::AnchorLeft, -20) + << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorRight, -30) + << BasicData(-1, Qt::AnchorBottom, 0, Qt::AnchorBottom, -40) + + << BasicData(0, Qt::AnchorTop, -1, Qt::AnchorTop, -10) + << BasicData(0, Qt::AnchorLeft, -1, Qt::AnchorLeft, -10) + << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorRight, -10) + << BasicData(-1, Qt::AnchorBottom, 0, Qt::AnchorBottom, -10) + ; + + theResult + // ### Same as above... + // << BasicResult(0, QRectF(10, 10, 180, 80) ) + << BasicResult(0, QRectF(-10, -10, 220, 120) ) + ; + + QTest::newRow("One, duplicates (n)") << QSizeF(200, 100) << theData << theResult; + } + + // One widget, mixed, negative spacing + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + // ### All anchors of negative spacing between the layout and an + // item are handled as to make sure the item is _outside_ the + // layout. + // To keep it inside, one _must_ use positive spacings. + // << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorTop, -80) + // << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorLeft, -150) + // << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorLeft, -150) + // << BasicData(-1, Qt::AnchorBottom, 0, Qt::AnchorTop, -80) + + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorTop, 80) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorLeft, 150) + << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorLeft, 150) + << BasicData(-1, Qt::AnchorBottom, 0, Qt::AnchorTop, 80) + ; + + theResult + << BasicResult(0, QRectF(50, 20, 100, 60) ) + ; + + QTest::newRow("One, mixed (n)") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, 1 horizontal connection, first completely defined, negative spacing + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + // << BasicData(0, Qt::AnchorTop, -1, Qt::AnchorTop, -10) + // << BasicData(-1, Qt::AnchorBottom, 0, Qt::AnchorBottom, -10) + // << BasicData(0, Qt::AnchorLeft, -1, Qt::AnchorLeft, -10) + // << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorRight, -180) + + // << BasicData(1, Qt::AnchorLeft, 0, Qt::AnchorRight, -10) + // << BasicData(-1, Qt::AnchorRight, 1, Qt::AnchorRight, -10) + // << BasicData(1, Qt::AnchorTop, -1, Qt::AnchorTop, -10) + // << BasicData(-1, Qt::AnchorBottom, 1, Qt::AnchorBottom, -20) + + << BasicData(0, Qt::AnchorTop, -1, Qt::AnchorTop, -10) + << BasicData(-1, Qt::AnchorBottom, 0, Qt::AnchorBottom, -10) + << BasicData(0, Qt::AnchorLeft, -1, Qt::AnchorLeft, -10) + << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorRight, 180) + + << BasicData(1, Qt::AnchorLeft, 0, Qt::AnchorRight, -10) + << BasicData(-1, Qt::AnchorRight, 1, Qt::AnchorRight, -10) + << BasicData(1, Qt::AnchorTop, -1, Qt::AnchorTop, -10) + << BasicData(-1, Qt::AnchorBottom, 1, Qt::AnchorBottom, -20) + + ; + + theResult + // << BasicResult(0, QRectF(10, 10, 10, 80) ) + // << BasicResult(1, QRectF(30, 10, 160, 70) ) + + << BasicResult(0, QRectF(-10, -10, 30, 120) ) + << BasicResult(1, QRectF(10, -10, 200, 130) ) + ; + + QTest::newRow("Two, 1h connected (n)") << QSizeF(200, 100) << theData << theResult; + } + + // Basic case - two widgets, 2 horizontal and 2 vertical connections, dependent on each other, negative spacing + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(0, Qt::AnchorLeft, -1, Qt::AnchorLeft, -10) + << BasicData(1, Qt::AnchorRight, 0, Qt::AnchorRight, -150) + << BasicData(0, Qt::AnchorTop, -1, Qt::AnchorTop, -10) + << BasicData(1, Qt::AnchorBottom, 0, Qt::AnchorBottom, -10) + + << BasicData(1, Qt::AnchorLeft, 0, Qt::AnchorLeft, -90) + << BasicData(-1, Qt::AnchorRight, 1, Qt::AnchorRight, -10) + << BasicData(1, Qt::AnchorTop, 0, Qt::AnchorTop, -10) + << BasicData(-1, Qt::AnchorBottom, 1, Qt::AnchorBottom, -20) + ; + + theResult + // << BasicResult(0, QRectF(10, 10, 30, 60) ) + // << BasicResult(1, QRectF(100, 20, 90, 60) ) + << BasicResult(0, QRectF(-10, -10, 70, 120) ) + << BasicResult(1, QRectF(80, 0, 130, 120) ) + ; + + QTest::newRow("Two, 2h+2v connected2 (n)") << QSizeF(200, 100) << theData << theResult; + } +} + +void tst_QGraphicsAnchorLayout1::testMixedSpacing_data() +{ + QTest::addColumn<QSizeF>("size"); + QTest::addColumn<BasicLayoutTestDataList>("data"); + QTest::addColumn<BasicLayoutTestResultList>("result"); + + typedef BasicLayoutTestData BasicData; + typedef BasicLayoutTestResult BasicResult; + + // Two widgets, partial overlapping + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(0, Qt::AnchorLeft, -1, Qt::AnchorLeft, -50) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 50) + << BasicData(1, Qt::AnchorRight, 0, Qt::AnchorRight, 15) + + // << BasicData(1, Qt::AnchorTop, 0, Qt::AnchorBottom, 5) + << BasicData(1, Qt::AnchorTop, 0, Qt::AnchorBottom, -5) + << BasicData(0, Qt::AnchorLeft, 1, Qt::AnchorLeft, -10) + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 20) + << BasicData(-1, Qt::AnchorBottom, 1, Qt::AnchorBottom, -5) + ; + + theResult + // << BasicResult(0, QRectF(50, 10, 45, 40) ) + // << BasicResult(1, QRectF(40, 45, 40, 50) ) + << BasicResult(0, QRectF(-50, 10, 145, 40) ) + << BasicResult(1, QRectF(-60, 45, 140, 60) ) + ; + + QTest::newRow("Two, partial overlap") << QSizeF(100, 100) << theData << theResult; + } + + // Two widgets, complete overlapping + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 5) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorRight, 0) + << BasicData(0, Qt::AnchorTop, 1, Qt::AnchorTop, 0) + << BasicData(1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 25) + + << BasicData(1, Qt::AnchorBottom, 0, Qt::AnchorBottom, 0) + << BasicData(1, Qt::AnchorBottom, -1, Qt::AnchorBottom, 5) + << BasicData(1, Qt::AnchorLeft, -1, Qt::AnchorRight, 50) + << BasicData(-1, Qt::AnchorRight, 1, Qt::AnchorRight, -10) + ; + + theResult + << BasicResult(0, QRectF(65, 5, 35, 35) ) + << BasicResult(1, QRectF(40, 5, 60, 35) ) + ; + + QTest::newRow("Two, complete overlap") << QSizeF(90, 45) << theData << theResult; + } + + // Five widgets, v shaped, edges shared + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + // edges shared + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorLeft, 0) + << BasicData(1, Qt::AnchorRight, 2, Qt::AnchorLeft, 0) + << BasicData(2, Qt::AnchorRight, 3, Qt::AnchorLeft, 0) + << BasicData(3, Qt::AnchorRight, 4, Qt::AnchorLeft, 0) + << BasicData(1, Qt::AnchorBottom, 2, Qt::AnchorTop, 0) + << BasicData(0, Qt::AnchorBottom, 1, Qt::AnchorTop, 0) + << BasicData(3, Qt::AnchorBottom, 2, Qt::AnchorTop, 0) + << BasicData(4, Qt::AnchorBottom, 3, Qt::AnchorTop, 0) + << BasicData(0, Qt::AnchorBottom, 4, Qt::AnchorBottom, 0) + << BasicData(1, Qt::AnchorBottom, 3, Qt::AnchorBottom, 0) + << BasicData(0, Qt::AnchorTop, 4, Qt::AnchorTop, 0) + << BasicData(1, Qt::AnchorTop, 3, Qt::AnchorTop, 0) + + // margins + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 5) + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 5) + << BasicData(2, Qt::AnchorBottom, -1, Qt::AnchorBottom, 5) + // << BasicData(-1, Qt::AnchorRight, 4, Qt::AnchorRight, -5) + << BasicData(-1, Qt::AnchorRight, 4, Qt::AnchorRight, 5) + + // additional details for exact size determination easily + << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorLeft, 25) + << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorRight, 50) + // << BasicData(-1, Qt::AnchorRight, 3, Qt::AnchorRight, -25) + // << BasicData(-1, Qt::AnchorRight, 2, Qt::AnchorRight, -50) + << BasicData(-1, Qt::AnchorRight, 3, Qt::AnchorRight, 25) + << BasicData(-1, Qt::AnchorRight, 2, Qt::AnchorRight, 50) + << BasicData(-1, Qt::AnchorTop, 3, Qt::AnchorBottom, 50) + // << BasicData(-1, Qt::AnchorBottom, 3, Qt::AnchorTop, -50) + << BasicData(-1, Qt::AnchorBottom, 3, Qt::AnchorTop, 50) + + ; + + theResult + << BasicResult(0, QRectF(5,5,20,20)) + << BasicResult(1, QRectF(25,25,25,25)) + << BasicResult(2, QRectF(50,50,25,20)) + << BasicResult(3, QRectF(75,25,25,25)) + << BasicResult(4, QRectF(100,5,20,20)) + ; + + QTest::newRow("Five, V shape") << QSizeF(125, 75) << theData << theResult; + } + + // ### The behavior is different in QGraphicsAnchorLayout. What happens here is + // that when the above anchors are set, the layout size hints are changed. + // In the example, the minimum item width is 5, thus the minimum layout width + // becomes 105 (50 + 5 + 50). Once that size hint is set, trying to set + // the widget size to (10, 10) is not possible because + // QGraphicsWidget::setGeometry() will enforce the minimum is respected. + if (0) + // One widget, unsolvable + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 50) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 50) + ; + theResult + << BasicResult(0, QRectF(0,0,0,0)) + ; + + QTest::newRow("One widget, unsolvable") << QSizeF(10, 10) << theData << theResult; + } + + // ### BUG. We are not handling "floating" elements properly. Ie. elements that + // have no anchors in a given orientation. + if (0) + // Two widgets, one has fixed size + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 50) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 50) + // not supported, use sizePolicy instead + // << BasicData(0, Qt::AnchorLeft, 0, Qt::AnchorRight, 50) + + << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorLeft, 50) + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 50) + ; + theResult + << BasicResult(0, QRectF(50,0,50,50)) + << BasicResult(1, QRectF(50,0,50,50)) + ; + + QTest::newRow("Two widgets, one has fixed size") << QSizeF(150, 150) << theData << theResult; + } +} + +void tst_QGraphicsAnchorLayout1::testMulti_data() +{ + QTest::addColumn<QSizeF>("size"); + QTest::addColumn<BasicLayoutTestDataList>("data"); + QTest::addColumn<BasicLayoutTestResultList>("result"); + + typedef BasicLayoutTestData BasicData; + typedef BasicLayoutTestResult BasicResult; + + // Multiple widgets, all overllapping + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + const int n = 30; + for ( int i = 0 ; i < n; i++ ) { + theData + << BasicData(-1, Qt::AnchorTop, i, Qt::AnchorTop, 20) + << BasicData(-1, Qt::AnchorLeft, i, Qt::AnchorLeft, 10) + // << BasicData(-1, Qt::AnchorBottom, i, Qt::AnchorBottom, -40) + // << BasicData(-1, Qt::AnchorRight, i, Qt::AnchorRight, -30); + << BasicData(-1, Qt::AnchorBottom, i, Qt::AnchorBottom, 40) + << BasicData(-1, Qt::AnchorRight, i, Qt::AnchorRight, 30); + + theResult + << BasicResult(i, QRectF(10, 20, 160, 40) ); + } + + + QTest::newRow("Overlapping multi") << QSizeF(200, 100) << theData << theResult; + } + + // Multiple widgets, linear order + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + const qreal height = 1000.f; + const qreal width = 2000.f; + + const int n = 30; + + const qreal verticalStep = height/qreal(n+2); + const qreal horizontalStep = width/qreal(n+2); + + for ( int i = 0 ; i < n; i++ ) { + + if ( i == 0 ) { + // First item + theData + << BasicData(-1, Qt::AnchorTop, i, Qt::AnchorTop, verticalStep) + << BasicData(-1, Qt::AnchorLeft, i, Qt::AnchorLeft, horizontalStep) + << BasicData(i+1, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep) + << BasicData(i+1, Qt::AnchorRight, i, Qt::AnchorRight, -horizontalStep); + + } else if ( i == n-1 ) { + // Last item + theData + << BasicData(i-1, Qt::AnchorTop, i, Qt::AnchorTop, verticalStep) + << BasicData(i-1, Qt::AnchorLeft, i, Qt::AnchorLeft, horizontalStep) + << BasicData(-1, Qt::AnchorBottom, i, Qt::AnchorBottom, verticalStep) + << BasicData(-1, Qt::AnchorRight, i, Qt::AnchorRight, horizontalStep); + // << BasicData(-1, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep) + // << BasicData(-1, Qt::AnchorRight, i, Qt::AnchorRight, -horizontalStep); + + } else { + // items in the middle + theData + << BasicData(i-1, Qt::AnchorTop, i, Qt::AnchorTop, verticalStep) + << BasicData(i-1, Qt::AnchorLeft, i, Qt::AnchorLeft, horizontalStep) + << BasicData(i+1, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep) + << BasicData(i+1, Qt::AnchorRight, i, Qt::AnchorRight, -horizontalStep); + // << BasicData(i+1, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep) + // << BasicData(i+1, Qt::AnchorRight, i, Qt::AnchorRight, -horizontalStep); + + } + + theResult + << BasicResult(i, QRectF((i+1)*horizontalStep, (i+1)*verticalStep, horizontalStep, verticalStep) ); + } + + + QTest::newRow("Linear multi") << QSizeF(width, height) << theData << theResult; + } + + // Multiple widgets, V shape + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + const qreal height = 100.f; + const qreal width = 200.f; + + const int n = 31; // odd number please (3,5,7... ) + + const qreal verticalStep = height/(2.f+(n+1)/2.f); + const qreal horizontalStep = width/(n+2.f); + + for ( int i = 0 ; i < n; i++ ) { + + if ( i == 0 ) { + // First item + theData + << BasicData(-1, Qt::AnchorTop, i, Qt::AnchorTop, verticalStep) + << BasicData(-1, Qt::AnchorLeft, i, Qt::AnchorLeft, horizontalStep) + << BasicData(i+1, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep) + << BasicData(i, Qt::AnchorRight, i+1, Qt::AnchorRight, horizontalStep); + + } else if ( i == n-1 ) { + // Last item + theData + << BasicData(i-1, Qt::AnchorTop, i, Qt::AnchorTop, -verticalStep) + << BasicData(i-1, Qt::AnchorLeft, i, Qt::AnchorLeft, horizontalStep) + << BasicData(i-1, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep) + << BasicData(i, Qt::AnchorRight, -1, Qt::AnchorRight, horizontalStep); + } else if ( i == ((n-1)/2) ) { + // midway + theData + << BasicData(i-1, Qt::AnchorTop, i, Qt::AnchorTop, verticalStep) + << BasicData(i-1, Qt::AnchorLeft, i, Qt::AnchorLeft, horizontalStep) + // << BasicData(-1, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep) + << BasicData(-1, Qt::AnchorBottom, i, Qt::AnchorBottom, verticalStep) + << BasicData(i, Qt::AnchorRight, i+1, Qt::AnchorRight, horizontalStep); + } else if ( i < ((n-1)/2) ) { + // before midway - going down + theData + << BasicData(i-1, Qt::AnchorTop, i, Qt::AnchorTop, verticalStep) + << BasicData(i-1, Qt::AnchorLeft, i, Qt::AnchorLeft, horizontalStep) + << BasicData(i+1, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep) + << BasicData(i, Qt::AnchorRight, i+1, Qt::AnchorRight, horizontalStep); + + } else { + // after midway - going up + theData + << BasicData(i-1, Qt::AnchorTop, i, Qt::AnchorTop, -verticalStep) + << BasicData(i-1, Qt::AnchorLeft, i, Qt::AnchorLeft, horizontalStep) + << BasicData(i-1, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep) + << BasicData(i, Qt::AnchorRight, i+1, Qt::AnchorRight, horizontalStep); + + } + + if ( i <= ((n-1)/2) ) { + // until midway + theResult + << BasicResult(i, QRectF((i+1)*horizontalStep, (i+1)*verticalStep, horizontalStep, verticalStep) ); + } else { + // after midway + theResult + << BasicResult(i, QRectF((i+1)*horizontalStep, (n-i)*verticalStep, horizontalStep, verticalStep) ); + } + + } + QTest::newRow("V multi") << QSizeF(width, height) << theData << theResult; + } + + // Multiple widgets, grid + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + const qreal height = 100.f; + const qreal width = 200.f; + + const int d = 10; // items per dimension + const int n = d*d; + + const qreal verticalStep = height/(d+2.f); + const qreal horizontalStep = width/(d+2.f); + + for ( int i = 0 ; i < n; i++ ) { + if ( i%d == 0 ) { + // left side item + theData + << BasicData(-1, Qt::AnchorLeft, i, Qt::AnchorLeft, horizontalStep) + << BasicData(i+1, Qt::AnchorRight, i, Qt::AnchorRight, -horizontalStep); + } else if ( (i+1)%d == 0 ) { + // rigth side item + theData + << BasicData(i-1, Qt::AnchorLeft, i, Qt::AnchorLeft, horizontalStep) + // << BasicData(-1, Qt::AnchorRight, i, Qt::AnchorRight, -horizontalStep); + << BasicData(-1, Qt::AnchorRight, i, Qt::AnchorRight, horizontalStep); + } else { + // horizontal middle + theData + << BasicData(i-1, Qt::AnchorLeft, i, Qt::AnchorLeft, horizontalStep) + << BasicData(i+1, Qt::AnchorRight, i, Qt::AnchorRight, -horizontalStep); + } + + if ( i < d ) { + // top line + theData + << BasicData(-1, Qt::AnchorTop, i, Qt::AnchorTop, verticalStep) + << BasicData(i+d, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep); + } else if ( i >= (d-1)*d ){ + // bottom line + theData + << BasicData(i-d, Qt::AnchorTop, i, Qt::AnchorTop, verticalStep) + // << BasicData(-1, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep) + << BasicData(-1, Qt::AnchorBottom, i, Qt::AnchorBottom, verticalStep); + } else { + // vertical middle + theData + << BasicData(i-d, Qt::AnchorTop, i, Qt::AnchorTop, verticalStep) + << BasicData(i+d, Qt::AnchorBottom, i, Qt::AnchorBottom, -verticalStep); + } + + theResult + << BasicResult(i, QRectF(((i%d)+1)*horizontalStep, ((i/d)+1)*verticalStep, horizontalStep, verticalStep) ); + } + + QTest::newRow("Grid multi") << QSizeF(200, 100) << theData << theResult; + } +} + +inline QGraphicsLayoutItem *getItem( + int index, + const QList<QGraphicsWidget *>& widgets, + QGraphicsLayoutItem *defaultItem) +{ + if (index < 0) { + return defaultItem; + } + + return widgets[index]; +} + +void tst_QGraphicsAnchorLayout1::testBasicLayout() +{ + QFETCH(QSizeF, size); + QFETCH(BasicLayoutTestDataList, data); + QFETCH(BasicLayoutTestResultList, result); + + QGraphicsWidget *widget = new QGraphicsWidget; + + // Determine amount of widgets to add. + int widgetCount = -1; + for (int i = 0; i < data.count(); ++i) { + const BasicLayoutTestData item = data[i]; + widgetCount = qMax(widgetCount, item.firstIndex); + widgetCount = qMax(widgetCount, item.secondIndex); + } + ++widgetCount; // widgetCount is max of indices. + + // Create dummy widgets + QList<QGraphicsWidget *> widgets; + for (int i = 0; i < widgetCount; ++i) { + TestWidget *w = new TestWidget; + widgets << w; + } + + // Setup anchor layout + TheAnchorLayout *layout = new TheAnchorLayout; + + for (int i = 0; i < data.count(); ++i) { + const BasicLayoutTestData item = data[i]; + layout->setAnchor( + getItem(item.firstIndex, widgets, layout), + item.firstEdge, + getItem(item.secondIndex, widgets, layout), + item.secondEdge, + item.spacing ); + } + + widget->setLayout(layout); + widget->setContentsMargins(0,0,0,0); + + widget->setMinimumSize(size); + widget->setMaximumSize(size); + +// QTest::qWait(500); // layouting is asynchronous.. + + // Validate + for (int i = 0; i < result.count(); ++i) { + if (i == 1) + QEXPECT_FAIL("Two, mixed", "Works with simplification disabled.", Continue); + const BasicLayoutTestResult item = result[i]; + QCOMPARE(widgets[item.index]->geometry(), item.rect); + } + + // ###: not supported yet +/* + // Test mirrored mode + widget->setLayoutDirection(Qt::RightToLeft); + layout->activate(); + // Validate + for (int j = 0; j < result.count(); ++j) { + const BasicLayoutTestResult item = result[j]; + QRectF mirroredRect(item.rect); + // only valid cases are mirrored + if (mirroredRect.isValid()){ + mirroredRect.moveLeft(size.width()-item.rect.width()-item.rect.left()); + } + QCOMPARE(widgets[item.index]->geometry(), mirroredRect); + delete widgets[item.index]; + } +*/ + delete widget; +} + +void tst_QGraphicsAnchorLayout1::testNegativeSpacing() +{ + // use the same frame + testBasicLayout(); +} + +void tst_QGraphicsAnchorLayout1::testMixedSpacing() +{ + // use the same frame + testBasicLayout(); +} + +void tst_QGraphicsAnchorLayout1::testMulti() +{ + // use the same frame + testBasicLayout(); +} + +void tst_QGraphicsAnchorLayout1::testCenterAnchors_data() +{ + QTest::addColumn<QSizeF>("size"); + QTest::addColumn<BasicLayoutTestDataList>("data"); + QTest::addColumn<BasicLayoutTestResultList>("result"); + + typedef BasicLayoutTestData BasicData; + typedef BasicLayoutTestResult BasicResult; + + // Basic center case + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + // << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorHorizontalCenter, -10) + << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorHorizontalCenter, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorRight, 15) + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorVerticalCenter, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 5); + + theResult + << BasicResult(0, QRectF(5, 5, 10, 10) ); + + QTest::newRow("center, basic") << QSizeF(20, 20) << theData << theResult; + } + + // Basic center case, with invalid (shouldn't affect on result) + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + // << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorHorizontalCenter, -10) + << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorHorizontalCenter, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorRight, 15) + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorVerticalCenter, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 5) + + // bogus definitions + << BasicData(0, Qt::AnchorHorizontalCenter, -1, Qt::AnchorBottom, 5) + << BasicData(0, Qt::AnchorHorizontalCenter, 1, Qt::AnchorVerticalCenter, 5) + << BasicData(0, Qt::AnchorVerticalCenter, -1, Qt::AnchorRight, 5) + << BasicData(0, Qt::AnchorVerticalCenter, 0, Qt::AnchorVerticalCenter, 666) + << BasicData(0, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, 999) + << BasicData(0, Qt::AnchorLeft, 0, Qt::AnchorLeft, 333) + << BasicData(-1, Qt::AnchorRight, -1, Qt::AnchorRight, 222) + << BasicData(0, Qt::AnchorTop, 0, Qt::AnchorTop, 111) + << BasicData(0, Qt::AnchorBottom, 0, Qt::AnchorBottom, 444); + + theResult + << BasicResult(0, QRectF(5, 5, 10, 10) ); + + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor edges of different orientations"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor edges of different orientations"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor edges of different orientations"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::newRow("center, basic with invalid") << QSizeF(20, 20) << theData << theResult; + } + + // Basic center case 2 + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, 0) + // Not supported << BasicData(0, Qt::AnchorHorizontalCenter, 0, Qt::AnchorRight, 5) + << BasicData(-1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorRight, 5) + << BasicData(-1, Qt::AnchorVerticalCenter, 0, Qt::AnchorVerticalCenter, 0) + << BasicData(-1, Qt::AnchorVerticalCenter, 0, Qt::AnchorTop, -5); + + theResult + << BasicResult(0, QRectF(5, 5, 10, 10) ); + + QTest::newRow("center, basic 2") << QSizeF(20, 20) << theData << theResult; + } + + // Basic center case, overrides + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, 10) + << BasicData(-1, Qt::AnchorVerticalCenter, 0, Qt::AnchorVerticalCenter, 20) + << BasicData(0, Qt::AnchorHorizontalCenter, -1, Qt::AnchorHorizontalCenter, 30) + << BasicData(0, Qt::AnchorVerticalCenter, -1, Qt::AnchorVerticalCenter, 40) + // actual data: + << BasicData(-1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, 0) + << BasicData(-1, Qt::AnchorVerticalCenter, 0, Qt::AnchorVerticalCenter, 0) + // << BasicData(0, Qt::AnchorHorizontalCenter, 0, Qt::AnchorRight, 5) + << BasicData(-1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorRight, 5) + << BasicData(-1, Qt::AnchorVerticalCenter, 0, Qt::AnchorTop, -5); + + theResult + << BasicResult(0, QRectF(5, 5, 10, 10) ); + + QTest::newRow("center, overrides") << QSizeF(20, 20) << theData << theResult; + } + + // Two nested + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorLeft, 0) + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 0) + << BasicData(-1, Qt::AnchorBottom, 0, Qt::AnchorBottom, 0) + << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorRight, 0) + << BasicData(0, Qt::AnchorVerticalCenter, 1, Qt::AnchorTop, 0) + << BasicData(0, Qt::AnchorLeft, 1, Qt::AnchorLeft, 0) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorRight, 0) + << BasicData(0, Qt::AnchorBottom, 1, Qt::AnchorBottom, 0); + + theResult + << BasicResult(0, QRectF(20, 0, 20, 40)) + << BasicResult(1, QRectF(20, 20, 20, 20)); + + QTest::newRow("center, two nested") << QSizeF(40, 40) << theData << theResult; + } + + // Two overlap + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + // theData + // // horizontal + // << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 20) + // << BasicData(0, Qt::AnchorHorizontalCenter, 1, Qt::AnchorLeft, 0) + // << BasicData(1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorRight, -5) + // << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + // << BasicData(0, Qt::AnchorHorizontalCenter, 0, Qt::AnchorRight, 10) + // // vertical is pretty much same as horizontal, just roles swapped + // << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 20) + // << BasicData(1, Qt::AnchorVerticalCenter, 0, Qt::AnchorTop, 0) + // << BasicData(0, Qt::AnchorVerticalCenter, 1, Qt::AnchorBottom, -5) + // << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 10) + // << BasicData(1, Qt::AnchorVerticalCenter, 1, Qt::AnchorBottom, 10); + + theData + // horizontal + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 20) + << BasicData(0, Qt::AnchorHorizontalCenter, 1, Qt::AnchorLeft, 0) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorHorizontalCenter, 5) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorRight, 20) + // vertical + << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 20) + << BasicData(1, Qt::AnchorVerticalCenter, 0, Qt::AnchorTop, 0) + << BasicData(1, Qt::AnchorBottom, 0, Qt::AnchorVerticalCenter, 5) + << BasicData(1, Qt::AnchorBottom, 0, Qt::AnchorBottom, 20); + + theResult + << BasicResult(0, QRectF(20, 30, 20, 30)) + << BasicResult(1, QRectF(30, 20, 30, 20)); + + QTest::newRow("center, two overlap") << QSizeF(70, 70) << theData << theResult; + } + + // Three + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 0) + << BasicData(0, Qt::AnchorHorizontalCenter, 2, Qt::AnchorHorizontalCenter, 75) + << BasicData(1, Qt::AnchorRight, 2, Qt::AnchorLeft, 10) + << BasicData(1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, -30) + << BasicData(2, Qt::AnchorRight, -1, Qt::AnchorRight, 0) + << BasicData(1, Qt::AnchorLeft, 1, Qt::AnchorRight, 30) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorLeft, 10) + + << BasicData(1, Qt::AnchorTop, -1, Qt::AnchorTop, 0) + << BasicData(1, Qt::AnchorVerticalCenter, 0, Qt::AnchorVerticalCenter, 35) + << BasicData(1, Qt::AnchorVerticalCenter, 2, Qt::AnchorVerticalCenter, 15) + << BasicData(1, Qt::AnchorBottom, 2, Qt::AnchorTop, 5) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 0) + << BasicData(2, Qt::AnchorBottom, 0, Qt::AnchorTop, 5) + << BasicData(0, Qt::AnchorTop, 0, Qt::AnchorBottom, 20); + + theResult + << BasicResult(0, QRectF(0, 30, 10, 20)) + << BasicResult(1, QRectF(20, 0, 30, 10)) + << BasicResult(2, QRectF(60, 15, 40, 10)); + + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + + QTest::newRow("center, three") << QSizeF(100, 50) << theData << theResult; + } + + // Two, parent center + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + // vertical is pretty much same as horizontal, just roles swapped + << BasicData(-1, Qt::AnchorVerticalCenter, 1, Qt::AnchorVerticalCenter, -15) + << BasicData(-1, Qt::AnchorVerticalCenter, 0, Qt::AnchorVerticalCenter, 10) + << BasicData(-1, Qt::AnchorBottom, 0, Qt::AnchorBottom, 0) + << BasicData(1, Qt::AnchorTop, 0, Qt::AnchorTop, 0) + // horizontal + << BasicData(-1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, -15) + << BasicData(-1, Qt::AnchorHorizontalCenter, 1, Qt::AnchorHorizontalCenter, 10) + << BasicData(-1, Qt::AnchorRight, 1, Qt::AnchorRight, 0) + << BasicData(0, Qt::AnchorLeft, 1, Qt::AnchorLeft, 0); + + theResult + << BasicResult(0, QRectF(20, 20, 30, 80)) + << BasicResult(1, QRectF(20, 20, 80, 30)); + + QTest::newRow("center, parent") << QSizeF(100, 100) << theData << theResult; + } + + // Two, parent center 2 + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + // << BasicData(1, Qt::AnchorLeft, -1, Qt::AnchorHorizontalCenter, 15) + << BasicData(1, Qt::AnchorLeft, -1, Qt::AnchorHorizontalCenter, -15) + << BasicData(1, Qt::AnchorRight, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, -1, Qt::AnchorRight, 5) + << BasicData(-1, Qt::AnchorHorizontalCenter, 1, Qt::AnchorRight, -5) + // vertical + << BasicData(0, Qt::AnchorVerticalCenter, 1, Qt::AnchorVerticalCenter, 20) + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 10) + << BasicData(0, Qt::AnchorBottom, 1, Qt::AnchorBottom, 20) + << BasicData(0, Qt::AnchorTop, 1, Qt::AnchorTop, 20) + << BasicData(0, Qt::AnchorBottom, 1, Qt::AnchorTop, 10); + + theResult + << BasicResult(0, QRectF(30, 10, 15, 10)) + << BasicResult(1, QRectF(10, 30, 10, 10)); + + QTest::newRow("center, parent 2") << QSizeF(50, 50) << theData << theResult; + } + + // Two, parent center 3 + { + BasicLayoutTestDataList theData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorRight, -5) + << BasicData(-1, Qt::AnchorHorizontalCenter, 1, Qt::AnchorLeft, 5) + // << BasicData(0, Qt::AnchorLeft, 1, Qt::AnchorRight, 100) + << BasicData(0, Qt::AnchorLeft, 1, Qt::AnchorRight, -100) + << BasicData(0, Qt::AnchorLeft, -1, Qt::AnchorLeft, 0) + + // vertical + << BasicData(0, Qt::AnchorVerticalCenter, 1, Qt::AnchorVerticalCenter, 55) + << BasicData(0, Qt::AnchorTop, -1, Qt::AnchorTop, 0) + << BasicData(1, Qt::AnchorBottom, -1, Qt::AnchorBottom, 0) + << BasicData(0, Qt::AnchorBottom, 1, Qt::AnchorTop, 10) + // << BasicData(0, Qt::AnchorTop, 0, Qt::AnchorBottom, 45) + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorBottom, 45) + ; + + theResult + << BasicResult(0, QRectF(0, 0, 45, 45)) + << BasicResult(1, QRectF(55, 55, 45, 45)); + + QTest::newRow("center, parent 3") << QSizeF(100, 100) << theData << theResult; + } + +} + +void tst_QGraphicsAnchorLayout1::testCenterAnchors() +{ + // use the same frame + testBasicLayout(); +} + +void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor_data() +{ + QTest::addColumn<QSizeF>("size"); + QTest::addColumn<BasicLayoutTestDataList>("data"); + QTest::addColumn<BasicLayoutTestDataList>("removeData"); + QTest::addColumn<BasicLayoutTestResultList>("result"); + + typedef BasicLayoutTestData BasicData; + typedef BasicLayoutTestResult BasicResult; + + { + BasicLayoutTestDataList theData; + BasicLayoutTestDataList theRemoveData; + BasicLayoutTestResultList theResult; + + theData + // << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorHorizontalCenter, -10) + << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorHorizontalCenter, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorRight, 15) + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorVerticalCenter, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 5) + + << BasicData(-1, Qt::AnchorHorizontalCenter, 1, Qt::AnchorHorizontalCenter, 66) + << BasicData(1, Qt::AnchorVerticalCenter, -1, Qt::AnchorVerticalCenter, 99) + << BasicData(0, Qt::AnchorHorizontalCenter, 1, Qt::AnchorHorizontalCenter, 33) + ; + + theRemoveData + << BasicData(-1, Qt::AnchorHorizontalCenter, 1, Qt::AnchorHorizontalCenter, 0) + << BasicData(1, Qt::AnchorVerticalCenter, -1, Qt::AnchorVerticalCenter, 0) + << BasicData(0, Qt::AnchorHorizontalCenter, 1, Qt::AnchorHorizontalCenter, 0); + + theResult + << BasicResult(0, QRectF(5, 5, 10, 10) ); + + QTest::newRow("remove, center, basic") << QSizeF(20, 20) << theData + << theRemoveData << theResult; + } + + { + BasicLayoutTestDataList theData; + BasicLayoutTestDataList theRemoveData; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 0) + << BasicData(0, Qt::AnchorHorizontalCenter, 2, Qt::AnchorHorizontalCenter, 75) + << BasicData(1, Qt::AnchorRight, 2, Qt::AnchorLeft, 10) + << BasicData(1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, -30) + << BasicData(2, Qt::AnchorRight, -1, Qt::AnchorRight, 0) + << BasicData(1, Qt::AnchorLeft, 1, Qt::AnchorRight, 30) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorLeft, 10) + + // extra: + << BasicData(-1, Qt::AnchorVerticalCenter, 0, Qt::AnchorVerticalCenter, 66) + << BasicData(-1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, 33) + << BasicData(0, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, 55) + << BasicData(1, Qt::AnchorVerticalCenter, 1, Qt::AnchorVerticalCenter, 55) + + << BasicData(1, Qt::AnchorTop, -1, Qt::AnchorTop, 0) + << BasicData(1, Qt::AnchorVerticalCenter, 0, Qt::AnchorVerticalCenter, 35) + << BasicData(1, Qt::AnchorVerticalCenter, 2, Qt::AnchorVerticalCenter, 15) + << BasicData(1, Qt::AnchorBottom, 2, Qt::AnchorTop, 5) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 0) + << BasicData(2, Qt::AnchorBottom, 0, Qt::AnchorTop, 5) + << BasicData(0, Qt::AnchorTop, 0, Qt::AnchorBottom, 20); + + theRemoveData + << BasicData(-1, Qt::AnchorVerticalCenter, 0, Qt::AnchorVerticalCenter, 66) + << BasicData(-1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, 33) + << BasicData(0, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, 55) + << BasicData(1, Qt::AnchorVerticalCenter, 1, Qt::AnchorVerticalCenter, 55); + + theResult + << BasicResult(0, QRectF(0, 30, 10, 20)) + << BasicResult(1, QRectF(20, 0, 30, 10)) + << BasicResult(2, QRectF(60, 15, 40, 10)); + + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + + QTest::newRow("remove, center, three") << QSizeF(100, 50) << theData << theRemoveData << theResult; + } + + // add edge (item0,edge0,item1,edge1), remove (item1,edge1,item0,edge0) + { + BasicLayoutTestDataList theData; + BasicLayoutTestDataList theRemoveData; + BasicLayoutTestResultList theResult; + + theData + // << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorHorizontalCenter, -10) + << BasicData(-1, Qt::AnchorRight, 0, Qt::AnchorHorizontalCenter, 10) + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorRight, 15) + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorVerticalCenter, 10) + << BasicData(0, Qt::AnchorBottom, -1, Qt::AnchorBottom, 5) + + << BasicData(-1, Qt::AnchorHorizontalCenter, 1, Qt::AnchorHorizontalCenter, 66) + << BasicData(1, Qt::AnchorVerticalCenter, -1, Qt::AnchorVerticalCenter, 99) + << BasicData(0, Qt::AnchorHorizontalCenter, 1, Qt::AnchorHorizontalCenter, 33) + << BasicData(0, Qt::AnchorLeft, 0, Qt::AnchorRight, 22) + << BasicData(0, Qt::AnchorTop, 0, Qt::AnchorBottom, 11) + ; + + theRemoveData + << BasicData(1, Qt::AnchorHorizontalCenter, -1, Qt::AnchorHorizontalCenter, 0) + << BasicData(-1, Qt::AnchorVerticalCenter, 1, Qt::AnchorVerticalCenter, 0) + << BasicData(1, Qt::AnchorHorizontalCenter, 0, Qt::AnchorHorizontalCenter, 0) + << BasicData(0, Qt::AnchorRight, 0, Qt::AnchorLeft, 0) + << BasicData(0, Qt::AnchorBottom, 0, Qt::AnchorTop, 0) + ; + + theResult + << BasicResult(0, QRectF(5, 5, 10, 10) ); + + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); + QTest::newRow("remove, center, basic 2") << QSizeF(20, 20) << theData + << theRemoveData << theResult; + } + +} + +void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor() +{ + QFETCH(QSizeF, size); + QFETCH(BasicLayoutTestDataList, data); + QFETCH(BasicLayoutTestDataList, removeData); + QFETCH(BasicLayoutTestResultList, result); + + QGraphicsWidget *widget = new QGraphicsWidget; + + // Determine amount of widgets to add. + int widgetCount = -1; + for (int i = 0; i < data.count(); ++i) { + const BasicLayoutTestData item = data[i]; + widgetCount = qMax(widgetCount, item.firstIndex); + widgetCount = qMax(widgetCount, item.secondIndex); + } + ++widgetCount; // widgetCount is max of indices. + + // Create dummy widgets + QList<QGraphicsWidget *> widgets; + for (int i = 0; i < widgetCount; ++i) { + TestWidget *w = new TestWidget; + widgets << w; + } + + // Setup anchor layout + TheAnchorLayout *layout = new TheAnchorLayout; + + for (int i = 0; i < data.count(); ++i) { + const BasicLayoutTestData item = data[i]; + layout->setAnchor( + getItem(item.firstIndex, widgets, layout), + item.firstEdge, + getItem(item.secondIndex, widgets, layout), + item.secondEdge, + item.spacing ); + } + + for (int i = 0; i < removeData.count(); ++i) { + const BasicLayoutTestData item = removeData[i]; + layout->removeAnchor( + getItem(item.firstIndex, widgets, layout), + item.firstEdge, + getItem(item.secondIndex, widgets, layout), + item.secondEdge); + } + + widget->setLayout(layout); + widget->setContentsMargins(0,0,0,0); + + widget->setMinimumSize(size); + widget->setMaximumSize(size); + + // Validate + for (int i = 0; i < result.count(); ++i) { + const BasicLayoutTestResult item = result[i]; + + QCOMPARE(widgets[item.index]->geometry(), item.rect); + delete widgets[item.index]; + } + delete widget; +} + +void tst_QGraphicsAnchorLayout1::testSingleSizePolicy_data() +{ + QTest::addColumn<QSizeF>("size"); + QTest::addColumn<QSizePolicy>("policy"); + QTest::addColumn<bool>("valid"); + +// FIXED + { + QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); + QTest::newRow("single size policy: fixed ok") << QSizeF(70, 70) << sizePolicy << true; + } +/* + { + QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); + QTest::newRow("single size policy: fixed too big") << QSizeF(100, 100) << sizePolicy << false; + } + + { + QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); + QTest::newRow("single size policy: fixed too small") << QSizeF(50, 50) << sizePolicy << false; + } +*/ +// MINIMUM + { + QSizePolicy sizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); + QTest::newRow("single size policy: minimum bigger ok") << QSizeF(100, 100) << sizePolicy << true; + } + + { + QSizePolicy sizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); + QTest::newRow("single size policy: minimum limit ok") << QSizeF(70, 70) << sizePolicy << true; + } +/* + { + QSizePolicy sizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); + QTest::newRow("single size policy: minimum too small") << QSizeF(50, 50) << sizePolicy << false; + } +*/ +// MAXIMUM + { + QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ); + QTest::newRow("single size policy: maximum small ok") << QSizeF(50, 50) << sizePolicy << true; + } + + { + QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ); + QTest::newRow("single size policy: maximum limit ok") << QSizeF(70, 70) << sizePolicy << true; + } +/* + { + QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ); + QTest::newRow("single size policy: maximum bigger fail") << QSizeF(100, 100) << sizePolicy << false; + } +*/ +// PREFERRED + { + QSizePolicy sizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + QTest::newRow("single size policy: preferred bigger ok") << QSizeF(100, 100) << sizePolicy << true; + } + + { + QSizePolicy sizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + QTest::newRow("single size policy: preferred smaller ok") << QSizeF(50, 50) << sizePolicy << true; + } +/* + { + QSizePolicy sizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + QTest::newRow("single size policy: preferred too big") << QSizeF(700, 700) << sizePolicy << false; + } + + { + QSizePolicy sizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); + QTest::newRow("single size policy: preferred too small") << QSizeF(21, 21) << sizePolicy << false; + } +*/ +// MINIMUMEXPANDING + + { + QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); + QTest::newRow("single size policy: min.expanding bigger ok") << QSizeF(100, 100) << sizePolicy << true; + } + + { + QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); + QTest::newRow("single size policy: min.expanding limit ok") << QSizeF(70, 70) << sizePolicy << true; + } + + /*{ + QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); + QTest::newRow("single size policy: min.expanding too small") << QSizeF(50, 50) << sizePolicy << false; + }*/ + +// EXPANDING + + { + QSizePolicy sizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + QTest::newRow("single size policy: expanding bigger ok") << QSizeF(100, 100) << sizePolicy << true; + } + + { + QSizePolicy sizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + QTest::newRow("single size policy: expanding smaller ok") << QSizeF(50, 50) << sizePolicy << true; + } + + // IGNORED + + { + QSizePolicy sizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ); + QTest::newRow("single size policy: ignored bigger ok") << QSizeF(100, 100) << sizePolicy << true; + } + + { + QSizePolicy sizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ); + QTest::newRow("single size policy: ignored smaller ok") << QSizeF(50, 50) << sizePolicy << true; + } +} + +void tst_QGraphicsAnchorLayout1::testSingleSizePolicy() +{ + QFETCH(QSizeF, size); + QFETCH(QSizePolicy, policy); + QFETCH(bool, valid); + + // create objects + QGraphicsWidget *widget = new QGraphicsWidget; + TheAnchorLayout *layout = new TheAnchorLayout; + TestWidget *childWidget = new TestWidget; + + // set anchors + layout->setAnchor( layout, Qt::AnchorLeft, childWidget, Qt::AnchorLeft, 10 ); + layout->setAnchor( childWidget, Qt::AnchorRight, layout, Qt::AnchorRight, 10 ); + layout->setAnchor( layout, Qt::AnchorTop, childWidget, Qt::AnchorTop, 10 ); + layout->setAnchor( childWidget, Qt::AnchorBottom, layout, Qt::AnchorBottom, 10 ); + + widget->setLayout( layout ); + + // set test case specific: policy and size + childWidget->setSizePolicy( policy ); + widget->setGeometry( QRectF( QPoint(0,0), size ) ); + + QCOMPARE( layout->isValid() , valid ); + + const QRectF childRect = childWidget->geometry(); + Q_UNUSED( childRect ); +} + +void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy_data() +{ + // tests only horizontal direction + QTest::addColumn<QSizePolicy>("policy1"); + QTest::addColumn<QSizePolicy>("policy2"); + QTest::addColumn<qreal>("width1"); + QTest::addColumn<qreal>("width2"); + + // layout size always 100x100 and size hints for items are 5<50<500 + // gabs: 10-item1-10-item2-10 + + { + QSizePolicy sizePolicy1( QSizePolicy::Fixed, QSizePolicy::Fixed ); + QSizePolicy sizePolicy2( QSizePolicy::Preferred, QSizePolicy::Preferred ); + const qreal width1 = 50; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: fixed-preferred") << sizePolicy1 << sizePolicy2 << width1 << width2; + } + + { + QSizePolicy sizePolicy1( QSizePolicy::Minimum, QSizePolicy::Minimum ); + QSizePolicy sizePolicy2( QSizePolicy::Preferred, QSizePolicy::Preferred ); + const qreal width1 = 50; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: minimum-preferred") << sizePolicy1 << sizePolicy2 << width1 << width2; + } + + { + QSizePolicy sizePolicy1( QSizePolicy::Maximum, QSizePolicy::Maximum ); + QSizePolicy sizePolicy2( QSizePolicy::Preferred, QSizePolicy::Preferred ); + const qreal width1 = 35; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: maximum-preferred") << sizePolicy1 << sizePolicy2 << width1 << width2; + } + + { + QSizePolicy sizePolicy1( QSizePolicy::Preferred, QSizePolicy::Preferred ); + QSizePolicy sizePolicy2( QSizePolicy::Preferred, QSizePolicy::Preferred ); + const qreal width1 = 35; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: preferred-preferred") << sizePolicy1 << sizePolicy2 << width1 << width2; + } + + { + QSizePolicy sizePolicy1( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); + QSizePolicy sizePolicy2( QSizePolicy::Preferred, QSizePolicy::Preferred ); + const qreal width1 = 50; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: min.expanding-preferred") << sizePolicy1 << sizePolicy2 << width1 << width2; + } + + { + QSizePolicy sizePolicy1( QSizePolicy::Expanding, QSizePolicy::Expanding ); + QSizePolicy sizePolicy2( QSizePolicy::Preferred, QSizePolicy::Preferred ); + const qreal width1 = 35; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: expanding-preferred") << sizePolicy1 << sizePolicy2 << width1 << width2; + } + + { + QSizePolicy sizePolicy1( QSizePolicy::Ignored, QSizePolicy::Ignored ); + QSizePolicy sizePolicy2( QSizePolicy::Preferred, QSizePolicy::Preferred ); + const qreal width1 = 35; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: ignored-preferred") << sizePolicy1 << sizePolicy2 << width1 << width2; + } + + /*{ + QSizePolicy sizePolicy1( QSizePolicy::Fixed, QSizePolicy::Fixed ); + QSizePolicy sizePolicy2( QSizePolicy::Fixed, QSizePolicy::Fixed ); + const qreal width1 = -1; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: fixed-fixed invalid") << sizePolicy1 << sizePolicy2 << width1 << width2; + }*/ + + /*{ + QSizePolicy sizePolicy1( QSizePolicy::Minimum, QSizePolicy::Minimum ); + QSizePolicy sizePolicy2( QSizePolicy::Fixed, QSizePolicy::Fixed ); + const qreal width1 = -1; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: minimum-fixed invalid") << sizePolicy1 << sizePolicy2 << width1 << width2; + }*/ + + { + QSizePolicy sizePolicy1( QSizePolicy::Maximum, QSizePolicy::Maximum ); + QSizePolicy sizePolicy2( QSizePolicy::Fixed, QSizePolicy::Fixed ); + const qreal width1 = 20; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: maximum-fixed") << sizePolicy1 << sizePolicy2 << width1 << width2; + } + + { + QSizePolicy sizePolicy1( QSizePolicy::Preferred, QSizePolicy::Preferred ); + QSizePolicy sizePolicy2( QSizePolicy::Fixed, QSizePolicy::Fixed ); + const qreal width1 = 20; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: preferred-fixed") << sizePolicy1 << sizePolicy2 << width1 << width2; + } + + /*{ + QSizePolicy sizePolicy1( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); + QSizePolicy sizePolicy2( QSizePolicy::Fixed, QSizePolicy::Fixed ); + const qreal width1 = -1; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: min.expanding-fixed invalid") << sizePolicy1 << sizePolicy2 << width1 << width2; + }*/ + + { + QSizePolicy sizePolicy1( QSizePolicy::Expanding, QSizePolicy::Expanding ); + QSizePolicy sizePolicy2( QSizePolicy::Fixed, QSizePolicy::Fixed ); + const qreal width1 = 20; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: expanding-fixed") << sizePolicy1 << sizePolicy2 << width1 << width2; + } + + { + QSizePolicy sizePolicy1( QSizePolicy::Ignored, QSizePolicy::Ignored ); + QSizePolicy sizePolicy2( QSizePolicy::Fixed, QSizePolicy::Fixed ); + const qreal width1 = 20; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("double size policy: ignored-fixed") << sizePolicy1 << sizePolicy2 << width1 << width2; + } +} + +void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy() +{ + // ### Size policy is not yet supported + return; + + QFETCH(QSizePolicy, policy1); + QFETCH(QSizePolicy, policy2); + QFETCH(qreal, width1); + QFETCH(qreal, width2); + + // create objects + QGraphicsWidget *widget = new QGraphicsWidget; + TheAnchorLayout *layout = new TheAnchorLayout; + TestWidget *childWidget1 = new TestWidget; + TestWidget *childWidget2 = new TestWidget; + + // set anchors + layout->setAnchor( layout, Qt::AnchorLeft, childWidget1, Qt::AnchorLeft, 10 ); + layout->setAnchor( childWidget1, Qt::AnchorRight, childWidget2, Qt::AnchorLeft, 10 ); + layout->setAnchor( childWidget2, Qt::AnchorRight, layout, Qt::AnchorRight, 10 ); + + widget->setLayout( layout ); + + // set test case specific: policy + childWidget1->setSizePolicy( policy1 ); + childWidget2->setSizePolicy( policy2 ); + + widget->setGeometry( QRectF( QPoint(0,0), QSize( 100,100 ) ) ); + + // check results: + if ( width1 == -1.0f ) { + // invalid + QCOMPARE( layout->isValid() , false ); + } else { + // valid + QCOMPARE( childWidget1->geometry().width(), width1 ); + QCOMPARE( childWidget2->geometry().width(), width2 ); + } +} + +typedef QMap<int,qreal> SizeHintArray; +Q_DECLARE_METATYPE(SizeHintArray) + +void tst_QGraphicsAnchorLayout1::testSizeDistribution_data() +{ + // tests only horizontal direction + QTest::addColumn<SizeHintArray>("sizeHints1"); + QTest::addColumn<SizeHintArray>("sizeHints2"); + QTest::addColumn<qreal>("width1"); + QTest::addColumn<qreal>("width2"); + + // layout size always 100x100 and size policy for items is preferred-preferred + // gabs: 10-item1-10-item2-10 + + { + SizeHintArray sizeHints1; + sizeHints1.insert( Qt::MinimumSize, 30 ); + sizeHints1.insert( Qt::PreferredSize, 35 ); + sizeHints1.insert( Qt::MaximumSize, 40 ); + Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) ); + Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) ); + + SizeHintArray sizeHints2; + sizeHints2.insert( Qt::MinimumSize, 5 ); + sizeHints2.insert( Qt::PreferredSize, 35 ); + sizeHints2.insert( Qt::MaximumSize, 300 ); + Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) ); + Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) ); + + const qreal width1 = 35; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("size distribution: preferred equal") << sizeHints1 << sizeHints2 << width1 << width2; + } + + { + SizeHintArray sizeHints1; + sizeHints1.insert( Qt::MinimumSize, 0 ); + sizeHints1.insert( Qt::PreferredSize, 20 ); + sizeHints1.insert( Qt::MaximumSize, 100 ); + Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) ); + Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) ); + + SizeHintArray sizeHints2; + sizeHints2.insert( Qt::MinimumSize, 0 ); + sizeHints2.insert( Qt::PreferredSize, 50 ); + sizeHints2.insert( Qt::MaximumSize, 100 ); + Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) ); + Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) ); + + const qreal width1 = 20; + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("size distribution: preferred non-equal") << sizeHints1 << sizeHints2 << width1 << width2; + } + + { + SizeHintArray sizeHints1; + sizeHints1.insert( Qt::MinimumSize, 0 ); + sizeHints1.insert( Qt::PreferredSize, 40 ); + sizeHints1.insert( Qt::MaximumSize, 100 ); + Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) ); + Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) ); + + SizeHintArray sizeHints2; + sizeHints2.insert( Qt::MinimumSize, 0 ); + sizeHints2.insert( Qt::PreferredSize, 60 ); + sizeHints2.insert( Qt::MaximumSize, 100 ); + Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) ); + Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) ); + + const qreal width1 = 28; // got from manual calculation + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("size distribution: below preferred") << sizeHints1 << sizeHints2 << width1 << width2; + } + + { + SizeHintArray sizeHints1; + sizeHints1.insert( Qt::MinimumSize, 0 ); + sizeHints1.insert( Qt::PreferredSize, 10 ); + sizeHints1.insert( Qt::MaximumSize, 100 ); + Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) ); + Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) ); + + SizeHintArray sizeHints2; + sizeHints2.insert( Qt::MinimumSize, 0 ); + sizeHints2.insert( Qt::PreferredSize, 40 ); + sizeHints2.insert( Qt::MaximumSize, 100 ); + Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) ); + Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) ); + + const qreal width1 = 22; // got from manual calculation + const qreal width2 = 100-10-10-10-width1; + QTest::newRow("size distribution: above preferred") << sizeHints1 << sizeHints2 << width1 << width2; + } + +} + +void tst_QGraphicsAnchorLayout1::testSizeDistribution() +{ + QFETCH(SizeHintArray, sizeHints1); + QFETCH(SizeHintArray, sizeHints2); + QFETCH(qreal, width1); + QFETCH(qreal, width2); + + // create objects + QGraphicsWidget *widget = new QGraphicsWidget; + TheAnchorLayout *layout = new TheAnchorLayout; + TestWidget *childWidget1 = new TestWidget; + TestWidget *childWidget2 = new TestWidget; + + // set anchors + layout->setAnchor( layout, Qt::AnchorLeft, childWidget1, Qt::AnchorLeft, 10 ); + layout->setAnchor( childWidget1, Qt::AnchorRight, childWidget2, Qt::AnchorLeft, 10 ); + layout->setAnchor( childWidget2, Qt::AnchorRight, layout, Qt::AnchorRight, 10 ); + + widget->setLayout( layout ); + + // set test case specific: size hints + childWidget1->setMinimumWidth( sizeHints1.value( Qt::MinimumSize ) ); + childWidget1->setPreferredWidth( sizeHints1.value( Qt::PreferredSize ) ); + childWidget1->setMaximumWidth( sizeHints1.value( Qt::MaximumSize ) ); + + childWidget2->setMinimumWidth( sizeHints2.value( Qt::MinimumSize ) ); + childWidget2->setPreferredWidth( sizeHints2.value( Qt::PreferredSize ) ); + childWidget2->setMaximumWidth( sizeHints2.value( Qt::MaximumSize ) ); + + widget->setGeometry( QRectF( QPoint(0,0), QSize( 100,100 ) ) ); + + // check results: + if ( width1 == -1.0f ) { + // invalid + QCOMPARE( layout->isValid() , false ); + } else { + // valid + QCOMPARE( float(childWidget1->geometry().width()), float(width1) ); + QCOMPARE( float(childWidget2->geometry().width()), float(width2) ); + } +} + +void tst_QGraphicsAnchorLayout1::testSizeHint() +{ + QGraphicsWidget *widget[5]; + + for( int i = 0; i < 5; i++ ) { + widget[i] = new QGraphicsWidget; + widget[i]->setMinimumSize( 10, 10 ); + widget[i]->setPreferredSize( 20, 20 ); + widget[i]->setMaximumSize( 40, 40 ); + } + + // one, basic + { + TheAnchorLayout *layout = new TheAnchorLayout(); + + + layout->setAnchor(layout, Qt::AnchorLeft, widget[0], Qt::AnchorLeft, 0 ); + layout->setAnchor(layout, Qt::AnchorRight, widget[0], Qt::AnchorRight, 0 ); + + layout->setAnchor(layout, Qt::AnchorTop, widget[0], Qt::AnchorTop, 0 ); + layout->setAnchor(layout, Qt::AnchorBottom, widget[0], Qt::AnchorBottom, 0 ); + + QCOMPARE( layout->minimumSize(), widget[0]->minimumSize() ); + QCOMPARE( layout->preferredSize(), widget[0]->preferredSize() ); + QCOMPARE( layout->maximumSize(), widget[0]->maximumSize() ); + + + delete layout; + } + + // one, basic again + { + TheAnchorLayout *layout = new TheAnchorLayout(); + + + layout->setAnchor(layout, Qt::AnchorLeft, widget[0], Qt::AnchorLeft, 10 ); + // layout->setAnchor(layout, Qt::AnchorRight, widget[0], Qt::AnchorRight, -10 ); + layout->setAnchor(layout, Qt::AnchorRight, widget[0], Qt::AnchorRight, 10 ); + + layout->setAnchor(layout, Qt::AnchorTop, widget[0], Qt::AnchorTop, 10 ); + // layout->setAnchor(layout, Qt::AnchorBottom, widget[0], Qt::AnchorBottom, -10 ); + layout->setAnchor(layout, Qt::AnchorBottom, widget[0], Qt::AnchorBottom, 10 ); + + QCOMPARE( layout->minimumSize(), widget[0]->minimumSize() + QSizeF( 20, 20 ) ); + QCOMPARE( layout->preferredSize(), widget[0]->preferredSize() + QSizeF( 20, 20 ) ); + QCOMPARE( layout->maximumSize(), widget[0]->maximumSize() + QSizeF( 20, 20 ) ); + + delete layout; + } + + // two, serial + { + TheAnchorLayout *layout = new TheAnchorLayout(); + + + layout->setAnchor(layout, Qt::AnchorLeft, widget[0], Qt::AnchorLeft, 0 ); + layout->setAnchor(layout, Qt::AnchorTop, widget[0], Qt::AnchorTop, 0 ); + layout->setAnchor(layout, Qt::AnchorBottom, widget[0], Qt::AnchorBottom, 0 ); + + layout->setAnchor(widget[0], Qt::AnchorRight, widget[1], Qt::AnchorLeft, 0 ); + layout->setAnchor(widget[1], Qt::AnchorRight, layout, Qt::AnchorRight, 0 ); + + + QCOMPARE( layout->minimumSize(), widget[0]->minimumSize() + QSizeF( widget[1]->minimumWidth(), 0 ) ); + QCOMPARE( layout->preferredSize(), widget[0]->preferredSize() + QSizeF( widget[1]->preferredWidth(), 0 ) ); + QCOMPARE( layout->maximumSize(), widget[0]->maximumSize() + QSizeF( widget[1]->maximumWidth(), 0 ) ); + + delete layout; + } + + // two, parallel + { + TheAnchorLayout *layout = new TheAnchorLayout(); + + + layout->setAnchor(layout, Qt::AnchorLeft, widget[0], Qt::AnchorLeft, 0 ); + layout->setAnchor(layout, Qt::AnchorTop, widget[0], Qt::AnchorTop, 0 ); + layout->setAnchor(layout, Qt::AnchorBottom, widget[0], Qt::AnchorBottom, 0 ); + layout->setAnchor(layout, Qt::AnchorRight, widget[0], Qt::AnchorRight, 0 ); + + layout->setAnchor(layout, Qt::AnchorLeft, widget[1], Qt::AnchorLeft, 0 ); + layout->setAnchor(layout, Qt::AnchorTop, widget[1], Qt::AnchorTop, 0 ); + layout->setAnchor(layout, Qt::AnchorBottom, widget[1], Qt::AnchorBottom, 0 ); + layout->setAnchor(layout, Qt::AnchorRight, widget[1], Qt::AnchorRight, 0 ); + + QCOMPARE( layout->minimumSize(), widget[0]->minimumSize() ); + QCOMPARE( layout->preferredSize(), widget[0]->preferredSize() ); + QCOMPARE( layout->maximumSize(), widget[0]->maximumSize() ); + + delete layout; + } + + // five, serial + { + TheAnchorLayout *layout = new TheAnchorLayout(); + + + layout->setAnchor(layout, Qt::AnchorLeft, widget[0], Qt::AnchorLeft, 0 ); + layout->setAnchor(layout, Qt::AnchorTop, widget[0], Qt::AnchorTop, 0 ); + layout->setAnchor(layout, Qt::AnchorBottom, widget[0], Qt::AnchorBottom, 0 ); + + layout->setAnchor(widget[0], Qt::AnchorRight, widget[1], Qt::AnchorLeft, 0 ); + layout->setAnchor(widget[1], Qt::AnchorRight, widget[2], Qt::AnchorLeft, 0 ); + layout->setAnchor(widget[2], Qt::AnchorRight, widget[3], Qt::AnchorLeft, 0 ); + layout->setAnchor(widget[3], Qt::AnchorRight, widget[4], Qt::AnchorLeft, 0 ); + layout->setAnchor(widget[4], Qt::AnchorRight, layout, Qt::AnchorRight, 0 ); + + + QCOMPARE( layout->minimumSize(), widget[0]->minimumSize() + + QSizeF( widget[1]->minimumWidth() + + widget[2]->minimumWidth() + + widget[3]->minimumWidth() + + widget[4]->minimumWidth(), 0 ) ); + + QCOMPARE( layout->preferredSize(), widget[0]->preferredSize() + + QSizeF( widget[1]->preferredWidth() + + widget[2]->preferredWidth() + + widget[3]->preferredWidth() + + widget[4]->preferredWidth(), 0 ) ); + + QCOMPARE( layout->maximumSize(), widget[0]->maximumSize() + + QSizeF( widget[1]->maximumWidth() + + widget[2]->maximumWidth() + + widget[3]->maximumWidth() + + widget[4]->maximumWidth(), 0 ) ); + + delete layout; + } + + + for( int i = 0; i < 5; i++ ) { + delete widget[i]; + } +} + +#ifdef TEST_COMPLEX_CASES + +void tst_QGraphicsAnchorLayout1::testComplexCases_data() +{ + QTest::addColumn<QSizeF>("size"); + QTest::addColumn<BasicLayoutTestDataList>("data"); + QTest::addColumn<AnchorItemSizeHintList>("sizehint"); + QTest::addColumn<BasicLayoutTestResultList>("result"); + + typedef BasicLayoutTestData BasicData; + typedef BasicLayoutTestResult BasicResult; + + // Three widgets, the same sizehint + { + BasicLayoutTestDataList theData; + AnchorItemSizeHintList theSizeHint; + BasicLayoutTestResultList theResult1; + BasicLayoutTestResultList theResult2; + + theData + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, 2, Qt::AnchorLeft, 10) + + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(2, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 0) + << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 0) + << BasicData(-1, Qt::AnchorTop, 2, Qt::AnchorTop, 0) + ; + + theSizeHint + << AnchorItemSizeHint( 0, 50, 100, 0, 50, 100 ) + << AnchorItemSizeHint( 0, 50, 100, 0, 50, 100 ) + << AnchorItemSizeHint( 0, 50, 100, 0, 50, 100 ) + ; + theResult1 + << BasicResult(0, QRectF(10, 0, 30, 50) ) + << BasicResult(1, QRectF(50, 0, 30, 50) ) + << BasicResult(2, QRectF(50, 0, 30, 50) ) + ; + + theResult2 + << BasicResult(0, QRectF(10, 0, 60, 50) ) + << BasicResult(1, QRectF(80, 0, 60, 50) ) + << BasicResult(2, QRectF(80, 0, 60, 50) ) + ; + + QTest::newRow("Three, the same sizehint(1)") << QSizeF(90, 50) << theData << theSizeHint << theResult1; + QTest::newRow("Three, the same sizehint(2)") << QSizeF(150, 50) << theData << theSizeHint << theResult2; + } + + // Three widgets, serial is bigger + { + BasicLayoutTestDataList theData; + AnchorItemSizeHintList theSizeHint; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, 2, Qt::AnchorLeft, 10) + + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(2, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 0) + << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 0) + << BasicData(-1, Qt::AnchorTop, 2, Qt::AnchorTop, 0) + ; + + theSizeHint + << AnchorItemSizeHint( 0, 100, 200, 0, 50, 100 ) + << AnchorItemSizeHint( 0, 50, 100, 0, 50, 100 ) + << AnchorItemSizeHint( 0, 50, 100, 0, 50, 100 ) + ; + + theResult + << BasicResult(0, QRectF(10, 0, 70, 50) ) + << BasicResult(1, QRectF(90, 0, 35, 50) ) + << BasicResult(2, QRectF(90, 0, 35, 50) ); + + QTest::newRow("Three, serial is bigger") << QSizeF(135, 50) << theData << theSizeHint << theResult; + + // theResult + // << BasicResult(0, QRectF(10, 0, 80, 50) ) + // << BasicResult(1, QRectF(100, 0, 60, 50) ) + // << BasicResult(2, QRectF(100, 0, 60, 50) ) + // ; + + // QTest::newRow("Three, serial is bigger") << QSizeF(170, 50) << theData << theSizeHint << theResult; + } + + + // Three widgets, parallel is bigger + { + BasicLayoutTestDataList theData; + AnchorItemSizeHintList theSizeHint; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, 2, Qt::AnchorLeft, 10) + + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(2, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 0) + << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 0) + << BasicData(-1, Qt::AnchorTop, 2, Qt::AnchorTop, 0) + ; + + theSizeHint + << AnchorItemSizeHint( 0, 50, 100, 0, 50, 100 ) + << AnchorItemSizeHint( 0, 100, 200, 0, 50, 100 ) + << AnchorItemSizeHint( 0, 50, 100, 0, 50, 100 ) + ; + + // ### QGAL uses a different preferred size calculation algorithm. + // This algorithm was discussed with Jan-Arve and tries to grow + // items instead of shrinking them. + // In this case, the preferred size of each item becomes: + // Item 0: 50 + // Item 1: 100 (grows to avoid shrinking item 2) + // Item 2: 100 + // Therefore, the preferred size of the parent widget becomes + // 180 == (10 + 50 + 10 + 100 + 10) + // As we set its size to 150, each widget is shrinked in the same + // ratio, in order to achieve the width of 150 == (10 + 40 + 10 + 80 + 10) + + theResult + << BasicResult(0, QRectF(10, 0, 40, 50) ) + << BasicResult(1, QRectF(60, 0, 80, 50) ) + << BasicResult(2, QRectF(60, 0, 80, 50) ) + ; + + QTest::newRow("Three, parallel is bigger") << QSizeF(150, 50) << theData << theSizeHint << theResult; + + // #ifdef PREFERRED_IS_AVERAGE + // theResult + // << BasicResult(0, QRectF(10, 0, 50, 50) ) + // << BasicResult(1, QRectF(70, 0, 75, 50) ) + // << BasicResult(2, QRectF(70, 0, 75, 50) ) + // ; + + // QTest::newRow("Three, parallel is bigger") << QSizeF(155, 50) << theData << theSizeHint << theResult; + // #else + // theResult + // << BasicResult(0, QRectF(10, 0, 50, 50) ) + // << BasicResult(1, QRectF(70, 0, 66.66666666666666, 50) ) + // << BasicResult(2, QRectF(70, 0, 60.66666666666666, 50) ) + // ; + + // QTest::newRow("Three, parallel is bigger") << QSizeF(146.66666666666666, 50) << theData << theSizeHint << theResult; + // #endif + } + + // Three widgets, the same sizehint, one center anchor + { + BasicLayoutTestDataList theData; + AnchorItemSizeHintList theSizeHint; + BasicLayoutTestResultList theResult; + + theData + << BasicData(-1, Qt::AnchorLeft, 0, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorRight, 1, Qt::AnchorLeft, 10) + << BasicData(0, Qt::AnchorHorizontalCenter, 2, Qt::AnchorLeft, 10) + + << BasicData(1, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + << BasicData(2, Qt::AnchorRight, -1, Qt::AnchorRight, 10) + + << BasicData(-1, Qt::AnchorTop, 0, Qt::AnchorTop, 0) + << BasicData(-1, Qt::AnchorTop, 1, Qt::AnchorTop, 0) + << BasicData(-1, Qt::AnchorTop, 2, Qt::AnchorTop, 0) + ; + + theSizeHint + << AnchorItemSizeHint( 0, 50, 100, 0, 50, 100 ) + << AnchorItemSizeHint( 0, 50, 100, 0, 50, 100 ) + << AnchorItemSizeHint( 0, 50, 100, 0, 50, 100 ) + ; + theResult + << BasicResult(0, QRectF(10, 0, 40, 50) ) + << BasicResult(1, QRectF(60, 0, 40, 50) ) + << BasicResult(2, QRectF(40, 0, 60, 50) ) + ; + + ; + + QTest::newRow("Three, the same sizehint, one center anchor") << QSizeF(110, 50) << theData << theSizeHint << theResult; + } +} + +void tst_QGraphicsAnchorLayout1::testComplexCases() +{ + QFETCH(QSizeF, size); + QFETCH(BasicLayoutTestDataList, data); + QFETCH(AnchorItemSizeHintList, sizehint); + QFETCH(BasicLayoutTestResultList, result); + + QGraphicsWidget *widget = new QGraphicsWidget; + + // Determine amount of widgets to add. + int widgetCount = -1; + for (int i = 0; i < data.count(); ++i) { + const BasicLayoutTestData item = data[i]; + widgetCount = qMax(widgetCount, item.firstIndex); + widgetCount = qMax(widgetCount, item.secondIndex); + } + ++widgetCount; // widgetCount is max of indices. + + // Create dummy widgets + QList<QGraphicsWidget *> widgets; + for (int i = 0; i < widgetCount; ++i) { + TestWidget *w = new TestWidget; + + w->setMinimumWidth( sizehint[i].hmin ); + w->setPreferredWidth( sizehint[i].hpref ); + w->setMaximumWidth( sizehint[i].hmax ); + + w->setMinimumHeight( sizehint[i].vmin ); + w->setPreferredHeight( sizehint[i].vpref ); + w->setMaximumHeight( sizehint[i].vmax ); + + widgets << w; + } + + // Setup anchor layout + TheAnchorLayout *layout = new TheAnchorLayout; + + for (int i = 0; i < data.count(); ++i) { + const BasicLayoutTestData item = data[i]; + layout->setAnchor( + getItem(item.firstIndex, widgets, layout), + item.firstEdge, + getItem(item.secondIndex, widgets, layout), + item.secondEdge, + item.spacing ); + } + + widget->setLayout(layout); + widget->setContentsMargins(0,0,0,0); + + widget->setMinimumSize(size); + widget->setMaximumSize(size); + +// QTest::qWait(500); // layouting is asynchronous.. + + // Validate + for (int i = 0; i < result.count(); ++i) { + const BasicLayoutTestResult item = result[i]; + QCOMPARE(widgets[item.index]->geometry(), item.rect); + } + + // Test mirrored mode + widget->setLayoutDirection(Qt::RightToLeft); + layout->activate(); + // Validate + for (int j = 0; j < result.count(); ++j) { + const BasicLayoutTestResult item = result[j]; + QRectF mirroredRect(item.rect); + // only valid cases are mirrored + if (mirroredRect.isValid()){ + mirroredRect.moveLeft(size.width()-item.rect.width()-item.rect.left()); + } + QCOMPARE(widgets[item.index]->geometry(), mirroredRect); + delete widgets[item.index]; + } + + delete widget; +} +#endif //TEST_COMPLEX_CASES + + +QTEST_MAIN(tst_QGraphicsAnchorLayout1) +#include "tst_qgraphicsanchorlayout1.moc" +//----------------------------------------------------------------------------- + diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 304330e..2f2a268 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -2920,18 +2920,16 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() Q_CHECK_PAINTEVENTS QGraphicsScene scene; - EventTester *tester = new EventTester; - scene.addItem(tester); - tester->setAcceptsHoverEvents(true); - QGraphicsView view(&scene); view.show(); #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(250); - qApp->processEvents(); - qApp->processEvents(); + EventTester *tester = new EventTester; + scene.addItem(tester); + tester->setAcceptsHoverEvents(true); QTRY_COMPARE(tester->repaints, 1); @@ -2945,7 +2943,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() int npaints = tester->repaints; qApp->processEvents(); qApp->processEvents(); - QCOMPARE(tester->events.size(), 3); // activate + enter + move + QCOMPARE(tester->events.size(), 2); // enter + move QCOMPARE(tester->repaints, npaints + 1); QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); @@ -2959,7 +2957,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() qApp->processEvents(); qApp->processEvents(); - QCOMPARE(tester->events.size(), 4); + QCOMPARE(tester->events.size(), 3); QCOMPARE(tester->repaints, npaints + 1); QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); @@ -2973,7 +2971,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() qApp->processEvents(); qApp->processEvents(); - QCOMPARE(tester->events.size(), 5); + QCOMPARE(tester->events.size(), 4); QCOMPARE(tester->repaints, npaints + 2); QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverLeave); } @@ -6510,6 +6508,9 @@ void tst_QGraphicsItem::cacheMode() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + // Increase the probability of window activation + // not causing another repaint of test items. + QTest::qWait(250); EventTester *tester = new EventTester; EventTester *testerChild = new EventTester; diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index c86d9e3..32b4420 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -1316,6 +1316,7 @@ void tst_QGraphicsProxyWidget::paintEvent() //make sure we flush all the paint events QTest::qWait(250); + QTRY_VERIFY(proxy.paintCount > 1); proxy.paintCount = 0; w->update(); @@ -2071,6 +2072,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() QApplication::setActiveWindow(&window); window.activateWindow(); QTest::qWait(125); + QTRY_COMPARE(QApplication::activeWindow(), &window); leftDial->setFocus(); QTest::qWait(125); @@ -2207,6 +2209,7 @@ void tst_QGraphicsProxyWidget::setFocus_simpleWidget() QApplication::setActiveWindow(&window); window.activateWindow(); QTest::qWait(125); + QTRY_COMPARE(QApplication::activeWindow(), &window); leftDial->setFocus(); QTest::qWait(125); @@ -2279,6 +2282,7 @@ void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets() QApplication::setActiveWindow(&window); window.activateWindow(); QTest::qWait(125); + QTRY_COMPARE(QApplication::activeWindow(), &window); leftDial->setFocus(); QTest::qWait(125); @@ -2358,6 +2362,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets() QApplication::setActiveWindow(&window); window.activateWindow(); QTest::qWait(125); + QTRY_COMPARE(QApplication::activeWindow(), &window); leftDial->setFocus(); QTest::qWait(125); @@ -3350,7 +3355,9 @@ void tst_QGraphicsProxyWidget::clickFocus() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(250); + QApplication::setActiveWindow(&view); + QTest::qWait(25); + QTRY_COMPARE(QApplication::activeWindow(), &view); QVERIFY(!proxy->hasFocus()); QVERIFY(!proxy->widget()->hasFocus()); diff --git a/tests/auto/qgroupbox/tst_qgroupbox.cpp b/tests/auto/qgroupbox/tst_qgroupbox.cpp index 5773804..20eec7e 100644 --- a/tests/auto/qgroupbox/tst_qgroupbox.cpp +++ b/tests/auto/qgroupbox/tst_qgroupbox.cpp @@ -467,6 +467,7 @@ void tst_QGroupBox::propagateFocus() QGroupBox box; QLineEdit lineEdit(&box); box.show(); + QApplication::setActiveWindow(&box); box.setFocus(); QTest::qWait(250); QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit)); diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index cab8fda..c0d5051 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -719,13 +719,14 @@ void tst_QImageReader::gifHandlerBugs() void tst_QImageReader::animatedGif() { - QImageReader io(prefix + "qt.gif"); - QImage image= io.read(); - int i=0; + QImageReader io(":images/qt.gif"); + QImage image = io.read(); + QVERIFY(!image.isNull()); + int i = 0; while(!image.isNull()){ - QString frameName = QString(prefix + "qt%1.gif").arg(++i); + QString frameName = QString(":images/qt%1.gif").arg(++i); QCOMPARE(image, QImage(frameName)); - image=io.read(); + image = io.read(); } } #endif diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp index dbbbd1c..5d1034a 100644 --- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp @@ -475,7 +475,7 @@ void tst_QItemDelegate::font() QApplication::sendPostedEvents(); //glib workaround #endif - QCOMPARE(delegate->displayText, item->text()); + QTRY_COMPARE(delegate->displayText, item->text()); if (properties.contains("italic")) { QCOMPARE(delegate->displayFont.italic(), item->font().italic()); } @@ -900,11 +900,8 @@ void tst_QItemDelegate::decoration() item->setSelected(true); QApplication::processEvents(); -#ifdef Q_WS_QWS - QApplication::sendPostedEvents(); //glib workaround -#endif - QCOMPARE(delegate.decorationRect.size(), expected); + QTRY_COMPARE(delegate.decorationRect.size(), expected); } void tst_QItemDelegate::editorEvent_data() @@ -1166,7 +1163,7 @@ void tst_QItemDelegate::task257859_finalizeEdit() QCOMPARE(editor->hasFocus(), true); QDialog dialog; - QTimer::singleShot(100, &dialog, SLOT(close())); + QTimer::singleShot(500, &dialog, SLOT(close())); dialog.exec(); QTRY_VERIFY(!editor); } diff --git a/tests/auto/qitemview/tst_qitemview.cpp b/tests/auto/qitemview/tst_qitemview.cpp index 3251ceb..58d7e24 100644 --- a/tests/auto/qitemview/tst_qitemview.cpp +++ b/tests/auto/qitemview/tst_qitemview.cpp @@ -45,6 +45,9 @@ #include "viewstotest.cpp" #include <stdlib.h> +#if defined(Q_OS_UNIX) +#include <time.h> +#endif #if defined(Q_OS_WIN) #include <time.h> #if defined(Q_OS_WINCE) diff --git a/tests/auto/qkeysequence/qkeysequence.pro b/tests/auto/qkeysequence/qkeysequence.pro index 6566340..bd85402 100644 --- a/tests/auto/qkeysequence/qkeysequence.pro +++ b/tests/auto/qkeysequence/qkeysequence.pro @@ -1,6 +1,4 @@ load(qttest_p4) SOURCES += tst_qkeysequence.cpp -TRANSLATIONS += keys_de.ts - - +RESOURCES += qkeysequence.qrc
\ No newline at end of file diff --git a/tests/auto/qkeysequence/qkeysequence.qrc b/tests/auto/qkeysequence/qkeysequence.qrc new file mode 100644 index 0000000..e224faa --- /dev/null +++ b/tests/auto/qkeysequence/qkeysequence.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource> + <file>keys_de.qm</file> + <file>qt_de.qm</file> + </qresource> +</RCC> diff --git a/tests/auto/qkeysequence/qt_de.qm b/tests/auto/qkeysequence/qt_de.qm Binary files differnew file mode 100644 index 0000000..595e4d7 --- /dev/null +++ b/tests/auto/qkeysequence/qt_de.qm diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp index 88d1d55..1c257bf 100644 --- a/tests/auto/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp @@ -166,9 +166,9 @@ tst_QKeySequence::~tst_QKeySequence() void tst_QKeySequence::initTestCase() { ourTranslator = new QTranslator(this); - ourTranslator->load(QLatin1String("keys_de"), "."); + ourTranslator->load(":/keys_de"); qtTranslator = new QTranslator(this); - qtTranslator->load(QLatin1String("qt_de"), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + qtTranslator->load(":/qt_de"); } void tst_QKeySequence::operatorQString_data() diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 3a81212..1417e69 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -339,6 +339,7 @@ void tst_QLineEdit::initTestCase() testWidget->resize(200,50); testWidget->show(); + QApplication::setActiveWindow(testWidget); #ifdef Q_WS_X11 // to be safe and avoid failing setFocus with window managers qt_x11_wait_for_window_manager(testWidget); diff --git a/tests/auto/qmdiarea/tst_qmdiarea.cpp b/tests/auto/qmdiarea/tst_qmdiarea.cpp index 1936c5b..65f1937 100644 --- a/tests/auto/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/qmdiarea/tst_qmdiarea.cpp @@ -1769,7 +1769,7 @@ void tst_QMdiArea::tileSubWindows() qt_x11_wait_for_window_manager(&workspace); #endif qApp->processEvents(); - QCOMPARE(workspace.size(), QSize(150, 150)); + QTRY_COMPARE(workspace.size(), QSize(150, 150)); // Horizontal scroll bar. QScrollBar *hBar = workspace.horizontalScrollBar(); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 5d14d88..9515d87 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -236,6 +236,8 @@ private slots: void clippingBug(); void emptyClip(); + void taskQT4444_dontOverflowDashOffset(); + private: void fillData(); QColor baseColor( int k, int intensity=255 ); @@ -4287,5 +4289,28 @@ void tst_QPainter::drawImage_1x1() QCOMPARE(img, expected); } +void tst_QPainter::taskQT4444_dontOverflowDashOffset() +{ + QPainter p; + + QPen pen; + pen.setWidth(2); + pen.setStyle(Qt::DashDotLine); + + QPointF point[4]; + point[0] = QPointF(182.50868749707968,347.78457234212630); + point[1] = QPointF(182.50868749707968,107.22501998401277); + point[2] = QPointF(182.50868749707968,107.22501998401277); + point[3] = QPointF(520.46600762283651,107.22501998401277); + + QImage crashImage(QSize(1000, 120), QImage::Format_ARGB32_Premultiplied); + p.begin(&crashImage); + p.setPen(pen); + p.drawLines(point, 2); + p.end(); + + QVERIFY(true); // Don't crash +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" diff --git a/tests/auto/qpixmap/qpixmap.pro b/tests/auto/qpixmap/qpixmap.pro index 02ed3f2..31d6eaa 100644 --- a/tests/auto/qpixmap/qpixmap.pro +++ b/tests/auto/qpixmap/qpixmap.pro @@ -14,6 +14,9 @@ wince*: { } symbian*: { DEPLOYMENT_PLUGIN += qmng LIBS += -lfbscli.dll -lbitgdi.dll -lgdi.dll + contains(QT_CONFIG, openvg) { + LIBS += $$QMAKE_LIBS_OPENVG + } } else { DEFINES += SRCDIR=\\\"$$PWD\\\" win32:LIBS += -lgdi32 -luser32 diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp index 77737ed..d6df94b 100644 --- a/tests/auto/qprinter/tst_qprinter.cpp +++ b/tests/auto/qprinter/tst_qprinter.cpp @@ -48,6 +48,7 @@ #include <qpagesetupdialog.h> #include <qpainter.h> #include <qprintdialog.h> +#include <qprinterinfo.h> #ifdef QT3_SUPPORT #include <q3paintdevicemetrics.h> #endif @@ -557,6 +558,8 @@ void tst_QPrinter::changingOutputFormat() void tst_QPrinter::outputFormatFromSuffix() { + if (QPrinterInfo::availablePrinters().size() == 0) + QSKIP("No printers available.", SkipAll); QPrinter p; QVERIFY(p.outputFormat() == QPrinter::NativeFormat); p.setOutputFileName("test.ps"); diff --git a/tests/auto/qregexp/tst_qregexp.cpp b/tests/auto/qregexp/tst_qregexp.cpp index 7496ec6..86d831e 100644 --- a/tests/auto/qregexp/tst_qregexp.cpp +++ b/tests/auto/qregexp/tst_qregexp.cpp @@ -70,6 +70,10 @@ private slots: void matchedLength(); void wildcard_data(); void wildcard(); + void testEscapingWildcard_data(); + void testEscapingWildcard(); + void testInvalidWildcard_data(); + void testInvalidWildcard(); void caretAnchoredOptimization(); void isEmpty(); void prepareEngineOptimization(); @@ -909,10 +913,79 @@ void tst_QRegExp::wildcard() QFETCH( int, foundIndex ); QRegExp r( rxp ); - r.setPatternSyntax(QRegExp::Wildcard); + r.setPatternSyntax(QRegExp::WildcardUnix); QCOMPARE( r.indexIn( string ), foundIndex ); } +void tst_QRegExp::testEscapingWildcard_data(){ + QTest::addColumn<QString>("pattern"); + QTest::addColumn<QString>("teststring"); + QTest::addColumn<bool>("isMatching"); + + QTest::newRow("[ Not escaped") << "[Qt;" << "[Qt;" << false; + QTest::newRow("[ Escaped") << "\\[Qt;" << "[Qt;" << true; + + QTest::newRow("] Not escaped") << "]Ik;" << "]Ik;" << false; + QTest::newRow("] Escaped") << "\\]Ip;" << "]Ip;" << true; + + QTest::newRow("? Not escaped valid") << "?Ou:" << ".Ou:" << true; + QTest::newRow("? Not escaped invalid") << "?Tr;" << "Tr;" << false; + QTest::newRow("? Escaped") << "\\?O;" << "?O;" << true; + + QTest::newRow("[] not escaped") << "[lL]" << "l" << true; + QTest::newRow("case [[]") << "[[abc]" << "[" << true; + QTest::newRow("case []abc] match ]") << "[]abc]" << "]" << true; + QTest::newRow("case []abc] match a") << "[]abc]" << "a" << true; + QTest::newRow("case [abc] match a") << "[abc]" << "a" << true; + QTest::newRow("case []] don't match [") << "[]abc]" << "[" << false; + QTest::newRow("case [^]abc] match d") << "[^]abc]" << "d" << true; + QTest::newRow("case [^]abc] don't match ]") << "[^]abc]" << "]" << false; + + QTest::newRow("* Not escaped with char") << "*Te;" << "12345Te;" << true; + QTest::newRow("* Not escaped without char") << "*Ch;" << "Ch;" << true; + QTest::newRow("* Not escaped invalid") << "*Ro;" << "o;" << false; + QTest::newRow("* Escaped") << "\\[Cks;" << "[Cks;" << true; + + QTest::newRow("a true '\\' in input") << "\\Qt;" << "\\Qt;" << true; + QTest::newRow("two true '\\' in input") << "\\\\Qt;" << "\\\\Qt;" << true; + QTest::newRow("a '\\' at the end") << "\\\\Qt;" << "\\\\Qt;" << true; + +} +void tst_QRegExp::testEscapingWildcard(){ + QFETCH(QString, pattern); + + QRegExp re(pattern); + re.setPatternSyntax(QRegExp::WildcardUnix); + + QFETCH(QString, teststring); + QFETCH(bool, isMatching); + QCOMPARE(re.exactMatch(teststring), isMatching); +} + +void tst_QRegExp::testInvalidWildcard_data(){ + QTest::addColumn<QString>("pattern"); + QTest::addColumn<bool>("isValid"); + + QTest::newRow("valid []") << "[abc]" << true; + QTest::newRow("invalid [") << "[abc" << false; + QTest::newRow("ending [") << "abc[" << false; + QTest::newRow("ending ]") << "abc]" << false; + QTest::newRow("ending [^") << "abc[^" << false; + QTest::newRow("ending [\\") << "abc[\\" << false; + QTest::newRow("ending []") << "abc[]" << false; + QTest::newRow("ending [[") << "abc[[" << false; + +} +void tst_QRegExp::testInvalidWildcard(){ + QFETCH(QString, pattern); + + QRegExp re(pattern); + re.setPatternSyntax(QRegExp::Wildcard); + + QFETCH(bool, isValid); + QCOMPARE(re.isValid(), isValid); +} + void tst_QRegExp::caretAnchoredOptimization() { QString s = "---babnana----"; diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 4bea26d..eb95d611c 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -191,6 +191,9 @@ private slots: void task_233829_data() { generic_data("QPSQL"); } void task_233829(); + void sqlServerReturn0_data() { generic_data(); } + void sqlServerReturn0(); + private: // returns all database connections @@ -312,6 +315,13 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) tablenames << qTableName( "task_250026" ); tablenames << qTableName( "task_234422" ); + if (tst_Databases::isSqlServer( db )) { + QSqlQuery q( db ); + q.exec("DROP PROCEDURE " + qTableName("test141895_proc")); + } + + tablenames << qTableName("test141895"); + tst_Databases::safeDropTables( db, tablenames ); } @@ -2808,5 +2818,33 @@ void tst_QSqlQuery::task_233829() QVERIFY_SQL(q,exec()); } +void tst_QSqlQuery::sqlServerReturn0() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + if (!tst_Databases::isSqlServer( db )) + QSKIP("SQL Server specific test", SkipSingle); + + QString tableName(qTableName("test141895")), procName(qTableName("test141895_proc")); + QSqlQuery q( db ); + q.exec("DROP TABLE " + tableName); + q.exec("DROP PROCEDURE " + procName); + QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+" (id integer)")); + QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" (id) VALUES (1)")); + QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" (id) VALUES (2)")); + QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" (id) VALUES (2)")); + QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" (id) VALUES (3)")); + QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" (id) VALUES (1)")); + QVERIFY_SQL(q, exec("CREATE PROCEDURE "+procName+ + " AS " + "SELECT * FROM "+tableName+" WHERE ID = 2 " + "RETURN 0")); + + QVERIFY_SQL(q, exec("{CALL "+procName+"}")); + + QVERIFY_SQL(q, next()); +} + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 8d9a50c..dbf1aa4 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -43,6 +43,7 @@ #include <QtGui/QtGui> #include <QtTest/QtTest> #include "../../shared/util.h" +#include "private/qapplication_p.h" //TESTED_CLASS= //TESTED_FILES= @@ -179,6 +180,7 @@ private slots: void task240266_veryBigColumn(); void task248688_autoScrollNavigation(); void task259308_scrollVerticalHeaderSwappedSections(); + void task191545_dragSelectRows(); void mouseWheel_data(); void mouseWheel(); @@ -2277,7 +2279,7 @@ void tst_QTableView::scrollTo_data() << (int)QAbstractItemView::ScrollPerItem << (int)QAbstractItemView::ScrollPerItem << 10 << 10 // table - << 40 << 40 // size + << 80 << 80 // size << -1 << -1 // hide << 0 << 0 // cell << 1 << 1 // span @@ -2289,7 +2291,7 @@ void tst_QTableView::scrollTo_data() << (int)QAbstractItemView::ScrollPerPixel << (int)QAbstractItemView::ScrollPerPixel << 10 << 10 // table - << 40 << 40 // size + << 80 << 80 // size << -1 << -1 // hide << 0 << 0 // cell << 1 << 1 // span @@ -2301,7 +2303,7 @@ void tst_QTableView::scrollTo_data() << (int)QAbstractItemView::ScrollPerItem << (int)QAbstractItemView::ScrollPerItem << 10 << 10 // table - << 40 << 40 // size + << 80 << 80 // size << 3 << 3 // hide << 5 << 5 // cell << 1 << 1 // span @@ -2334,6 +2336,7 @@ void tst_QTableView::scrollTo() QtTestTableView view; view.show(); + // resizing to this size will ensure that there can ONLY_BE_ONE_CELL inside the view. QSize forcedSize(columnWidth * 2, rowHeight * 2); view.resize(forcedSize); QTest::qWait(0); @@ -3300,5 +3303,117 @@ void tst_QTableView::task259308_scrollVerticalHeaderSwappedSections() QTRY_COMPARE(tv.rowAt(tv.viewport()->height() - 1), tv.verticalHeader()->logicalIndex(model.rowCount() - 1)); } +template <typename T> +struct ValueSaver { + T &var, value; + ValueSaver(T &v) : var(v), value(v) { } + ~ValueSaver() { var = value; } +}; + +void tst_QTableView::task191545_dragSelectRows() +{ + QStandardItemModel model(10, 10); + QTableView table; + table.setModel(&model); + table.setSelectionBehavior(QAbstractItemView::SelectItems); + table.setSelectionMode(QAbstractItemView::ExtendedSelection); + table.setMinimumSize(1000, 400); + table.show(); + QTest::qWait(200); + + ValueSaver<Qt::KeyboardModifiers> saver(QApplicationPrivate::modifier_buttons); + QApplicationPrivate::modifier_buttons = Qt::ControlModifier; + + { + QRect cellRect = table.visualRect(model.index(3, 0)); + QHeaderView *vHeader = table.verticalHeader(); + QWidget *vHeaderVp = vHeader->viewport(); + QPoint rowPos(5, (cellRect.top() + cellRect.bottom()) / 2); + QMouseEvent rowPressEvent(QEvent::MouseButtonPress, rowPos, Qt::LeftButton, Qt::NoButton, Qt::ControlModifier); + qApp->sendEvent(vHeaderVp, &rowPressEvent); + + for (int i = 0; i < 4; ++i) { + rowPos.setY(rowPos.y() + cellRect.height()); + QMouseEvent moveEvent(QEvent::MouseMove, rowPos, Qt::NoButton, Qt::LeftButton, Qt::ControlModifier); + qApp->sendEvent(vHeaderVp, &moveEvent); + } + QMouseEvent rowReleaseEvent(QEvent::MouseButtonRelease, rowPos, Qt::LeftButton, Qt::NoButton, Qt::ControlModifier); + qApp->sendEvent(vHeaderVp, &rowReleaseEvent); + + for (int i = 0; i < 4; ++i) { + QModelIndex index = model.index(3 + i, 0, table.rootIndex()); + QVERIFY(vHeader->selectionModel()->selectedRows().contains(index)); + } + } + + { + QRect cellRect = table.visualRect(model.index(0, 3)); + QHeaderView *hHeader = table.horizontalHeader(); + QWidget *hHeaderVp = hHeader->viewport(); + QPoint colPos((cellRect.left() + cellRect.right()) / 2, 5); + QMouseEvent colPressEvent(QEvent::MouseButtonPress, colPos, Qt::LeftButton, Qt::NoButton, Qt::ControlModifier); + qApp->sendEvent(hHeaderVp, &colPressEvent); + + for (int i = 0; i < 4; ++i) { + colPos.setX(colPos.x() + cellRect.width()); + QMouseEvent moveEvent(QEvent::MouseMove, colPos, Qt::NoButton, Qt::LeftButton, Qt::ControlModifier); + qApp->sendEvent(hHeaderVp, &moveEvent); + } + QMouseEvent colReleaseEvent(QEvent::MouseButtonRelease, colPos, Qt::LeftButton, Qt::NoButton, Qt::ControlModifier); + qApp->sendEvent(hHeaderVp, &colReleaseEvent); + + for (int i = 0; i < 4; ++i) { + QModelIndex index = model.index(0, 3 + i, table.rootIndex()); + QVERIFY(hHeader->selectionModel()->selectedColumns().contains(index)); + } + } + + { + QRect cellRect = table.visualRect(model.index(2, 2)); + QWidget *tableVp = table.viewport(); + QPoint cellPos = cellRect.center(); + QMouseEvent cellPressEvent(QEvent::MouseButtonPress, cellPos, Qt::LeftButton, Qt::NoButton, Qt::ControlModifier); + qApp->sendEvent(tableVp, &cellPressEvent); + + for (int i = 0; i < 6; ++i) { + cellPos.setX(cellPos.x() + cellRect.width()); + cellPos.setY(cellPos.y() + cellRect.height()); + QMouseEvent moveEvent(QEvent::MouseMove, cellPos, Qt::NoButton, Qt::LeftButton, Qt::ControlModifier); + qApp->sendEvent(tableVp, &moveEvent); + } + QMouseEvent cellReleaseEvent(QEvent::MouseButtonRelease, cellPos, Qt::LeftButton, Qt::NoButton, Qt::ControlModifier); + qApp->sendEvent(tableVp, &cellReleaseEvent); + + for (int i = 0; i < 6; ++i) + for (int j = 0; j < 6; ++j) { + QModelIndex index = model.index(2 + i, 2 + j, table.rootIndex()); + QVERIFY(table.selectionModel()->isSelected(index)); + } + } + + { + QRect cellRect = table.visualRect(model.index(3, 3)); + QWidget *tableVp = table.viewport(); + QPoint cellPos = cellRect.center(); + QMouseEvent cellPressEvent(QEvent::MouseButtonPress, cellPos, Qt::LeftButton, Qt::NoButton, Qt::ControlModifier); + qApp->sendEvent(tableVp, &cellPressEvent); + + for (int i = 0; i < 6; ++i) { + cellPos.setX(cellPos.x() + cellRect.width()); + cellPos.setY(cellPos.y() + cellRect.height()); + QMouseEvent moveEvent(QEvent::MouseMove, cellPos, Qt::NoButton, Qt::LeftButton, Qt::ControlModifier); + qApp->sendEvent(tableVp, &moveEvent); + } + QMouseEvent cellReleaseEvent(QEvent::MouseButtonRelease, cellPos, Qt::LeftButton, Qt::NoButton, Qt::ControlModifier); + qApp->sendEvent(tableVp, &cellReleaseEvent); + + for (int i = 0; i < 6; ++i) + for (int j = 0; j < 6; ++j) { + QModelIndex index = model.index(3 + i, 3 + j, table.rootIndex()); + QVERIFY(!table.selectionModel()->isSelected(index)); + } + } +} + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp index a55c1c6..0877500 100644 --- a/tests/auto/qtimer/tst_qtimer.cpp +++ b/tests/auto/qtimer/tst_qtimer.cpp @@ -88,6 +88,7 @@ private slots: void timerFiresOnlyOncePerProcessEvents_data(); void timerFiresOnlyOncePerProcessEvents(); void timerIdPersistsAfterThreadExit(); + void cancelLongTimer(); }; class TimerHelper : public QObject @@ -602,5 +603,16 @@ void tst_QTimer::timerIdPersistsAfterThreadExit() QVERIFY((timerId & 0xffffff) != (thread.timerId & 0xffffff)); } +void tst_QTimer::cancelLongTimer() +{ + QTimer timer; + timer.setSingleShot(true); + timer.start(1000 * 60 * 60); //set timer for 1 hour (which would overflow Symbian RTimer) + QCoreApplication::processEvents(); + QVERIFY(timer.isActive()); //if the timer completes immediately with an error, then this will fail + timer.stop(); + QVERIFY(!timer.isActive()); +} + QTEST_MAIN(tst_QTimer) #include "tst_qtimer.moc" diff --git a/tests/auto/qtoolbar/tst_qtoolbar.cpp b/tests/auto/qtoolbar/tst_qtoolbar.cpp index 90d7cf4..e4f317c 100644 --- a/tests/auto/qtoolbar/tst_qtoolbar.cpp +++ b/tests/auto/qtoolbar/tst_qtoolbar.cpp @@ -55,6 +55,8 @@ #include <qlineedit.h> #include <qkeysequence.h> +#include "../../shared/util.h" + //TESTED_FILES= QT_FORWARD_DECLARE_CLASS(QAction) @@ -973,12 +975,14 @@ void tst_QToolBar::accel() QSignalSpy spy(action, SIGNAL(triggered(bool))); mw.show(); - QTest::qWait(1000); + QApplication::setActiveWindow(&mw); + QTest::qWait(100); + QTRY_COMPARE(QApplication::activeWindow(), &mw); QTest::keyClick(&mw, Qt::Key_T, Qt::AltModifier); QTest::qWait(300); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); #ifdef Q_WS_MAC qt_set_sequence_auto_mnemonic(false); #endif diff --git a/tests/auto/qtooltip/tst_qtooltip.cpp b/tests/auto/qtooltip/tst_qtooltip.cpp index 5068460..2ad74a3 100644 --- a/tests/auto/qtooltip/tst_qtooltip.cpp +++ b/tests/auto/qtooltip/tst_qtooltip.cpp @@ -42,6 +42,7 @@ #include <QtTest/QtTest> #include <qtooltip.h> +#include "../../shared/util.h" //TESTED_CLASS= //TESTED_FILES= @@ -132,20 +133,24 @@ void tst_QToolTip::task183679() void tst_QToolTip::setPalette() { //the previous test may still have a tooltip pending for deletion - QTest::qWait(100); QVERIFY(!QToolTip::isVisible()); QToolTip::showText(QPoint(), "tool tip text", 0); - QTest::qWait(100); + + QTRY_VERIFY(QToolTip::isVisible()); QWidget *toolTip = 0; foreach (QWidget *widget, QApplication::topLevelWidgets()) { - if (widget->windowType() == Qt::ToolTip) { + if (widget->windowType() == Qt::ToolTip + && widget->objectName() == QLatin1String("qtooltip_label")) + { toolTip = widget; break; } } + QVERIFY(toolTip); + QTRY_VERIFY(toolTip->isVisible()); const QPalette oldPalette = toolTip->palette(); QPalette newPalette = oldPalette; diff --git a/tests/auto/uic3/baseline/customwidgeteditor.ui.err b/tests/auto/uic3/baseline/customwidgeteditor.ui.err index df2b7a9..bf66c02 100644 --- a/tests/auto/uic3/baseline/customwidgeteditor.ui.err +++ b/tests/auto/uic3/baseline/customwidgeteditor.ui.err @@ -1,34 +1,34 @@ -uic3: slot `currentWidgetChanged(Q3ListBoxItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1114 Column: 16 -uic3: slot `currentWidgetChanged(Q3ListBoxItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1120 Column: 16 -uic3: slot `addWidgetClicked()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1126 Column: 16 -uic3: slot `deleteWidgetClicked()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1132 Column: 16 -uic3: slot `classNameChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1138 Column: 16 -uic3: slot `headerFileChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1144 Column: 16 -uic3: slot `widthChanged(int)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1150 Column: 16 -uic3: slot `heightChanged(int)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1156 Column: 16 -uic3: slot `pixmapChoosen()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1162 Column: 16 -uic3: slot `includePolicyChanged(int)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1168 Column: 16 -uic3: slot `chooseHeader()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1174 Column: 16 -uic3: slot `closeClicked()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1180 Column: 16 -uic3: slot `currentSignalChanged(Q3ListBoxItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1186 Column: 16 -uic3: slot `currentSignalChanged(Q3ListBoxItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1192 Column: 16 -uic3: slot `removeSignal()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1198 Column: 16 -uic3: slot `signalNameChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1204 Column: 16 -uic3: slot `currentSlotChanged(Q3ListViewItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1210 Column: 16 -uic3: slot `currentSlotChanged(Q3ListViewItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1216 Column: 16 -uic3: slot `removeSlot()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1222 Column: 16 -uic3: slot `slotNameChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1228 Column: 16 -uic3: slot `slotAccessChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1234 Column: 16 -uic3: slot `currentPropertyChanged(Q3ListViewItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1240 Column: 16 -uic3: slot `currentPropertyChanged(Q3ListViewItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1246 Column: 16 -uic3: slot `removeProperty()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1252 Column: 16 -uic3: slot `propertyNameChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1258 Column: 16 -uic3: slot `propertyTypeChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1264 Column: 16 -uic3: slot `loadDescription()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1270 Column: 16 -uic3: slot `saveDescription()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1276 Column: 16 -uic3: slot `horDataChanged(int)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1282 Column: 16 -uic3: slot `verDataChanged(int)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1288 Column: 16 -uic3: slot `addProperty()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1294 Column: 16 -uic3: slot `widgetIsContainer(bool)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1300 Column: 16 -uic3: slot `addSignal()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1306 Column: 16 -uic3: slot `addSlot()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1312 Column: 16 +uic3: slot `currentWidgetChanged(Q3ListBoxItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1122 Column: 16 +uic3: slot `currentWidgetChanged(Q3ListBoxItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1128 Column: 16 +uic3: slot `addWidgetClicked()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1134 Column: 16 +uic3: slot `deleteWidgetClicked()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1140 Column: 16 +uic3: slot `classNameChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1146 Column: 16 +uic3: slot `headerFileChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1152 Column: 16 +uic3: slot `widthChanged(int)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1158 Column: 16 +uic3: slot `heightChanged(int)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1164 Column: 16 +uic3: slot `pixmapChoosen()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1170 Column: 16 +uic3: slot `includePolicyChanged(int)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1176 Column: 16 +uic3: slot `chooseHeader()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1182 Column: 16 +uic3: slot `closeClicked()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1188 Column: 16 +uic3: slot `currentSignalChanged(Q3ListBoxItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1194 Column: 16 +uic3: slot `currentSignalChanged(Q3ListBoxItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1200 Column: 16 +uic3: slot `removeSignal()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1206 Column: 16 +uic3: slot `signalNameChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1212 Column: 16 +uic3: slot `currentSlotChanged(Q3ListViewItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1218 Column: 16 +uic3: slot `currentSlotChanged(Q3ListViewItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1224 Column: 16 +uic3: slot `removeSlot()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1230 Column: 16 +uic3: slot `slotNameChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1236 Column: 16 +uic3: slot `slotAccessChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1242 Column: 16 +uic3: slot `currentPropertyChanged(Q3ListViewItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1248 Column: 16 +uic3: slot `currentPropertyChanged(Q3ListViewItem*)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1254 Column: 16 +uic3: slot `removeProperty()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1260 Column: 16 +uic3: slot `propertyNameChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1266 Column: 16 +uic3: slot `propertyTypeChanged(QString)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1272 Column: 16 +uic3: slot `loadDescription()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1278 Column: 16 +uic3: slot `saveDescription()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1284 Column: 16 +uic3: slot `horDataChanged(int)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1290 Column: 16 +uic3: slot `verDataChanged(int)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1296 Column: 16 +uic3: slot `addProperty()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1302 Column: 16 +uic3: slot `widgetIsContainer(bool)' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1308 Column: 16 +uic3: slot `addSignal()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1314 Column: 16 +uic3: slot `addSlot()' for widget `CustomWidgetEditorBase' of type `QDialog' is not supported; connection may fail. Line: 1320 Column: 16 diff --git a/tests/auto/uic3/baseline/dbconnections.ui.err b/tests/auto/uic3/baseline/dbconnections.ui.err index d9d726a..416f0dc 100644 --- a/tests/auto/uic3/baseline/dbconnections.ui.err +++ b/tests/auto/uic3/baseline/dbconnections.ui.err @@ -1,5 +1,5 @@ -uic3: slot `newConnection()' for widget `DatabaseConnectionBase' of type `QDialog' is not supported; connection may fail. Line: 282 Column: 16 -uic3: slot `deleteConnection()' for widget `DatabaseConnectionBase' of type `QDialog' is not supported; connection may fail. Line: 288 Column: 16 -uic3: slot `doConnect()' for widget `DatabaseConnectionBase' of type `QDialog' is not supported; connection may fail. Line: 294 Column: 16 -uic3: slot `currentConnectionChanged(QString)' for widget `DatabaseConnectionBase' of type `QDialog' is not supported; connection may fail. Line: 300 Column: 16 -uic3: slot `currentConnectionChanged(QString)' for widget `DatabaseConnectionBase' of type `QDialog' is not supported; connection may fail. Line: 306 Column: 16 +uic3: slot `newConnection()' for widget `DatabaseConnectionBase' of type `QDialog' is not supported; connection may fail. Line: 290 Column: 16 +uic3: slot `deleteConnection()' for widget `DatabaseConnectionBase' of type `QDialog' is not supported; connection may fail. Line: 296 Column: 16 +uic3: slot `doConnect()' for widget `DatabaseConnectionBase' of type `QDialog' is not supported; connection may fail. Line: 302 Column: 16 +uic3: slot `currentConnectionChanged(QString)' for widget `DatabaseConnectionBase' of type `QDialog' is not supported; connection may fail. Line: 308 Column: 16 +uic3: slot `currentConnectionChanged(QString)' for widget `DatabaseConnectionBase' of type `QDialog' is not supported; connection may fail. Line: 314 Column: 16 diff --git a/tests/auto/uic3/baseline/gotolinedialog.ui.err b/tests/auto/uic3/baseline/gotolinedialog.ui.err index 6d40b7a..aab52a6 100644 --- a/tests/auto/uic3/baseline/gotolinedialog.ui.err +++ b/tests/auto/uic3/baseline/gotolinedialog.ui.err @@ -1 +1 @@ -uic3: slot `gotoLine()' for widget `GotoLineDialog' of type `QDialog' is not supported; connection may fail. Line: 165 Column: 31 +uic3: slot `gotoLine()' for widget `GotoLineDialog' of type `QDialog' is not supported; connection may fail. Line: 173 Column: 31 diff --git a/tests/auto/uic3/baseline/listboxeditor.ui.4 b/tests/auto/uic3/baseline/listboxeditor.ui.4 index c641e0e..8de9fa7 100644 --- a/tests/auto/uic3/baseline/listboxeditor.ui.4 +++ b/tests/auto/uic3/baseline/listboxeditor.ui.4 @@ -7,7 +7,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the autotests of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/tests/auto/uic3/baseline/mainwindowwizard.ui.err b/tests/auto/uic3/baseline/mainwindowwizard.ui.err index 28fc54e..53ba5ff 100644 --- a/tests/auto/uic3/baseline/mainwindowwizard.ui.err +++ b/tests/auto/uic3/baseline/mainwindowwizard.ui.err @@ -1,12 +1,12 @@ -uic3: slot `currentToolbarChanged(QString)' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 656 Column: 31 -uic3: slot `toolbarAddAction()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 662 Column: 31 -uic3: slot `toolbarRemoveAction()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 668 Column: 31 -uic3: slot `toolbarActionUp()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 674 Column: 31 -uic3: slot `toolbarActionDown()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 680 Column: 31 -uic3: slot `pageSelected(QString)' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 686 Column: 31 -uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 692 Column: 31 -uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 698 Column: 31 -uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 704 Column: 31 -uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 710 Column: 31 -uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 716 Column: 31 -uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 722 Column: 31 +uic3: slot `currentToolbarChanged(QString)' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 664 Column: 31 +uic3: slot `toolbarAddAction()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 670 Column: 31 +uic3: slot `toolbarRemoveAction()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 676 Column: 31 +uic3: slot `toolbarActionUp()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 682 Column: 31 +uic3: slot `toolbarActionDown()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 688 Column: 31 +uic3: slot `pageSelected(QString)' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 694 Column: 31 +uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 700 Column: 31 +uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 706 Column: 31 +uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 712 Column: 31 +uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 718 Column: 31 +uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 724 Column: 31 +uic3: slot `currentSettingChanged()' for widget `MainWindowWizardBase' of type `Q3Wizard' is not supported; connection may fail. Line: 730 Column: 31 diff --git a/tests/auto/uic3/baseline/paletteeditor.ui.err b/tests/auto/uic3/baseline/paletteeditor.ui.err index 7cc2345..13b1bd9 100644 --- a/tests/auto/uic3/baseline/paletteeditor.ui.err +++ b/tests/auto/uic3/baseline/paletteeditor.ui.err @@ -1,9 +1,9 @@ -uic3: slot `onChoose2ndMainColor()' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 439 Column: 16 -uic3: slot `paletteSelected(int)' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 445 Column: 16 -uic3: slot `onTune()' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 451 Column: 16 -uic3: slot `onChooseMainColor()' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 469 Column: 16 -uic3: slot `onChooseMainColor()' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 475 Column: 16 -uic3: slot `onChoose2ndMainColor()' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 481 Column: 16 +uic3: slot `onChoose2ndMainColor()' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 447 Column: 16 +uic3: slot `paletteSelected(int)' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 453 Column: 16 +uic3: slot `onTune()' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 459 Column: 16 +uic3: slot `onChooseMainColor()' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 477 Column: 16 +uic3: slot `onChooseMainColor()' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 483 Column: 16 +uic3: slot `onChoose2ndMainColor()' for widget `PaletteEditorBase' of type `QDialog' is not supported; connection may fail. Line: 489 Column: 16 uic3: flag 'AlignAuto' for widget 'Q3GroupBox' is not supported uic3: flag 'AlignAuto' for widget 'QLabel' is not supported uic3: flag 'AlignAuto' for widget 'QLabel' is not supported diff --git a/tests/auto/uic3/baseline/paletteeditoradvanced.ui.err b/tests/auto/uic3/baseline/paletteeditoradvanced.ui.err index 5ee7fe3..c6922c0 100644 --- a/tests/auto/uic3/baseline/paletteeditoradvanced.ui.err +++ b/tests/auto/uic3/baseline/paletteeditoradvanced.ui.err @@ -1,12 +1,12 @@ -uic3: slot `paletteSelected(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 656 Column: 16 -uic3: slot `onCentral(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 662 Column: 16 -uic3: slot `onChoosePixmap()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 668 Column: 16 -uic3: slot `onChooseCentralColor()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 674 Column: 16 -uic3: slot `onChooseEffectColor()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 680 Column: 16 -uic3: slot `onEffect(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 686 Column: 16 -uic3: slot `onToggleBuildEffects(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 692 Column: 16 -uic3: slot `showHelp()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 698 Column: 16 -uic3: slot `onToggleBuildInactive(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 716 Column: 16 -uic3: slot `onToggleBuildDisabled(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 722 Column: 16 +uic3: slot `paletteSelected(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 664 Column: 16 +uic3: slot `onCentral(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 670 Column: 16 +uic3: slot `onChoosePixmap()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 676 Column: 16 +uic3: slot `onChooseCentralColor()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 682 Column: 16 +uic3: slot `onChooseEffectColor()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 688 Column: 16 +uic3: slot `onEffect(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 694 Column: 16 +uic3: slot `onToggleBuildEffects(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 700 Column: 16 +uic3: slot `showHelp()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 706 Column: 16 +uic3: slot `onToggleBuildInactive(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 724 Column: 16 +uic3: slot `onToggleBuildDisabled(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 730 Column: 16 uic3: enumerator 'MShape' for widget 'QLabel' is not supported uic3: enumerator 'MShadow' for widget 'QLabel' is not supported diff --git a/tests/auto/uic3/baseline/paletteeditoradvancedbase.ui.err b/tests/auto/uic3/baseline/paletteeditoradvancedbase.ui.err index d5a5c3d..67ab03b 100644 --- a/tests/auto/uic3/baseline/paletteeditoradvancedbase.ui.err +++ b/tests/auto/uic3/baseline/paletteeditoradvancedbase.ui.err @@ -1,10 +1,10 @@ -uic3: slot `paletteSelected(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 599 Column: 16 -uic3: slot `onCentral(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 605 Column: 16 -uic3: slot `onChooseCentralColor()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 611 Column: 16 -uic3: slot `onChooseEffectColor()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 617 Column: 16 -uic3: slot `onEffect(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 623 Column: 16 -uic3: slot `onToggleBuildEffects(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 629 Column: 16 -uic3: slot `onToggleBuildInactive(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 647 Column: 16 -uic3: slot `onToggleBuildDisabled(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 653 Column: 16 +uic3: slot `paletteSelected(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 607 Column: 16 +uic3: slot `onCentral(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 613 Column: 16 +uic3: slot `onChooseCentralColor()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 619 Column: 16 +uic3: slot `onChooseEffectColor()' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 625 Column: 16 +uic3: slot `onEffect(int)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 631 Column: 16 +uic3: slot `onToggleBuildEffects(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 637 Column: 16 +uic3: slot `onToggleBuildInactive(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 655 Column: 16 +uic3: slot `onToggleBuildDisabled(bool)' for widget `PaletteEditorAdvancedBase' of type `QDialog' is not supported; connection may fail. Line: 661 Column: 16 uic3: enumerator 'MShape' for widget 'QLabel' is not supported uic3: enumerator 'MShadow' for widget 'QLabel' is not supported diff --git a/tests/auto/uic3/baseline/richtextfontdialog.ui.err b/tests/auto/uic3/baseline/richtextfontdialog.ui.err index c873980..32922b0 100644 --- a/tests/auto/uic3/baseline/richtextfontdialog.ui.err +++ b/tests/auto/uic3/baseline/richtextfontdialog.ui.err @@ -1 +1 @@ -uic3: property `paletteBackgroundColor' for widget `colorButton' of type `QToolButton' is not supported. Line: 193 Column: 63 +uic3: property `paletteBackgroundColor' for widget `colorButton' of type `QToolButton' is not supported. Line: 201 Column: 63 diff --git a/tests/auto/uic3/baseline/settingsdialog.ui.err b/tests/auto/uic3/baseline/settingsdialog.ui.err index 2fe5907..a3bb5e8 100644 --- a/tests/auto/uic3/baseline/settingsdialog.ui.err +++ b/tests/auto/uic3/baseline/settingsdialog.ui.err @@ -1 +1 @@ -uic3: property `paletteBackgroundColor' for widget `colorButton' of type `QToolButton' is not supported. Line: 161 Column: 75 +uic3: property `paletteBackgroundColor' for widget `colorButton' of type `QToolButton' is not supported. Line: 169 Column: 75 diff --git a/tests/auto/uic3/baseline/wizardeditor.ui.4 b/tests/auto/uic3/baseline/wizardeditor.ui.4 index c0fdf61..ebf2e91 100644 --- a/tests/auto/uic3/baseline/wizardeditor.ui.4 +++ b/tests/auto/uic3/baseline/wizardeditor.ui.4 @@ -7,7 +7,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the autotests of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro b/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro index 4978c35..531e48b 100644 --- a/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro +++ b/tests/auto/xmlpatternsschemats/xmlpatternsschemats.pro @@ -14,7 +14,7 @@ if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { win32:PATTERNIST_SDK = $${PATTERNIST_SDK}d else: PATTERNIST_SDK = $${PATTERNIST_SDK}_debug } -LIBS += -l$$PATTERNIST_SDK +LIBS += -l$$PATTERNIST_SDK -lQtXml INCLUDEPATH += $$QT_SOURCE_TREE/tests/auto/xmlpatternsxqts/lib/ \ $$QT_BUILD_TREE/include/QtXmlPatterns/private \ diff --git a/tests/manual/qcursor/allcursors/main.cpp b/tests/manual/qcursor/allcursors/main.cpp index 9fb7510..4ab8116 100644 --- a/tests/manual/qcursor/allcursors/main.cpp +++ b/tests/manual/qcursor/allcursors/main.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include <QtGui/QApplication> #include "mainwindow.h" diff --git a/tests/manual/qcursor/allcursors/mainwindow.cpp b/tests/manual/qcursor/allcursors/mainwindow.cpp index 0046ddb..cb903ae 100644 --- a/tests/manual/qcursor/allcursors/mainwindow.cpp +++ b/tests/manual/qcursor/allcursors/mainwindow.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "mainwindow.h" #include "ui_mainwindow.h" diff --git a/tests/manual/qcursor/allcursors/mainwindow.h b/tests/manual/qcursor/allcursors/mainwindow.h index e5c731c..25a317a 100644 --- a/tests/manual/qcursor/allcursors/mainwindow.h +++ b/tests/manual/qcursor/allcursors/mainwindow.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef MAINWINDOW_H #define MAINWINDOW_H @@ -20,8 +61,7 @@ public: private: void keyPressEvent(QKeyEvent* event); - -private: + Ui::MainWindow *ui; }; diff --git a/tests/manual/qcursor/grab_override/main.cpp b/tests/manual/qcursor/grab_override/main.cpp index 9fb7510..4ab8116 100644 --- a/tests/manual/qcursor/grab_override/main.cpp +++ b/tests/manual/qcursor/grab_override/main.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include <QtGui/QApplication> #include "mainwindow.h" diff --git a/tests/manual/qcursor/grab_override/mainwindow.cpp b/tests/manual/qcursor/grab_override/mainwindow.cpp index 27dd0e7..4afa9da 100644 --- a/tests/manual/qcursor/grab_override/mainwindow.cpp +++ b/tests/manual/qcursor/grab_override/mainwindow.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "mainwindow.h" #include "ui_mainwindow.h" diff --git a/tests/manual/qcursor/grab_override/mainwindow.h b/tests/manual/qcursor/grab_override/mainwindow.h index 0b1f694..34b5d73 100644 --- a/tests/manual/qcursor/grab_override/mainwindow.h +++ b/tests/manual/qcursor/grab_override/mainwindow.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef MAINWINDOW_H #define MAINWINDOW_H |