summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-06-09 17:42:11 +0200
committerJason McDonald <jason.mcdonald@nokia.com>2009-06-10 13:56:00 +1000
commitd07565a33c51362de4743de6ed4ad6affeab17b3 (patch)
tree06305c17675ca3edf268ab4dca7ac9b75548e7ba
parent918b71e7ce1ae20dbb051dff2aff8e49e6a54898 (diff)
Fix the qitemdelgate test.
the line edit was deleted when we press enter (cherry picked from commit f4548a337bbc348065e8341df9445bf0fc7bc241)
-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 cdb7b8f789..969ca9061e 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);
}