summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-03-28 16:13:59 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-01 05:27:00 +0200
commit0cb2c760c219514849ab0f6be8e5368f92dfa5d9 (patch)
treefba91e3d36bef3f7c43d2cfa8b800b1c171b6e30 /tests/auto
parentcc08fc7bfd1a5cf2da52d49b8b4989b33d3597cc (diff)
Item views: respect selection mode when closing an editor
Task-number: QTBUG-31411 Change-Id: I1a52eb739e0bc2afa7227f006461916df8ecaf48 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index b8875c638d..1005bf6b3c 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -247,6 +247,7 @@ private slots:
void testNoActivateOnDisabledItem();
void testFocusPolicy_data();
void testFocusPolicy();
+ void QTBUG31411_noSelection();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -1782,5 +1783,46 @@ void tst_QAbstractItemView::testFocusPolicy()
QVERIFY(!qApp->focusWidget());
}
+Q_DECLARE_METATYPE(QItemSelection)
+void tst_QAbstractItemView::QTBUG31411_noSelection()
+{
+ QWidget window;
+ QTableView *table = new QTableView(&window);
+ table->setSelectionMode(QAbstractItemView::NoSelection);
+ QVBoxLayout *layout = new QVBoxLayout(&window);
+ layout->addWidget(table);
+
+ QStandardItemModel model;
+ model.setRowCount(10);
+ model.setColumnCount(10);
+ table->setModel(&model);
+ table->setCurrentIndex(model.index(1, 1));
+
+ centerOnScreen(&window);
+ moveCursorAway(&window);
+
+ window.show();
+ QApplication::setActiveWindow(&window);
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+
+ qRegisterMetaType<QItemSelection>();
+ QSignalSpy selectionChangeSpy(table->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+ QVERIFY(selectionChangeSpy.isValid());
+
+ QPoint clickpos = table->visualRect(model.index(1, 1)).center();
+ QTest::mouseClick(table->viewport(), Qt::LeftButton, Qt::NoModifier, clickpos);
+ QTest::mouseDClick(table->viewport(), Qt::LeftButton, Qt::NoModifier, clickpos);
+
+ QPointer<QWidget> editor1 = qApp->focusWidget();
+ QVERIFY(editor1);
+ QTest::keyClick(editor1, Qt::Key_Tab, Qt::NoModifier);
+
+ QPointer<QWidget> editor2 = qApp->focusWidget();
+ QVERIFY(editor2);
+ QTest::keyClick(editor2, Qt::Key_Escape, Qt::NoModifier);
+
+ QCOMPARE(selectionChangeSpy.count(), 0);
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"