diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-12-04 15:10:06 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-12-04 15:10:06 (GMT) |
commit | 452a938862c74f64ebc93fcf82fedd476f0e7bd7 (patch) | |
tree | fee118487794242104f1e5a6cda7d732e7c97810 /tests | |
parent | d4228d023a19ecc2ebad9b63e08dbf6c1075ac40 (diff) | |
parent | 39392326c8c843a6f46b864c6595a5241a47af10 (diff) | |
download | Qt-452a938862c74f64ebc93fcf82fedd476f0e7bd7.zip Qt-452a938862c74f64ebc93fcf82fedd476f0e7bd7.tar.gz Qt-452a938862c74f64ebc93fcf82fedd476f0e7bd7.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qabstractitemview/tst_qabstractitemview.cpp | 42 | ||||
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 81 |
2 files changed, 123 insertions, 0 deletions
diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp index db840f4..6479829 100644 --- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp @@ -46,6 +46,7 @@ #include <qstandarditemmodel.h> #include <qapplication.h> #include <qlistview.h> +#include <qlistwidget.h> #include <qtableview.h> #include <qtreeview.h> #include <qtreewidget.h> @@ -224,6 +225,7 @@ private slots: void shiftArrowSelectionAfterScrolling(); void shiftSelectionAfterRubberbandSelection(); void ctrlRubberbandSelection(); + void QTBUG6407_extendedSelection(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -1433,5 +1435,45 @@ void tst_QAbstractItemView::ctrlRubberbandSelection() QVERIFY(selected.contains(index2)); } +void tst_QAbstractItemView::QTBUG6407_extendedSelection() +{ + QListWidget view; + view.setSelectionMode(QAbstractItemView::ExtendedSelection); + for(int i = 0; i < 50; ++i) + view.addItem(QString::number(i)); + + view.resize(200,200); + + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow()); + + view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum()); + QTest::qWait(20); + + QModelIndex index49 = view.model()->index(49,0); + QPoint p = view.visualRect(index49).center(); + QVERIFY(view.viewport()->rect().contains(p)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p); + QCOMPARE(view.currentIndex(), index49); + QCOMPARE(view.selectedItems().count(), 1); + + QModelIndex index47 = view.model()->index(47,0); + p = view.visualRect(index47).center(); + QVERIFY(view.viewport()->rect().contains(p)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, p); + QCOMPARE(view.currentIndex(), index47); + QCOMPARE(view.selectedItems().count(), 3); //49, 48, 47; + + QModelIndex index44 = view.model()->index(44,0); + p = view.visualRect(index44).center(); + QVERIFY(view.viewport()->rect().contains(p)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ShiftModifier, p); + QCOMPARE(view.currentIndex(), index44); + QCOMPARE(view.selectedItems().count(), 6); //49 .. 44; + +} + QTEST_MAIN(tst_QAbstractItemView) #include "tst_qabstractitemview.moc" diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index a8017ff..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()); @@ -4211,6 +4218,42 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid() //If there are in the list that's bad, we crash... QVERIFY(!QGraphicsScenePrivate::get(&scene)->topLevelItems.contains(static_cast<QGraphicsItem *>(child))); + //Other case + QGraphicsScene scene2; + // works with bsp tree index + scene2.setItemIndexMethod(QGraphicsScene::NoIndex); + + QGraphicsView view2(&scene2); + + // first add the blue rect + QGraphicsRectItem* const item1 = new QGraphicsRectItem(QRect( 10, 10, 10, 10 )); + item1->setPen(QColor(Qt::blue)); + item1->setBrush(Qt::blue); + scene2.addItem(item1); + + // then add the red rect + QGraphicsRectItem* const item2 = new QGraphicsRectItem(5, 5, 10, 10); + item2->setPen(QColor(Qt::red)); + item2->setBrush(Qt::red); + scene2.addItem(item2); + + // now the blue one is visible on top of the red one -> swap them (important for the bug) + item1->setZValue(1.0); + item2->setZValue(0.0); + + view2.show(); + + // handle events as a real life app would do + QApplication::processEvents(); + + // now delete the red rect + delete item2; + + // handle events as a real life app would do + QApplication::processEvents(); + + //We should not crash + } void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() @@ -4228,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" |