diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2009-10-20 08:28:49 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-10-20 08:28:49 (GMT) |
commit | 1a11cc88e8516097e73d7aefc44c9a97ea0b5aef (patch) | |
tree | 0d1e57ee49db51982083f1fbdba19f5f852f9bf4 /tests/auto | |
parent | eeac9aa8d51b11f3040dcf818cec0a58cd0898f0 (diff) | |
parent | 93550050f4fe4f411bfbd80d7b30ff5bc8a20df7 (diff) | |
download | Qt-1a11cc88e8516097e73d7aefc44c9a97ea0b5aef.zip Qt-1a11cc88e8516097e73d7aefc44c9a97ea0b5aef.tar.gz Qt-1a11cc88e8516097e73d7aefc44c9a97ea0b5aef.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt-widget-team into 4.6
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | 200 | ||||
-rw-r--r-- | tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 11 | ||||
-rw-r--r-- | tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 14 | ||||
-rw-r--r-- | tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 7 | ||||
-rw-r--r-- | tests/auto/qlineedit/tst_qlineedit.cpp | 24 | ||||
-rw-r--r-- | tests/auto/qlistview/tst_qlistview.cpp | 24 | ||||
-rw-r--r-- | tests/auto/qtableview/tst_qtableview.cpp | 35 | ||||
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 41 |
9 files changed, 319 insertions, 41 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 286ea2d..7b87969 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -49,6 +49,14 @@ class tst_QGraphicsAnchorLayout : public QObject { Q_OBJECT; +public: + tst_QGraphicsAnchorLayout() : QObject() { + hasSimplification = qgetenv("QT_ANCHORLAYOUT_NO_SIMPLIFICATION").isEmpty(); + } + +private: + bool hasSimplification; + private slots: void simple(); void simple_center(); @@ -73,6 +81,7 @@ private slots: void expandingSequenceFairDistribution(); void expandingParallel(); void floatConflict(); + void infiniteMaxSizes(); }; class RectWidget : public QGraphicsWidget @@ -152,6 +161,15 @@ static bool layoutHasConflict(QGraphicsAnchorLayout *l) return QGraphicsAnchorLayoutPrivate::get(l)->hasConflicts(); } +static bool usedSimplex(QGraphicsAnchorLayout *l, Qt::Orientation o) +{ + QGraphicsAnchorLayoutPrivate::Orientation oo = (o == Qt::Horizontal) ? + QGraphicsAnchorLayoutPrivate::Horizontal : + QGraphicsAnchorLayoutPrivate::Vertical; + + return QGraphicsAnchorLayoutPrivate::get(l)->lastCalculationUsedSimplex[oo]; +} + void tst_QGraphicsAnchorLayout::simple() { QGraphicsWidget *w1 = createItem(); @@ -169,10 +187,16 @@ void tst_QGraphicsAnchorLayout::simple() l->addAnchors(l, w1, Qt::Vertical); l->addAnchors(l, w2, Qt::Vertical); + QCOMPARE(l->count(), 2); + QGraphicsWidget p; p.setLayout(l); + p.adjustSize(); - QCOMPARE(l->count(), 2); + if (hasSimplification) { + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + } } void tst_QGraphicsAnchorLayout::simple_center() @@ -212,6 +236,11 @@ void tst_QGraphicsAnchorLayout::simple_center() QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); QCOMPARE(layoutMaximumSize, QSizeF(200, 20)); + if (hasSimplification) { + QVERIFY(usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + } + delete p; } @@ -309,6 +338,9 @@ void tst_QGraphicsAnchorLayout::layoutDirection() QCOMPARE(checkReverseDirection(p), true); + QVERIFY(usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + delete p; delete view; } @@ -397,6 +429,11 @@ void tst_QGraphicsAnchorLayout::diagonal() QCOMPARE(e->geometry(), QRectF(100.0, 200.0, 75.0, 100.0)); QCOMPARE(p.size(), testA); + if (hasSimplification) { + QVERIFY(usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + } + QCOMPARE(checkReverseDirection(&p), true); c->setMinimumWidth(300); @@ -473,6 +510,9 @@ void tst_QGraphicsAnchorLayout::parallel() QCOMPARE(f->geometry(), QRectF(350, 500, 100, 100)); QCOMPARE(p.size(), layoutMinimumSize); + if (!hasSimplification) + return; + p.resize(layoutPreferredSize); QCOMPARE(a->geometry(), QRectF(0, 0, 150, 100)); QCOMPARE(b->geometry(), QRectF(150, 100, 150, 100)); @@ -493,6 +533,9 @@ void tst_QGraphicsAnchorLayout::parallel() QCOMPARE(e->geometry(), QRectF(375, 400, 175, 100)); QCOMPARE(f->geometry(), QRectF(550, 500, 200, 100)); QCOMPARE(p.size(), layoutMaximumSize); + + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); } void tst_QGraphicsAnchorLayout::parallel2() @@ -538,6 +581,11 @@ void tst_QGraphicsAnchorLayout::parallel2() p.resize(layoutMaximumSize); QCOMPARE(p.size(), layoutMaximumSize); + + if (hasSimplification) { + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + } } void tst_QGraphicsAnchorLayout::snake() @@ -729,6 +777,8 @@ void tst_QGraphicsAnchorLayout::fairDistribution() QCOMPARE(layoutMaximumSize, QSizeF(300.0, 400.0)); p.resize(layoutMinimumSize); + if (!hasSimplification) + QEXPECT_FAIL("", "Without simplification there is no fair distribution.", Abort); QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 20.0, 100.0)); QCOMPARE(b->geometry(), QRectF(20.0, 100.0, 20.0, 100.0)); QCOMPARE(c->geometry(), QRectF(40.0, 200.0, 20.0, 100.0)); @@ -748,6 +798,11 @@ void tst_QGraphicsAnchorLayout::fairDistribution() QCOMPARE(c->geometry(), QRectF(200.0, 200.0, 100.0, 100.0)); QCOMPARE(d->geometry(), QRectF(0.0, 300.0, 300.0, 100.0)); QCOMPARE(p.size(), layoutMaximumSize); + + if (hasSimplification) { + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + } } void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections() @@ -804,6 +859,9 @@ void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections() QCOMPARE(layoutPreferredSize, QSizeF(220.0, 500.0)); QCOMPARE(layoutMaximumSize, QSizeF(400.0, 500.0)); + if (!hasSimplification) + return; + p.resize(layoutMinimumSize); QCOMPARE(a->size(), b->size()); QCOMPARE(a->size(), c->size()); @@ -824,6 +882,9 @@ void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections() QCOMPARE(a->size(), d->size()); QCOMPARE(e->size().width(), 4 * a->size().width()); QCOMPARE(p.size(), layoutMaximumSize); + + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); } void tst_QGraphicsAnchorLayout::proportionalPreferred() @@ -886,6 +947,11 @@ void tst_QGraphicsAnchorLayout::proportionalPreferred() QCOMPARE(a->size().width(), 10 * factor); QCOMPARE(c->size().width(), 14 * factor); QCOMPARE(p.size(), QSizeF(12, 400)); + + if (hasSimplification) { + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + } } void tst_QGraphicsAnchorLayout::example() @@ -969,6 +1035,11 @@ void tst_QGraphicsAnchorLayout::example() QCOMPARE(a->size(), e->size()); QCOMPARE(b->size(), d->size()); QCOMPARE(f->size(), g->size()); + + if (hasSimplification) { + QVERIFY(usedSimplex(l, Qt::Horizontal)); + QVERIFY(usedSimplex(l, Qt::Vertical)); + } } void tst_QGraphicsAnchorLayout::setSpacing() @@ -1225,19 +1296,8 @@ void tst_QGraphicsAnchorLayout::sizePolicy() 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); + // horizontal and vertical + l->addAnchors(l, w1); QGraphicsWidget *p = new QGraphicsWidget; p->setLayout(l); @@ -1287,9 +1347,53 @@ void tst_QGraphicsAnchorLayout::sizePolicy() w1->adjustSize(); QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(0, 0)); - QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(100, 100)); + QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(0, 0)); QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(100, 100)); + // Anchor size policies + w1->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + QGraphicsAnchor *anchor = l->anchor(l, Qt::AnchorLeft, w1, Qt::AnchorLeft); + anchor->setSpacing(10); + + // QSizePolicy::Minimum + anchor->setSizePolicy(QSizePolicy::Minimum); + QApplication::processEvents(); + + QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(60, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(60, 50)); + // The layout has a maximum size of QWIDGETSIZE_MAX, so the result won't exceed that value. + QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(QWIDGETSIZE_MAX, 50)); + + // QSizePolicy::Preferred + anchor->setSizePolicy(QSizePolicy::Preferred); + QApplication::processEvents(); + + QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(50, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(60, 50)); + // The layout has a maximum size of QWIDGETSIZE_MAX, so the result won't exceed that value. + QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(QWIDGETSIZE_MAX, 50)); + + // QSizePolicy::Maximum + anchor->setSizePolicy(QSizePolicy::Maximum); + QApplication::processEvents(); + + QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(50, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(60, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(60, 50)); + + // QSizePolicy::Ignored + anchor->setSizePolicy(QSizePolicy::Ignored); + QApplication::processEvents(); + + QCOMPARE(l->effectiveSizeHint(Qt::MinimumSize), QSizeF(50, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::PreferredSize), QSizeF(50, 50)); + QCOMPARE(l->effectiveSizeHint(Qt::MaximumSize), QSizeF(QWIDGETSIZE_MAX, 50)); + + if (hasSimplification) { + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + } + delete p; delete view; } @@ -1380,6 +1484,11 @@ void tst_QGraphicsAnchorLayout::expandingSequence() QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); QCOMPARE(layoutMaximumSize.width(), qreal(200)); + + if (hasSimplification) { + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + } } void tst_QGraphicsAnchorLayout::expandingSequenceFairDistribution() @@ -1441,6 +1550,11 @@ void tst_QGraphicsAnchorLayout::expandingSequenceFairDistribution() QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); QCOMPARE(layoutMaximumSize.width(), qreal(400)); + if (hasSimplification) { + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + } + // Now we change D to have more "room for growth" from its preferred size // to its maximum size. We expect a proportional fair distribution. Note that // this seems to not conform with what QGraphicsLinearLayout does. @@ -1463,6 +1577,11 @@ void tst_QGraphicsAnchorLayout::expandingSequenceFairDistribution() QCOMPARE(b->geometry().size(), pref + QSizeF(25, 0)); QCOMPARE(c->geometry().size(), pref); QCOMPARE(d->geometry().size(), pref + QSizeF(50, 0)); + + if (hasSimplification) { + QVERIFY(!usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + } } void tst_QGraphicsAnchorLayout::expandingParallel() @@ -1585,5 +1704,56 @@ void tst_QGraphicsAnchorLayout::floatConflict() delete p; } +void tst_QGraphicsAnchorLayout::infiniteMaxSizes() +{ + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + l->setSpacing(0); + + QSizeF min(10, 10); + QSizeF pref(50, 10); + QSizeF max(QWIDGETSIZE_MAX, 10); + + QGraphicsWidget *a = createItem(min, pref, max, "a"); + QGraphicsWidget *b = createItem(min, pref, max, "b"); + QGraphicsWidget *c = createItem(min, pref, max, "c"); + QGraphicsWidget *d = createItem(min, pref, max, "d"); + + //<!-- Trunk --> + setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); + setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 0); + setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft, 0); + setAnchor(l, c, Qt::AnchorRight, d, Qt::AnchorLeft, 0); + setAnchor(l, d, Qt::AnchorRight, l, Qt::AnchorRight, 0); + + a->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + c->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + + QGraphicsWidget p; + p.setLayout(l); + + p.resize(200, 10); + QCOMPARE(a->geometry(), QRectF(0, 0, 50, 10)); + QCOMPARE(b->geometry(), QRectF(50, 0, 50, 10)); + QCOMPARE(c->geometry(), QRectF(100, 0, 50, 10)); + QCOMPARE(d->geometry(), QRectF(150, 0, 50, 10)); + + if (!hasSimplification) + QEXPECT_FAIL("", "Without simplification there is no fair distribution.", Abort); + + p.resize(1000, 10); + QCOMPARE(a->geometry(), QRectF(0, 0, 450, 10)); + QCOMPARE(b->geometry(), QRectF(450, 0, 50, 10)); + QCOMPARE(c->geometry(), QRectF(500, 0, 450, 10)); + QCOMPARE(d->geometry(), QRectF(950, 0, 50, 10)); + + qreal expMaxSize = (QWIDGETSIZE_MAX - 100.0) / 2; + p.resize(QWIDGETSIZE_MAX, 10); + QCOMPARE(a->geometry(), QRectF(0, 0, expMaxSize, 10)); + QCOMPARE(b->geometry(), QRectF(expMaxSize, 0, 50, 10)); + QCOMPARE(c->geometry(), QRectF(expMaxSize + 50, 0, expMaxSize, 10)); + QCOMPARE(d->geometry(), QRectF(QWIDGETSIZE_MAX - 50, 0, 50, 10)); +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index 148b2c8..1c7a159 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -435,7 +435,7 @@ void tst_QGraphicsAnchorLayout1::testAddAndRemoveAnchor() layout->removeAnchor(layout, Qt::AnchorLeft, widget1, Qt::AnchorLeft); QCOMPARE( layout->count(), 4 ); - QCOMPARE( (int)widget1->parentLayoutItem(), 0 ); + QVERIFY( !widget1->parentLayoutItem() ); // test that item is not removed from layout if other anchors remain set layout->setAnchor(widget2, Qt::AnchorLeft, widget3, Qt::AnchorRight, 10); @@ -1711,8 +1711,6 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() // 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); } diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 554292f..e33c7b6 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -104,6 +104,7 @@ private slots: void defaultStretchFactors(); void geometries_data(); void geometries(); + void avoidRecursionInInsertItem(); void task236367_maxSizeHint(); }; @@ -2081,6 +2082,16 @@ void tst_QGraphicsGridLayout::geometries() delete widget; } +void tst_QGraphicsGridLayout::avoidRecursionInInsertItem() +{ + QGraphicsWidget window(0, Qt::Window); + QGraphicsGridLayout *layout = new QGraphicsGridLayout(&window); + QCOMPARE(layout->count(), 0); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsGridLayout::addItem: cannot insert itself"); + layout->addItem(layout, 0, 0); + QCOMPARE(layout->count(), 0); +} + void tst_QGraphicsGridLayout::task236367_maxSizeHint() { QGraphicsWidget *widget = new QGraphicsWidget; diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 4f28df4..546f92d 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -101,6 +101,7 @@ private slots: void updateGeometry(); void layoutDirection(); void removeLayout(); + void avoidRecursionInInsertItem(); // Task specific tests void task218400_insertStretchCrash(); @@ -146,7 +147,7 @@ void tst_QGraphicsLinearLayout::initTestCase() // since the style will influence the results, we have to ensure // that the tests are run using the same style on all platforms #ifdef Q_WS_S60 - QApplication::setStyle(new QWindowsStyle); + QApplication::setStyle(new QWindowsStyle); #else QApplication::setStyle(new QPlastiqueStyle); #endif @@ -332,6 +333,7 @@ void tst_QGraphicsLinearLayout::alignment() widget->resize(newSize); view.show(); widget->show(); + QTest::qWaitForWindowShown(&view); QApplication::processEvents(); int x = 0; @@ -1431,6 +1433,16 @@ void tst_QGraphicsLinearLayout::removeLayout() QCOMPARE(pushButton->geometry(), r2); } +void tst_QGraphicsLinearLayout::avoidRecursionInInsertItem() +{ + QGraphicsWidget window(0, Qt::Window); + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(&window); + QCOMPARE(layout->count(), 0); + QTest::ignoreMessage(QtWarningMsg, "QGraphicsLinearLayout::insertItem: cannot insert itself"); + layout->insertItem(0, layout); + QCOMPARE(layout->count(), 0); +} + void tst_QGraphicsLinearLayout::task218400_insertStretchCrash() { QGraphicsScene *scene = new QGraphicsScene; diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 013a028..2426ce9 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -1287,6 +1287,7 @@ void tst_QGraphicsProxyWidget::paintEvent() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(70); SubQGraphicsProxyWidget proxy; @@ -1297,14 +1298,14 @@ void tst_QGraphicsProxyWidget::paintEvent() w->show(); QTest::qWaitForWindowShown(w); QApplication::processEvents(); - QTest::qWait(50); + QTest::qWait(100); proxy.setWidget(w); scene.addItem(&proxy); //make sure we flush all the paint events QTest::qWait(70); QTRY_VERIFY(proxy.paintCount > 1); - QTest::qWait(70); + QTest::qWait(110); proxy.paintCount = 0; w->update(); @@ -2705,7 +2706,7 @@ void tst_QGraphicsProxyWidget::windowOpacity() view.show(); QTest::qWaitForWindowShown(&view); QApplication::sendPostedEvents(); - QTest::qWait(50); + QTest::qWait(150); qRegisterMetaType<QList<QRectF> >("QList<QRectF>"); QSignalSpy signalSpy(&scene, SIGNAL(changed(const QList<QRectF> &))); diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 8368114..c676959 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -3304,41 +3304,45 @@ void tst_QLineEdit::task174640_editingFinished() layout->addWidget(le2); mw.show(); - QTest::qWait(200); + QApplication::setActiveWindow(&mw); mw.activateWindow(); + QTest::qWaitForWindowShown(&mw); QSignalSpy editingFinishedSpy(le1, SIGNAL(editingFinished())); le1->setFocus(); - QTest::qWait(200); - QVERIFY(le1->hasFocus()); + QTest::qWait(20); + QTRY_VERIFY(le1->hasFocus()); QCOMPARE(editingFinishedSpy.count(), 0); le2->setFocus(); - QTest::qWait(200); - QVERIFY(le2->hasFocus()); + QTest::qWait(20); + QTRY_VERIFY(le2->hasFocus()); QCOMPARE(editingFinishedSpy.count(), 1); editingFinishedSpy.clear(); le1->setFocus(); - QTest::qWait(200); - QVERIFY(le1->hasFocus()); + QTest::qWait(20); + QTRY_VERIFY(le1->hasFocus()); QMenu *testMenu1 = new QMenu(le1); testMenu1->addAction("foo"); testMenu1->addAction("bar"); testMenu1->show(); - QTest::qWait(200); + QTest::qWaitForWindowShown(testMenu1); + QTest::qWait(20); mw.activateWindow(); + delete testMenu1; QCOMPARE(editingFinishedSpy.count(), 0); - QVERIFY(le1->hasFocus()); + QTRY_VERIFY(le1->hasFocus()); QMenu *testMenu2 = new QMenu(le2); testMenu2->addAction("foo2"); testMenu2->addAction("bar2"); testMenu2->show(); - QTest::qWait(200); + QTest::qWaitForWindowShown(testMenu2); + QTest::qWait(20); mw.activateWindow(); delete testMenu2; QCOMPARE(editingFinishedSpy.count(), 1); diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 7599ce6a06..3ee6889 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -116,6 +116,7 @@ private slots: void keyboardSearch(); void shiftSelectionWithNonUniformItemSizes(); void clickOnViewportClearsSelection(); + void task262152_setModelColumnNavigate(); }; // Testing get/set functions @@ -1767,6 +1768,29 @@ void tst_QListView::clickOnViewportClearsSelection() } +void tst_QListView::task262152_setModelColumnNavigate() +{ + QListView view; + QStandardItemModel model(3,2); + model.setItem(0,1,new QStandardItem("[0,1]")); + model.setItem(1,1,new QStandardItem("[1,1]")); + model.setItem(2,1,new QStandardItem("[2,1]")); + + view.setModel(&model); + view.setModelColumn(1); + + view.show(); + QTest::qWait(30); + QTest::keyClick(&view, Qt::Key_Down); + QTest::qWait(10); + QCOMPARE(view.currentIndex(), model.index(1,1)); + QTest::keyClick(&view, Qt::Key_Down); + QTest::qWait(10); + QCOMPARE(view.currentIndex(), model.index(2,1)); + +} + + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index d75cfa7..d8110e1 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -1195,6 +1195,13 @@ void tst_QTableView::moveCursorStrikesBack_data() << 0 << 5 << (IntList() << int(QtTestTableView::MoveNext)) << 1 << 0; + QTest::newRow("Last column disabled. Task QTBUG-3878") << -1 << -1 + << IntList() + << (IntList() << 6) + << QRect() + << 1 << 0 << (IntList() << int(QtTestTableView::MovePrevious)) + << 0 << 5; + QTest::newRow("Span, anchor column hidden") << -1 << 1 << IntList() << IntList() @@ -1250,6 +1257,24 @@ void tst_QTableView::moveCursorStrikesBack_data() << QRect(1, 2, 2, 3) << 5 << 2 << (IntList() << int(QtTestTableView::MoveUp) << int(QtTestTableView::MoveUp)) << 1 << 2; + + IntList fullList; + for (int i = 0; i < 7; ++i) + fullList << i; + + QTest::newRow("All disabled, wrap forward. Timeout => FAIL") << -1 << -1 + << fullList + << fullList + << QRect() + << 1 << 0 << (IntList() << int(QtTestTableView::MoveNext)) + << 1 << 0; + + QTest::newRow("All disabled, wrap backwards. Timeout => FAIL") << -1 << -1 + << fullList + << fullList + << QRect() + << 1 << 0 << (IntList() << int(QtTestTableView::MovePrevious)) + << 1 << 0; } void tst_QTableView::moveCursorStrikesBack() @@ -1272,11 +1297,6 @@ void tst_QTableView::moveCursorStrikesBack() view.hideRow(hideRow); view.hideColumn(hideColumn); - foreach (int row, disableRows) - model.disableRow(row); - foreach (int column, disableColumns) - model.disableColumn(column); - if (span.height() && span.width()) view.setSpan(span.top(), span.left(), span.height(), span.width()); view.show(); @@ -1284,6 +1304,11 @@ void tst_QTableView::moveCursorStrikesBack() QModelIndex index = model.index(startRow, startColumn); view.setCurrentIndex(index); + foreach (int row, disableRows) + model.disableRow(row); + foreach (int column, disableColumns) + model.disableColumn(column); + int newRow = -1; int newColumn = -1; foreach (int cursorMoveAction, cursorMoveActions) { diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 1b898f4..a03f112 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -69,6 +69,9 @@ #include <QtGui/qpaintengine.h> #include <private/qbackingstore_p.h> +#include <QtGui/QGraphicsView> +#include <QtGui/QGraphicsProxyWidget> + #include "../../shared/util.h" @@ -290,6 +293,7 @@ private slots: #ifdef Q_WS_X11 void minAndMaxSizeWithX11BypassWindowManagerHint(); void showHideShow(); + void clean_qt_x11_enforce_cursor(); #endif void compatibilityChildInsertedEvents(); @@ -6194,6 +6198,35 @@ void tst_QWidget::showHideShow() QVERIFY(w.gotExpectedMapNotify); } + +void tst_QWidget::clean_qt_x11_enforce_cursor() +{ + { + QWidget window; + QWidget *w = new QWidget(&window); + QWidget *child = new QWidget(w); + child->setAttribute(Qt::WA_SetCursor, true); + + window.show(); + QApplication::setActiveWindow(&window); + QTest::qWaitForWindowShown(&window); + QTest::qWait(100); + QCursor::setPos(window.geometry().center()); + QTest::qWait(100); + + child->setFocus(); + QApplication::processEvents(); + QTest::qWait(100); + + delete w; + } + + QGraphicsScene scene; + QLineEdit *edit = new QLineEdit; + scene.addWidget(edit); + + // If the test didn't crash, then it passed. +} #endif class EventRecorder : public QObject @@ -7605,11 +7638,11 @@ void tst_QWidget::updateWhileMinimized() QTest::qWaitForWindowShown(&widget); QApplication::processEvents(); QTRY_VERIFY(widget.numPaintEvents > 0); - QTest::qWait(50); + QTest::qWait(150); // Minimize window. widget.showMinimized(); - QTest::qWait(70); + QTest::qWait(110); widget.reset(); @@ -8310,7 +8343,7 @@ public: static bool firstTime = true; if (firstTime) - QTimer::singleShot(150, this, SLOT(resizeMe())); + QTimer::singleShot(250, this, SLOT(resizeMe())); firstTime = false; } @@ -8327,7 +8360,7 @@ void tst_QWidget::moveInResizeEvent() testWidget.setGeometry(50, 50, 200, 200); testWidget.show(); QTest::qWaitForWindowShown(&testWidget); - QTest::qWait(160); + QTest::qWait(300); QRect expectedGeometry(100,100, 100, 100); QTRY_COMPARE(testWidget.geometry(), expectedGeometry); |