diff options
author | Bill King <bill.king@nokia.com> | 2009-12-09 23:07:52 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2009-12-09 23:07:52 (GMT) |
commit | e032c0756df0d11f7a43bcdfbb82cf2d83fe74a4 (patch) | |
tree | 36884ee5c9a9287663c05d5db529a3a0f16b9550 /tests | |
parent | 127d52df97b68fcf54a50e471a0b899d92fda10a (diff) | |
parent | 346d3618bad19714b41ad45715cdef9488ce8969 (diff) | |
download | Qt-e032c0756df0d11f7a43bcdfbb82cf2d83fe74a4.zip Qt-e032c0756df0d11f7a43bcdfbb82cf2d83fe74a4.tar.gz Qt-e032c0756df0d11f7a43bcdfbb82cf2d83fe74a4.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qdesktopservices/tst_qdesktopservices.cpp | 16 | ||||
-rw-r--r-- | tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | 57 | ||||
-rw-r--r-- | tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp | 31 | ||||
-rw-r--r-- | tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 12 | ||||
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 16 | ||||
-rw-r--r-- | tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 45 | ||||
-rw-r--r-- | tests/auto/qlistwidget/tst_qlistwidget.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qmenu/tst_qmenu.cpp | 35 | ||||
-rw-r--r-- | tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 16 | ||||
-rw-r--r-- | tests/manual/qwidget_zorder/main.cpp | 118 | ||||
-rw-r--r-- | tests/manual/qwidget_zorder/qwidget_zorder.pro | 6 |
13 files changed, 337 insertions, 28 deletions
diff --git a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp index 2d9e5dc..c105a97 100644 --- a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp +++ b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp @@ -70,6 +70,7 @@ private slots: void openMailtoUrl(); void openFileUrl_data(); void openFileUrl(); + void openMultipleFileUrls(); #endif void handlers(); void storageLocation_data(); @@ -197,6 +198,7 @@ void tst_qdesktopservices::openMailtoUrl() QFETCH(QUrl, url); QFETCH(bool, result); QCOMPARE(QDesktopServices::openUrl(url), result); + QTest::qWait(5000); } void tst_qdesktopservices::openFileUrl_data() @@ -239,7 +241,19 @@ void tst_qdesktopservices::openFileUrl() QFETCH(QUrl, url); QFETCH(bool, result); QCOMPARE(QDesktopServices::openUrl(url), result); - QTest::qWait(15000); + QTest::qWait(5000); +} + +void tst_qdesktopservices::openMultipleFileUrls() +{ +#ifndef RUN_MANUAL_TESTS + QSKIP("Test disabled -- only for manual purposes", SkipAll); +#endif + + QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/images/image.bmp")), true); + QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/images/image.png")), true); + QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/others/noendofline.txt")), true); + QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/installs/ErrRd.sisx")), true); } #endif diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index aa67ac5..6e78522 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -89,6 +89,7 @@ private slots: void snakeParallelWithLayout(); void parallelToHalfLayout(); void globalSpacing(); + void graphicsAnchorHandling(); }; class RectWidget : public QGraphicsWidget @@ -1196,7 +1197,7 @@ void tst_QGraphicsAnchorLayout::styleDefaults() QSizeF pref(20, 20); QSizeF max (50, 50); - /* + /* create this layout, where a,b have controlType QSizePolicy::RadioButton c,d have controlType QSizePolicy::PushButton: +-------+ @@ -1243,9 +1244,9 @@ void tst_QGraphicsAnchorLayout::styleDefaults() scene.addItem(window); window->show(); - QGraphicsView *view = new QGraphicsView(&scene); - view->resize(200, 200); - view->show(); + QGraphicsView view(&scene); + view.resize(200, 200); + view.show(); window->adjustSize(); QCOMPARE(a->geometry(), QRectF(0, 3, 20, 20)); //radio @@ -1264,10 +1265,13 @@ void tst_QGraphicsAnchorLayout::styleDefaults() window->setStyle(style); window->adjustSize(); QCOMPARE(a->geometry(), QRectF(0, 3, 20, 20)); - QCOMPARE(b->geometry(), QRectF(21, 25, 20, 20)); + QCOMPARE(b->geometry(), QRectF(21, 25, 20, 20)); QCOMPARE(c->geometry(), QRectF(42, 47, 20, 20)); QCOMPARE(d->geometry(), QRectF(63, 69, 20, 20)); QCOMPARE(l->geometry(), QRectF(0, 0, 89, 98)); + + window->setStyle(0); + delete style; } @@ -1776,7 +1780,8 @@ void tst_QGraphicsAnchorLayout::simplificationVsOrder() QGraphicsWidget *b = createItem(min, pref, max, "B"); QGraphicsWidget *c = createItem(min, pref, max, "C"); - QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + QGraphicsWidget frame; + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&frame); // Bulk anchors l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); @@ -1801,7 +1806,6 @@ void tst_QGraphicsAnchorLayout::simplificationVsOrder() l->effectiveSizeHint(Qt::MinimumSize); if (hasSimplification) { - QEXPECT_FAIL("", "Sequential anchors cannot handle children of opposite directions", Continue); QCOMPARE(usedSimplex(l, Qt::Horizontal), false); QCOMPARE(usedSimplex(l, Qt::Vertical), false); } @@ -1846,7 +1850,8 @@ void tst_QGraphicsAnchorLayout::simplificationVsRedundance() QGraphicsWidget *b = createItem(min, pref, max, "B"); QGraphicsWidget *c = createItem(min, pref, max, "C"); - QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + QGraphicsWidget frame; + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&frame); l->addCornerAnchors(a, Qt::TopLeftCorner, l, Qt::TopLeftCorner); l->addCornerAnchors(a, Qt::BottomLeftCorner, l, Qt::BottomLeftCorner); @@ -2016,6 +2021,42 @@ void tst_QGraphicsAnchorLayout::globalSpacing() QCOMPARE(newHSpacing, hSpacing); } +void tst_QGraphicsAnchorLayout::graphicsAnchorHandling() +{ + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(); + QGraphicsWidget *a = createItem(); + + l->addAnchors(l, a); + + QGraphicsAnchor *layoutAnchor = l->anchor(l, Qt::AnchorTop, l, Qt::AnchorBottom); + QGraphicsAnchor *itemAnchor = l->anchor(a, Qt::AnchorTop, a, Qt::AnchorBottom); + QGraphicsAnchor *invalidAnchor = l->anchor(a, Qt::AnchorTop, l, Qt::AnchorBottom); + + // Ensure none of these anchors are accessible. + QVERIFY(layoutAnchor == 0); + QVERIFY(itemAnchor == 0); + QVERIFY(invalidAnchor == 0); + + // Hook the anchors to a QObject + QObject object; + QGraphicsAnchor *userAnchor = l->anchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + userAnchor->setParent(&object); + userAnchor = l->anchor(l, Qt::AnchorBottom, a, Qt::AnchorBottom); + userAnchor->setParent(&object); + userAnchor = l->anchor(l, Qt::AnchorRight, a, Qt::AnchorRight); + userAnchor->setParent(&object); + userAnchor = l->anchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + userAnchor->setParent(&object); + + QCOMPARE(object.children().size(), 4); + + // Delete layout, this will cause all anchors to be deleted internally. + // We expect the public QGraphicsAnchor instances to be deleted too. + delete l; + QCOMPARE(object.children().size(), 0); + + delete a; +} 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 baa1ba1..57dc90d 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -356,6 +356,8 @@ void tst_QGraphicsAnchorLayout1::testItemAt() QVERIFY( layout->itemAt(0) == widget2 ); + delete widget1; + widget->setLayout(layout); delete widget; } @@ -460,6 +462,12 @@ void tst_QGraphicsAnchorLayout1::testAddAndRemoveAnchor() QCOMPARE( layout->count(), 0 ); + delete widget1; + delete widget2; + delete widget3; + delete widget4; + delete widget5; + widget->setLayout(layout); delete widget; } @@ -1740,9 +1748,9 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QRectF actual = truncate(widgets[item.index]->geometry()); QCOMPARE(actual, expected); - delete widgets[item.index]; } + qDeleteAll(widgets); delete widget; } @@ -2231,8 +2239,9 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor() const BasicLayoutTestResult item = result[i]; QCOMPARE(widgets[item.index]->geometry(), item.rect); - delete widgets[item.index]; } + + qDeleteAll(widgets); delete widget; } @@ -2360,7 +2369,7 @@ void tst_QGraphicsAnchorLayout1::testSingleSizePolicy() QFETCH(bool, valid); // create objects - QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsWidget widget; TheAnchorLayout *layout = new TheAnchorLayout; TestWidget *childWidget = new TestWidget; @@ -2370,11 +2379,11 @@ void tst_QGraphicsAnchorLayout1::testSingleSizePolicy() layout->setAnchor( layout, Qt::AnchorTop, childWidget, Qt::AnchorTop, 10 ); layout->setAnchor( childWidget, Qt::AnchorBottom, layout, Qt::AnchorBottom, 10 ); - widget->setLayout( layout ); + widget.setLayout( layout ); // set test case specific: policy and size childWidget->setSizePolicy( policy ); - widget->setGeometry( QRectF( QPoint(0,0), size ) ); + widget.setGeometry( QRectF( QPoint(0,0), size ) ); QCOMPARE( layout->isValid() , valid ); @@ -2516,7 +2525,7 @@ void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy() QFETCH(qreal, width2); // create objects - QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsWidget widget; TheAnchorLayout *layout = new TheAnchorLayout; TestWidget *childWidget1 = new TestWidget; TestWidget *childWidget2 = new TestWidget; @@ -2526,13 +2535,13 @@ void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy() layout->setAnchor( childWidget1, Qt::AnchorRight, childWidget2, Qt::AnchorLeft, 10 ); layout->setAnchor( childWidget2, Qt::AnchorRight, layout, Qt::AnchorRight, 10 ); - widget->setLayout( layout ); + widget.setLayout( layout ); // set test case specific: policy childWidget1->setSizePolicy( policy1 ); childWidget2->setSizePolicy( policy2 ); - widget->setGeometry( QRectF( QPoint(0,0), QSize( 100,100 ) ) ); + widget.setGeometry( QRectF( QPoint(0,0), QSize( 100,100 ) ) ); // check results: if ( width1 == -1.0f ) { @@ -2649,7 +2658,7 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution() QFETCH(qreal, width2); // create objects - QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsWidget widget; TheAnchorLayout *layout = new TheAnchorLayout; TestWidget *childWidget1 = new TestWidget; TestWidget *childWidget2 = new TestWidget; @@ -2659,7 +2668,7 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution() layout->setAnchor( childWidget1, Qt::AnchorRight, childWidget2, Qt::AnchorLeft, 10 ); layout->setAnchor( childWidget2, Qt::AnchorRight, layout, Qt::AnchorRight, 10 ); - widget->setLayout( layout ); + widget.setLayout( layout ); // set test case specific: size hints childWidget1->setMinimumWidth( sizeHints1.value( Qt::MinimumSize ) ); @@ -2670,7 +2679,7 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution() childWidget2->setPreferredWidth( sizeHints2.value( Qt::PreferredSize ) ); childWidget2->setMaximumWidth( sizeHints2.value( Qt::MaximumSize ) ); - widget->setGeometry( QRectF( QPoint(0,0), QSize( 100,100 ) ) ); + widget.setGeometry( QRectF( QPoint(0,0), QSize( 100,100 ) ) ); // check results: if ( width1 == -1.0f ) { diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index d216924..259df4d 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -196,8 +196,8 @@ void tst_QGraphicsEffect::source() // Uninstall effect on QGraphicsItem. effect->reset(); item->setGraphicsEffect(0); - QVERIFY(!effect->source()); - QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceDetached); + QVERIFY(!effect); + effect = new CustomEffect; // The item takes ownership and should delete the effect when destroyed. item->setGraphicsEffect(effect); @@ -249,10 +249,10 @@ void tst_QGraphicsEffect::boundingRect() QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); // Uninstall effect on QGraphicsItem. + QPointer<CustomEffect> ptr = effect; item->setGraphicsEffect(0); - QCOMPARE(effect->boundingRect(), QRectF()); + QVERIFY(!ptr); - delete effect; delete item; } @@ -343,11 +343,11 @@ void tst_QGraphicsEffect::draw() QCOMPARE(item->numRepaints, 0); // Make sure uninstalling an effect triggers a repaint. + QPointer<CustomEffect> ptr = effect; item->setGraphicsEffect(0); + QVERIFY(!ptr); QTest::qWait(50); - QCOMPARE(effect->numRepaints, 0); QCOMPARE(item->numRepaints, 1); - delete effect; } void tst_QGraphicsEffect::opacity() diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 565a3e7..6266933 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -7962,6 +7962,22 @@ void tst_QGraphicsItem::setGraphicsEffect() delete item; QVERIFY(!blurEffect); delete anotherItem; + + // Ensure the effect is uninstalled when deleting it + item = new QGraphicsRectItem(0, 0, 10, 10); + blurEffect = new QGraphicsBlurEffect; + item->setGraphicsEffect(blurEffect); + delete blurEffect; + QVERIFY(!item->graphicsEffect()); + + // Ensure the existing effect is uninstalled and deleted when setting a null effect + blurEffect = new QGraphicsBlurEffect; + item->setGraphicsEffect(blurEffect); + item->setGraphicsEffect(0); + QVERIFY(!item->graphicsEffect()); + QVERIFY(!blurEffect); + + delete item; } void tst_QGraphicsItem::panel() diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index d3087dc..ab110e6 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -146,7 +146,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 +#if defined( Q_WS_S60 )|| defined (Q_WS_WINCE) QApplication::setStyle(new QWindowsStyle); #else QApplication::setStyle(new QPlastiqueStyle); diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 38abc3d..c5e57f7 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -280,6 +280,7 @@ private slots: void task160653_selectionChanged(); void task250680_childClip(); void taskQTBUG_5904_crashWithDeviceCoordinateCache(); + void taskQT657_paintIntoCacheWithTransparentParts(); }; void tst_QGraphicsScene::initTestCase() @@ -1462,6 +1463,7 @@ void tst_QGraphicsScene::focusItemLostFocus() class ClearTestItem : public QGraphicsRectItem { public: + ClearTestItem(QGraphicsItem *parent = 0) : QGraphicsRectItem(parent) {} ~ClearTestItem() { qDeleteAll(items); } QList<QGraphicsItem *> items; }; @@ -1486,6 +1488,11 @@ void tst_QGraphicsScene::clear() scene.addItem(secondItem); QCOMPARE(scene.items().at(0), firstItem); QCOMPARE(scene.items().at(1), secondItem); + + ClearTestItem *thirdItem = new ClearTestItem(firstItem); + QGraphicsItem *forthItem = new QGraphicsRectItem(firstItem); + thirdItem->items += forthItem; + // must not crash even if firstItem deletes secondItem scene.clear(); QVERIFY(scene.items().isEmpty()); @@ -4264,5 +4271,43 @@ void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() // No crash, then it passed! } +void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts() +{ + QWidget *w = new QWidget(); + w->setPalette(Qt::blue); + w->setGeometry(0, 0, 50, 50); + + QGraphicsScene *scene = new QGraphicsScene(); + QGraphicsView *view = new QGraphicsView(scene); + + QGraphicsProxyWidget *proxy = scene->addWidget(w); + proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + proxy->rotate(15); + + view->show(); + QTest::qWaitForWindowShown(view); + w->update(10,10,10,10); + QTest::qWait(50); + + QPixmap pix; + QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(proxy); + QPixmapCache::Key key = itemp->extraItemCache()->deviceData.value(view->viewport()).key; + QVERIFY(QPixmapCache::find(key, &pix)); + + QTransform t = proxy->sceneTransform(); + // Map from scene coordinates to pixmap coordinates. + // X origin in the pixmap is the most-left point + // of the item's boundingRect in the scene. + qreal adjust = t.mapRect(proxy->boundingRect().toRect()).left(); + QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); + QPixmap subpix = pix.copy(rect); + + QImage im = subpix.toImage(); + for(int i = 0; i < im.width(); i++) { + for(int j = 0; j < im.height(); j++) + QCOMPARE(qAlpha(im.pixel(i, j)), 255); + } +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp index cb8f1e9..863c308 100644 --- a/tests/auto/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp @@ -867,6 +867,7 @@ void tst_QListWidget::moveItemsPriv_data() QTest::newRow("Same place") << 5 << 2 << 2 << false; QTest::newRow("Up") << 5 << 4 << 2 << true; QTest::newRow("Down") << 5 << 2 << 4 << true; + QTest::newRow("QTBUG-6532 assert") << 5 << 0 << 1 << false; } void tst_QListWidget::moveItemsPriv() diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 7cdfe46..af10ad1 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -82,7 +82,7 @@ private slots: void keyboardNavigation_data(); void keyboardNavigation(); void focus(); - void overrideMenuAction(); + void overrideMenuAction(); void statusTip(); void widgetActionFocus(); void mouseActivation(); @@ -103,12 +103,14 @@ private slots: void task258920_mouseBorder(); void setFixedWidth(); void deleteActionInTriggered(); + void pushButtonPopulateOnAboutToShow(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); void onStatusMessageChanged(const QString &); void onStatusTipTimer(); void deleteAction(QAction *a) { delete a; } + void populateMenu(); private: void createActions(); QMenu *menus[2], *lastMenu; @@ -258,6 +260,15 @@ void tst_QMenu::onStatusMessageChanged(const QString &s) statustip=s; } +void tst_QMenu::populateMenu(){ + //just adds 3 dummy actions and a separator. + lastMenu->addAction("Foo"); + lastMenu->addAction("Bar"); + lastMenu->addAction("FooBar"); + lastMenu->addSeparator(); + +} + //actual tests void @@ -896,7 +907,29 @@ void tst_QMenu::deleteActionInTriggered() QVERIFY(!a); } +void tst_QMenu::pushButtonPopulateOnAboutToShow() +{ + QPushButton b("Test PushButton"); + b.setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); + lastMenu = new QMenu; + b.setMenu(lastMenu); + const int scrNumber = QApplication::desktop()->screenNumber(&b); + connect(lastMenu, SIGNAL(aboutToShow()), this, SLOT(populateMenu())); + b.show(); + const QRect screen = QApplication::desktop()->screenGeometry(scrNumber); + b.move(10, screen.bottom()-b.height()-5); + QTest::qWaitForWindowShown(&b); + QTimer::singleShot(300,lastMenu, SLOT(hide())); + QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center()); + QVERIFY(!lastMenu->geometry().intersects(b.geometry())); + + b.move(10, screen.bottom()-lastMenu->height()-5); + QTimer::singleShot(300,lastMenu, SLOT(hide())); + QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center()); + QVERIFY(!lastMenu->geometry().intersects(b.geometry())); + +} QTEST_MAIN(tst_QMenu) diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index ed9206c..0cb08f9 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -73,6 +73,7 @@ private slots: void forwardDeclaration2(); void memoryManagement(); void downCast(); + void functionCallDownCast(); void upCast(); void qobjectWeakManagement(); void noSharedPointerFromWeakQObject(); @@ -503,6 +504,15 @@ void tst_QSharedPointer::downCast() QCOMPARE(DerivedData::derivedDestructorCounter, destructorCount + 1); } +void functionDataByValue(QSharedPointer<Data> p) { Q_UNUSED(p); }; +void functionDataByRef(const QSharedPointer<Data> &p) { Q_UNUSED(p); }; +void tst_QSharedPointer::functionCallDownCast() +{ + QSharedPointer<DerivedData> p(new DerivedData()); + functionDataByValue(p); + functionDataByRef(p); +} + void tst_QSharedPointer::upCast() { QSharedPointer<Data> baseptr = QSharedPointer<Data>(new DerivedData); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 9960f47..3e14b56 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -9549,6 +9549,22 @@ void tst_QWidget::setGraphicsEffect() delete widget; QVERIFY(!blurEffect); delete anotherWidget; + + // Ensure the effect is uninstalled when deleting it + widget = new QWidget; + blurEffect = new QGraphicsBlurEffect; + widget->setGraphicsEffect(blurEffect); + delete blurEffect; + QVERIFY(!widget->graphicsEffect()); + + // Ensure the existing effect is uninstalled and deleted when setting a null effect + blurEffect = new QGraphicsBlurEffect; + widget->setGraphicsEffect(blurEffect); + widget->setGraphicsEffect(0); + QVERIFY(!widget->graphicsEffect()); + QVERIFY(!blurEffect); + + delete widget; } void tst_QWidget::activateWindow() diff --git a/tests/manual/qwidget_zorder/main.cpp b/tests/manual/qwidget_zorder/main.cpp new file mode 100644 index 0000000..fe8e0a2 --- /dev/null +++ b/tests/manual/qwidget_zorder/main.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** 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 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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> + +class Widget : public QWidget +{ + Q_OBJECT +public: + Widget() + { + QWidget *stackWidget = new QWidget; + stackWidget->setFixedSize(400, 300); + button = new QPushButton("pushbutton", stackWidget); + plainTextEdit = new QPlainTextEdit(stackWidget); + plainTextEdit->setWordWrapMode(QTextOption::NoWrap); + QString s = "foo bar bar foo foo bar bar foo"; + for (int i = 0; i < 10; ++i) { + plainTextEdit->appendPlainText(s); + s.remove(1, 2); + } + calendar = new QCalendarWidget(stackWidget); + button->move(10, 10); + button->resize(100, 100); + plainTextEdit->move(30, 70); + plainTextEdit->resize(100, 100); + calendar->move(80, 40); + + QWidget *buttonOps = new QWidget; + QVBoxLayout *l = new QVBoxLayout(buttonOps); + QPushButton *lower = new QPushButton("button: lower"); + connect(lower, SIGNAL(clicked()), button, SLOT(lower())); + l->addWidget(lower); + QPushButton *raise = new QPushButton("button: raise"); + connect(raise, SIGNAL(clicked()), button, SLOT(raise())); + l->addWidget(raise); + + lower = new QPushButton("calendar: lower"); + connect(lower, SIGNAL(clicked()), calendar, SLOT(lower())); + l->addWidget(lower); + raise = new QPushButton("calendar: raise"); + connect(raise, SIGNAL(clicked()), calendar, SLOT(raise())); + l->addWidget(raise); + QPushButton *stackUnder = new QPushButton("calendar: stack under textedit"); + connect(stackUnder, SIGNAL(clicked()), this, SLOT(stackCalendarUnderTextEdit())); + l->addWidget(stackUnder); + + lower = new QPushButton("lower textedit"); + connect(lower, SIGNAL(clicked()), plainTextEdit, SLOT(lower())); + l->addWidget(lower); + raise = new QPushButton("raise textedit"); + connect(raise, SIGNAL(clicked()), plainTextEdit, SLOT(raise())); + l->addWidget(raise); + + QHBoxLayout *mainLayout = new QHBoxLayout(this); + mainLayout->addWidget(buttonOps); + mainLayout->addWidget(stackWidget); + } + +private Q_SLOTS: + void stackCalendarUnderTextEdit() + { + calendar->stackUnder(plainTextEdit); + } + +private: + QPushButton *button; + QPlainTextEdit *plainTextEdit; + QCalendarWidget *calendar; +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + Widget w; + w.show(); + return app.exec(); +} + +#include "main.moc" diff --git a/tests/manual/qwidget_zorder/qwidget_zorder.pro b/tests/manual/qwidget_zorder/qwidget_zorder.pro new file mode 100644 index 0000000..5526f91 --- /dev/null +++ b/tests/manual/qwidget_zorder/qwidget_zorder.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += main.cpp |