Cast back to QWindow *

Tests for widgets should select the
QWidget * version of overloaded QTestLib
functions rather than the QWindow * version.

Change-Id: I8b540b630758c0e7ba7ed88aba45d624c83ff378
Reviewed-on: http://codereview.qt-project.org/4977
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Matthew Cattell <matthew.cattell@nokia.com>
This commit is contained in:
Jo Asplin 2011-09-15 13:09:44 +02:00 committed by Qt by Nokia
parent 51589e834e
commit 629295fcf7
5 changed files with 46 additions and 46 deletions

View File

@ -2163,8 +2163,8 @@ void tst_QComboBox::task247863_keyBoardSelection()
qApp->setEffectEnabled(Qt::UI_AnimateCombo, false); qApp->setEffectEnabled(Qt::UI_AnimateCombo, false);
QTest::keyClick(&combo, Qt::Key_Space); QTest::keyClick(&combo, Qt::Key_Space);
qApp->setEffectEnabled(Qt::UI_AnimateCombo, true); qApp->setEffectEnabled(Qt::UI_AnimateCombo, true);
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Down); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down);
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Enter); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter);
QCOMPARE(combo.currentText(), QLatin1String("222")); QCOMPARE(combo.currentText(), QLatin1String("222"));
QCOMPARE(spy.count(), 1); QCOMPARE(spy.count(), 1);
} }
@ -2528,7 +2528,7 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated()
cb.setFocus(); cb.setFocus();
QApplication::processEvents(); QApplication::processEvents();
QTRY_VERIFY(cb.hasFocus()); QTRY_VERIFY(cb.hasFocus());
QTest::keyClick(static_cast<QWindow *>(0), '1'); QTest::keyClick(static_cast<QWidget *>(0), '1');
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
edit.setFocus(); edit.setFocus();
QTRY_VERIFY(edit.hasFocus()); QTRY_VERIFY(edit.hasFocus());

View File

@ -1080,7 +1080,7 @@ void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate()
QTRY_COMPARE(static_cast<QWidget *>(&spinbox), QApplication::activeWindow()); QTRY_COMPARE(static_cast<QWidget *>(&spinbox), QApplication::activeWindow());
QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));
spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_0); // let's insert a 0 QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_0); // let's insert a 0
QCOMPARE(spinbox.value(), 10000.); QCOMPARE(spinbox.value(), 10000.);
spinbox.clearFocus(); //make sure the value is correctly formatted spinbox.clearFocus(); //make sure the value is correctly formatted
QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));

View File

@ -3704,7 +3704,7 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut()
le.setFocus(); le.setFocus();
QTRY_VERIFY(le.hasFocus()); QTRY_VERIFY(le.hasFocus());
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_P); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_P);
QCOMPARE(spy.count(), 1); QCOMPARE(spy.count(), 1);
} }

View File

