summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsproxywidget
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-10-20 11:52:38 +0200
committerAlexis Menard <alexis.menard@nokia.com>2009-10-20 11:52:38 +0200
commit63b574ee1539b34ac7df890a7941320deb1c258e (patch)
tree4f0ed9bf2f9ceb93b6424eaf2a6ba431241f5782 /tests/auto/qgraphicsproxywidget
parentc1a661638f8ad20f0db34d2589cebfa95cdbcdc1 (diff)
Fix bug in embedded dialog demo with tab focus.
On embedded dialog pressing tab stop changing the focus when the focus was given to QFontComboBox. It's because QFontComboBox embed a QLineEdit in order to allow editing. But this QLineEdit is a focus proxy so we need to special case that. The logic is the same in QApplication. Be careful when changing one of them. Task-number:QTBUG-4818 Reviewed-by:jan-arve Reviewed-by:ogoffart
Diffstat (limited to 'tests/auto/qgraphicsproxywidget')
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 2426ce93f2..9269164898 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -2007,8 +2007,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
edit1->setText("QLineEdit 1");
QLineEdit *edit2 = new QLineEdit;
edit2->setText("QLineEdit 2");
+ QFontComboBox *fontComboBox = new QFontComboBox;
QVBoxLayout *vlayout = new QVBoxLayout;
vlayout->addWidget(edit1);
+ vlayout->addWidget(fontComboBox);
vlayout->addWidget(edit2);
QGroupBox *box = new QGroupBox("QGroupBox");
@@ -2020,8 +2022,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
edit1_2->setText("QLineEdit 1_2");
QLineEdit *edit2_2 = new QLineEdit;
edit2_2->setText("QLineEdit 2_2");
+ QFontComboBox *fontComboBox2 = new QFontComboBox;
vlayout = new QVBoxLayout;
vlayout->addWidget(edit1_2);
+ vlayout->addWidget(fontComboBox2);
vlayout->addWidget(edit2_2);
QGroupBox *box_2 = new QGroupBox("QGroupBox 2");
@@ -2062,8 +2066,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
EventSpy eventSpy(edit1);
EventSpy eventSpy2(edit2);
+ EventSpy eventSpy3(fontComboBox);
EventSpy eventSpy1_2(edit1_2);
EventSpy eventSpy2_2(edit2_2);
+ EventSpy eventSpy2_3(fontComboBox2);
EventSpy eventSpyBox(box);
// Tab into group box
@@ -2084,11 +2090,24 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy.counts[QEvent::FocusOut], 0);
+ // Tab to the font combobox
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
+ QApplication::processEvents();
+ fontComboBox->hasFocus();
+ QVERIFY(!edit2->hasFocus());
+ QCOMPARE(eventSpy3.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy3.counts[QEvent::FocusOut], 0);
+ QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1);
+
// Tab into line edit 2
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
QApplication::processEvents();
edit2->hasFocus();
QVERIFY(!edit1->hasFocus());
+ QCOMPARE(eventSpy2.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy2.counts[QEvent::FocusOut], 0);
+ QCOMPARE(eventSpy3.counts[QEvent::FocusOut], 1);
QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1);
@@ -2106,6 +2125,16 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 0);
+ // Tab into right font combobox
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
+ QApplication::processEvents();
+ QVERIFY(!edit1_2->hasFocus());
+ fontComboBox2->hasFocus();
+ QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusOut], 0);
+
// Tab into right bottom line edit
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab);
QApplication::processEvents();
@@ -2113,6 +2142,8 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
edit2_2->hasFocus();
QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusIn], 1);
+ QCOMPARE(eventSpy2_3.counts[QEvent::FocusOut], 1);
QCOMPARE(eventSpy2_2.counts[QEvent::FocusIn], 1);
QCOMPARE(eventSpy2_2.counts[QEvent::FocusOut], 0);
@@ -2129,6 +2160,12 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QVERIFY(!rightDial->hasFocus());
edit2_2->hasFocus();
+ // Backtab into the right font combobox
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
+ QApplication::processEvents();
+ QVERIFY(!edit2_2->hasFocus());
+ fontComboBox2->hasFocus();
+
// Backtab into line edit 1
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
QApplication::processEvents();
@@ -2147,10 +2184,16 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
QVERIFY(!rightDial->hasFocus());
edit2->hasFocus();
- // Backtab into line edit 1
+ // Backtab into the font combobox
QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
QApplication::processEvents();
QVERIFY(!edit2->hasFocus());
+ fontComboBox->hasFocus();
+
+ // Backtab into line edit 1
+ QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab);
+ QApplication::processEvents();
+ QVERIFY(!fontComboBox->hasFocus());
edit1->hasFocus();
// Backtab into line box