summaryrefslogtreecommitdiffstats
path: root/tests/auto/qitemdelegate
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-06-09 15:42:11 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-06-09 15:42:11 (GMT)
commitf4548a337bbc348065e8341df9445bf0fc7bc241 (patch)
tree615379f50b0ea4b6d6f68fc263725f815f117603 /tests/auto/qitemdelegate
parentc93f69f95a8c0a4eb3cd390c11266057b77c78b5 (diff)
downloadQt-f4548a337bbc348065e8341df9445bf0fc7bc241.zip
Qt-f4548a337bbc348065e8341df9445bf0fc7bc241.tar.gz
Qt-f4548a337bbc348065e8341df9445bf0fc7bc241.tar.bz2
Fix the qitemdelgate test.
the line edit was deleted when we press enter
Diffstat (limited to 'tests/auto/qitemdelegate')
-rw-r--r--tests/auto/qitemdelegate/tst_qitemdelegate.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
index 615ac01..50e1ff0 100644
--- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
@@ -1034,7 +1034,7 @@ void tst_QItemDelegate::editorEvent()
option.rect = rect;
option.state |= QStyle::State_Enabled;
- const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
+ const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
QPoint pos = inCheck ? qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center() + QPoint(checkMargin, 0) : QPoint(200,200);
QEvent *event = new QMouseEvent((QEvent::Type)type,
@@ -1057,7 +1057,7 @@ void tst_QItemDelegate::enterKey_data()
QTest::addColumn<int>("widget");
QTest::addColumn<int>("key");
QTest::addColumn<bool>("expectedFocus");
-
+
QTest::newRow("lineedit enter") << 1 << int(Qt::Key_Enter) << false;
QTest::newRow("textedit enter") << 2 << int(Qt::Key_Enter) << true;
QTest::newRow("plaintextedit enter") << 3 << int(Qt::Key_Enter) << true;
@@ -1071,17 +1071,17 @@ void tst_QItemDelegate::enterKey()
QFETCH(int, widget);
QFETCH(int, key);
QFETCH(bool, expectedFocus);
-
+
QStandardItemModel model;
model.appendRow(new QStandardItem());
-
+
QListView view;
view.setModel(&model);
view.show();
QApplication::setActiveWindow(&view);
view.setFocus();
QTest::qWait(30);
-
+
struct TestDelegate : public QItemDelegate
{
int widgetType;
@@ -1089,7 +1089,7 @@ void tst_QItemDelegate::enterKey()
{
QWidget *editor = 0;
switch(widgetType) {
- case 1:
+ case 1:
editor = new QLineEdit(parent);
break;
case 2:
@@ -1103,25 +1103,25 @@ void tst_QItemDelegate::enterKey()
return editor;
}
} delegate;
-
+
delegate.widgetType = widget;
-
+
view.setItemDelegate(&delegate);
QModelIndex index = model.index(0, 0);
view.setCurrentIndex(index); // the editor will only selectAll on the current index
view.edit(index);
QTest::qWait(30);
-
+
QList<QWidget*> lineEditors = qFindChildren<QWidget *>(view.viewport(), QString::fromLatin1("TheEditor"));
QCOMPARE(lineEditors.count(), 1);
-
- QWidget *editor = lineEditors.at(0);
+
+ QPointer<QWidget> editor = lineEditors.at(0);
QCOMPARE(editor->hasFocus(), true);
-
+
QTest::keyClick(editor, Qt::Key(key));
QApplication::processEvents();
-
- QCOMPARE(editor->hasFocus(), expectedFocus);
+
+ QCOMPARE(editor && editor->hasFocus(), expectedFocus);
}