@ -347,8 +347,8 @@ void tst_QMenuBar::accel()
// shortcuts won't work unless the window is active // shortcuts won't work unless the window is active
QTRY_VERIFY( QApplication::activeWindow() ); QTRY_VERIFY( QApplication::activeWindow() );
// QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_A, AltKey ); // QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_A, AltKey );
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_A, Qt::ControlModifier ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_A, Qt::ControlModifier );
QTest::qWait(300); QTest::qWait(300);
QCOMPARE( last_accel_id, action ); QCOMPARE( last_accel_id, action );
@ -362,7 +362,7 @@ void tst_QMenuBar::activatedCount()
// create a popup menu with menu items set the accelerators later... // create a popup menu with menu items set the accelerators later...
initSimpleMenubar(); initSimpleMenubar();
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_A, Qt::ControlModifier ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_A, Qt::ControlModifier );
//wait(5000); //wait(5000);
QCOMPARE( activated_count, 2 ); //1 from the popupmenu and 1 from the menubar QCOMPARE( activated_count, 2 ); //1 from the popupmenu and 1 from the menubar
} }
@ -576,7 +576,7 @@ void tst_QMenuBar::check_accelKeys()
initComplexMenubar(); initComplexMenubar();
// start with a bogus key that shouldn't trigger anything // start with a bogus key that shouldn't trigger anything
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_I, Qt::ControlModifier); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_I, Qt::ControlModifier);
QCOMPARE(menu1->selCount(), 0u); QCOMPARE(menu1->selCount(), 0u);
QCOMPARE(menu2->selCount(), 0u); QCOMPARE(menu2->selCount(), 0u);
QCOMPARE(menu3->selCount(), 0u); QCOMPARE(menu3->selCount(), 0u);
@ -586,7 +586,7 @@ void tst_QMenuBar::check_accelKeys()
QCOMPARE(item2_C->selCount(), 0u); QCOMPARE(item2_C->selCount(), 0u);
QCOMPARE(item2_D->selCount(), 0u); QCOMPARE(item2_D->selCount(), 0u);
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_A, Qt::ControlModifier); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_A, Qt::ControlModifier);
QCOMPARE(menu1->selCount(), 0u); QCOMPARE(menu1->selCount(), 0u);
QCOMPARE(menu2->selCount(), 0u); QCOMPARE(menu2->selCount(), 0u);
QCOMPARE(menu3->selCount(), 0u); QCOMPARE(menu3->selCount(), 0u);
@ -596,7 +596,7 @@ void tst_QMenuBar::check_accelKeys()
QCOMPARE(item2_C->selCount(), 0u); QCOMPARE(item2_C->selCount(), 0u);
QCOMPARE(item2_D->selCount(), 0u); QCOMPARE(item2_D->selCount(), 0u);
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_C, Qt::ControlModifier); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_C, Qt::ControlModifier);
QCOMPARE(menu1->selCount(), 0u); QCOMPARE(menu1->selCount(), 0u);
QCOMPARE(menu2->selCount(), 0u); QCOMPARE(menu2->selCount(), 0u);
QCOMPARE(menu3->selCount(), 0u); QCOMPARE(menu3->selCount(), 0u);
@ -606,7 +606,7 @@ void tst_QMenuBar::check_accelKeys()
QCOMPARE(item2_C->selCount(), 1u); QCOMPARE(item2_C->selCount(), 1u);
QCOMPARE(item2_D->selCount(), 0u); QCOMPARE(item2_D->selCount(), 0u);
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_B, Qt::ControlModifier); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_B, Qt::ControlModifier);
QCOMPARE(menu1->selCount(), 0u); QCOMPARE(menu1->selCount(), 0u);
QCOMPARE(menu2->selCount(), 0u); QCOMPARE(menu2->selCount(), 0u);
QCOMPARE(menu3->selCount(), 0u); QCOMPARE(menu3->selCount(), 0u);
@ -616,7 +616,7 @@ void tst_QMenuBar::check_accelKeys()
QCOMPARE(item2_C->selCount(), 1u); QCOMPARE(item2_C->selCount(), 1u);
QCOMPARE(item2_D->selCount(), 0u); QCOMPARE(item2_D->selCount(), 0u);
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_D, Qt::ControlModifier); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_D, Qt::ControlModifier);
QCOMPARE(menu1->selCount(), 0u); QCOMPARE(menu1->selCount(), 0u);
QCOMPARE(menu2->selCount(), 0u); QCOMPARE(menu2->selCount(), 0u);
QCOMPARE(menu3->selCount(), 0u); QCOMPARE(menu3->selCount(), 0u);
@ -626,7 +626,7 @@ void tst_QMenuBar::check_accelKeys()
QCOMPARE(item2_C->selCount(), 1u); QCOMPARE(item2_C->selCount(), 1u);
QCOMPARE(item2_D->selCount(), 1u); QCOMPARE(item2_D->selCount(), 1u);
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_J, Qt::AltModifier); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_J, Qt::AltModifier);
QCOMPARE(menu1->selCount(), 0u); QCOMPARE(menu1->selCount(), 0u);
QCOMPARE(menu2->selCount(), 0u); QCOMPARE(menu2->selCount(), 0u);
QCOMPARE(menu3->selCount(), 1u); QCOMPARE(menu3->selCount(), 1u);
@ -646,7 +646,7 @@ void tst_QMenuBar::check_cursorKeys1()
initComplexMenubar(); initComplexMenubar();
// start with a ALT + 1 that activates the first popupmenu // start with a ALT + 1 that activates the first popupmenu
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_1, Qt::AltModifier ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_1, Qt::AltModifier );
// the Popupmenu should be visible now // the Popupmenu should be visible now
QCOMPARE(menu3->selCount(), 0u); QCOMPARE(menu3->selCount(), 0u);
QCOMPARE(menu4->selCount(), 0u); QCOMPARE(menu4->selCount(), 0u);
@ -656,9 +656,9 @@ void tst_QMenuBar::check_cursorKeys1()
QCOMPARE(item2_D->selCount(), 0u); QCOMPARE(item2_D->selCount(), 0u);
// Simulate a cursor key down click // Simulate a cursor key down click
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Down ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
// and an Enter key // and an Enter key
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Enter ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
// Let's see if the correct slot is called... // Let's see if the correct slot is called...
QCOMPARE(menu3->selCount(), 0u); QCOMPARE(menu3->selCount(), 0u);
QCOMPARE(menu4->selCount(), 0u); QCOMPARE(menu4->selCount(), 0u);
@ -677,15 +677,15 @@ void tst_QMenuBar::check_cursorKeys2()
initComplexMenubar(); initComplexMenubar();
// select popupmenu2 // select popupmenu2
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_2, Qt::AltModifier ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_2, Qt::AltModifier );
// Simulate some cursor keys // Simulate some cursor keys
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Left ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Left );
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Down ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Right ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Right );
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Down ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
// and an Enter key // and an Enter key
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Enter ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
// Let's see if the correct slot is called... // Let's see if the correct slot is called...
QCOMPARE(menu3->selCount(), 0u); QCOMPARE(menu3->selCount(), 0u);
QCOMPARE(menu4->selCount(), 0u); QCOMPARE(menu4->selCount(), 0u);
@ -707,13 +707,13 @@ void tst_QMenuBar::check_cursorKeys3()
initComplexMenubar(); initComplexMenubar();
// select Popupmenu 2 // select Popupmenu 2
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_2, Qt::AltModifier ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_2, Qt::AltModifier );
// Simulate some keys // Simulate some keys
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Left ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Left );
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Down ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
// and press ENTER // and press ENTER
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Enter ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
// Let's see if the correct slot is called... // Let's see if the correct slot is called...
QCOMPARE(menu3->selCount(), 0u); QCOMPARE(menu3->selCount(), 0u);
QCOMPARE(menu4->selCount(), 0u); QCOMPARE(menu4->selCount(), 0u);
@ -738,15 +738,15 @@ void tst_QMenuBar::check_homeKey()
initComplexMenubar(); initComplexMenubar();
// select Popupmenu 2 // select Popupmenu 2
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_2, Qt::AltModifier ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_2, Qt::AltModifier );
// Simulate some keys // Simulate some keys
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Down ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Down ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Down ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Home ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Home );
// and press ENTER // and press ENTER
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Enter ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
// Let's see if the correct slot is called... // Let's see if the correct slot is called...
// QVERIFY2( item2_C->selCount() == 1, "Popupmenu should respond to a Home key" ); // QVERIFY2( item2_C->selCount() == 1, "Popupmenu should respond to a Home key" );
QCOMPARE(item2_C->selCount(), 1u); QCOMPARE(item2_C->selCount(), 1u);
@ -776,12 +776,12 @@ void tst_QMenuBar::check_endKey()
initComplexMenubar(); initComplexMenubar();
// select Popupmenu 2 // select Popupmenu 2
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_2, Qt::AltModifier ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_2, Qt::AltModifier );
// Simulate some keys // Simulate some keys
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_End ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_End );
// and press ENTER // and press ENTER
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Enter ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
// Let's see if the correct slot is called... // Let's see if the correct slot is called...
// QVERIFY2( item2_H->selCount() == 1, "Popupmenu should respond to an End key" ); // QVERIFY2( item2_H->selCount() == 1, "Popupmenu should respond to an End key" );
QCOMPARE(item2_H->selCount(), 1u);//, "Popupmenu should respond to an End key"); QCOMPARE(item2_H->selCount(), 1u);//, "Popupmenu should respond to an End key");
@ -814,12 +814,12 @@ void tst_QMenuBar::check_escKey()
QVERIFY( !pm2->isActiveWindow() ); QVERIFY( !pm2->isActiveWindow() );
// select Popupmenu 2 // select Popupmenu 2
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_2, Qt::AltModifier ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_2, Qt::AltModifier );
QVERIFY( !pm1->isActiveWindow() ); QVERIFY( !pm1->isActiveWindow() );
QVERIFY( pm2->isActiveWindow() ); QVERIFY( pm2->isActiveWindow() );
// If we press ESC, the popup should disappear // If we press ESC, the popup should disappear
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Escape ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Escape );
QVERIFY( !pm1->isActiveWindow() ); QVERIFY( !pm1->isActiveWindow() );
QVERIFY( !pm2->isActiveWindow() ); QVERIFY( !pm2->isActiveWindow() );
@ -827,7 +827,7 @@ void tst_QMenuBar::check_escKey()
return; return;
// If we press Down the popupmenu should be active again // If we press Down the popupmenu should be active again
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Down ); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
QVERIFY( !pm1->isActiveWindow() ); QVERIFY( !pm1->isActiveWindow() );
QVERIFY( pm2->isActiveWindow() ); QVERIFY( pm2->isActiveWindow() );
@ -1255,13 +1255,13 @@ void tst_QMenuBar::taskQTBUG4965_escapeEaten()
menubar.setActiveAction(first); menubar.setActiveAction(first);
QTRY_VERIFY(menu.isVisible()); QTRY_VERIFY(menu.isVisible());
QCOMPARE(menubar.activeAction(), first); QCOMPARE(menubar.activeAction(), first);
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Escape); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Escape);
QVERIFY(!menu.isVisible()); QVERIFY(!menu.isVisible());
QTRY_VERIFY(menubar.hasFocus()); QTRY_VERIFY(menubar.hasFocus());
QCOMPARE(menubar.activeAction(), first); QCOMPARE(menubar.activeAction(), first);
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Escape); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Escape);
QVERIFY(!menubar.activeAction()); QVERIFY(!menubar.activeAction());
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Escape); //now the action should be triggered QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Escape); //now the action should be triggered
QTRY_VERIFY(!menubar.isVisible()); QTRY_VERIFY(!menubar.isVisible());
} }
@ -1278,9 +1278,9 @@ void tst_QMenuBar::taskQTBUG11823_crashwithInvisibleActions()
QApplication::setActiveWindow(&menubar); QApplication::setActiveWindow(&menubar);
menubar.setActiveAction(m); menubar.setActiveAction(m);
QCOMPARE(menubar.activeAction(), m); QCOMPARE(menubar.activeAction(), m);
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Right); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Right);
QCOMPARE(menubar.activeAction(), a); QCOMPARE(menubar.activeAction(), a);
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Right); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Right);
QCOMPARE(menubar.activeAction(), m); QCOMPARE(menubar.activeAction(), m);
a->setVisible(false); a->setVisible(false);
@ -1288,7 +1288,7 @@ void tst_QMenuBar::taskQTBUG11823_crashwithInvisibleActions()
QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed
//it used to crash here because the action is invisible //it used to crash here because the action is invisible
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_Right); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Right);
QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed
} }

View File

@ -1039,7 +1039,7 @@ void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate()
QTRY_COMPARE(static_cast<QWidget *>(&spinbox), QApplication::activeWindow()); QTRY_COMPARE(static_cast<QWidget *>(&spinbox), QApplication::activeWindow());
QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));
spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator
QTest::keyClick(static_cast<QWindow *>(0), Qt::Key_0); // let's insert a 0 QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_0); // let's insert a 0
QCOMPARE(spinbox.value(), 10000000); //it's been multiplied by 10 QCOMPARE(spinbox.value(), 10000000); //it's been multiplied by 10
spinbox.clearFocus(); //make sure the value is correctly formatted spinbox.clearFocus(); //make sure the value is correctly formatted
QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));