summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-05-26 21:10:45 +0200
committerQt Continuous Integration System <qt-info@nokia.com>2010-05-26 21:10:45 +0200
commit84f35321b867894470391d4997b5d58e34bce0ed (patch)
treecb66294f39a2660bfac73b5dbccd21b85dfb65bc /tests
parent4837518d3161c77b4e811057d638dcbd22b89195 (diff)
parent11a8c52498e8dc74fdfef48e953055338c8f18d7 (diff)
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Redraw issues when removing a fully transparent QGraphicsItem from the scene. Fixes a proxymodel sorting odity.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp43
-rw-r--r--tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp36
2 files changed, 79 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index a15522263c..67a41ca81a 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -275,6 +275,7 @@ private slots:
void polishItems2();
void isActive();
void siblingIndexAlwaysValid();
+ void removeFullyTransparentItem();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -4333,6 +4334,48 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid()
}
+void tst_QGraphicsScene::removeFullyTransparentItem()
+{
+ QGraphicsScene scene;
+
+ QGraphicsItem *parent = scene.addRect(0, 0, 100, 100);
+ parent->setFlag(QGraphicsItem::ItemHasNoContents);
+
+ QGraphicsItem *child = scene.addRect(0, 0, 100, 100);
+ child->setParentItem(parent);
+
+ CustomView view;
+ view.setScene(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ // NB! The parent has the ItemHasNoContents flag set, which means
+ // the parent itself doesn't generate any update requests, only the
+ // child can possibly trigger an update. Also note that the child
+ // is removed before processing events.
+ view.repaints = 0;
+ parent->setOpacity(0);
+ QVERIFY(qFuzzyIsNull(child->effectiveOpacity()));
+ scene.removeItem(child);
+ QVERIFY(!scene.items().contains(child));
+ QTRY_VERIFY(view.repaints > 0);
+
+ // Re-add child. There's nothing new to display (child is still
+ // effectively hidden), so it shouldn't trigger an update.
+ view.repaints = 0;
+ child->setParentItem(parent);
+ QVERIFY(scene.items().contains(child));
+ QVERIFY(qFuzzyIsNull(child->effectiveOpacity()));
+ QApplication::processEvents();
+ QCOMPARE(view.repaints, 0);
+
+ // Nothing is visible on the screen, removing child item shouldn't trigger an update.
+ scene.removeItem(child);
+ QApplication::processEvents();
+ QCOMPARE(view.repaints, 0);
+ delete child;
+}
+
void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache()
{
QGraphicsScene scene;
diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 992c95e4c0..53fefeedc8 100644
--- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -127,6 +127,8 @@ private slots:
void sortColumnTracking1();
void sortColumnTracking2();
+ void sortStable();
+
void task236755_hiddenColumns();
void task247867_insertRowsSort();
void task248868_staticSorting();
@@ -2442,6 +2444,40 @@ void tst_QSortFilterProxyModel::sortColumnTracking2()
QCOMPARE(proxyModel.data(proxyModel.index(strings.count()-1,0)).toString(),QString::fromLatin1("zz"));
}
+void tst_QSortFilterProxyModel::sortStable()
+{
+ QStandardItemModel* model = new QStandardItemModel(5, 2);
+ for (int r=0; r<5; r++) {
+ for (int c=0; c<2; c++) {
+ QStandardItem* item = new QStandardItem(
+ QString("Row:%0, Column:%1").arg(r).arg(c) );
+ for( int i=0; i<3; i++ ) {
+ QStandardItem* child = new QStandardItem(
+ QString("Item %0").arg(i) );
+ item->appendRow( child );
+ }
+ model->setItem(r, c, item);
+ }
+ }
+ model->setHorizontalHeaderItem( 0, new QStandardItem( "Name" ));
+ model->setHorizontalHeaderItem( 1, new QStandardItem( "Value" ) );
+
+
+ QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(model);
+ filterModel->setSourceModel(model);
+
+ QTreeView *view = new QTreeView;
+ view->setModel(filterModel);
+ QModelIndex firstRoot = filterModel->index(0,0);
+ view->expand(firstRoot);
+ view->setSortingEnabled(true);
+
+ view->model()->sort(1, Qt::DescendingOrder);
+ QVariant lastItemData =filterModel->index(2,0, firstRoot).data();
+ view->model()->sort(1, Qt::DescendingOrder);
+ QCOMPARE(lastItemData, filterModel->index(2,0, firstRoot).data());
+}
+
void tst_QSortFilterProxyModel::task236755_hiddenColumns()
{
class MyStandardItemModel : public QStandardItemModel