summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-25 10:47:46 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-25 10:56:06 (GMT)
commitb463bd91f5e19ec597990ea736ee51a4baaca338 (patch)
tree21021d062724228cdc32ea44cb98f0fc28f3715d
parent931a81a116dd453b1714f0faa2be42bddcd066aa (diff)
downloadQt-b463bd91f5e19ec597990ea736ee51a4baaca338.zip
Qt-b463bd91f5e19ec597990ea736ee51a4baaca338.tar.gz
Qt-b463bd91f5e19ec597990ea736ee51a4baaca338.tar.bz2
stabilize tests on X11
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp2
-rw-r--r--tests/auto/qmenubar/tst_qmenubar.cpp12
-rw-r--r--tests/auto/qwidget_window/tst_qwidget_window.cpp24
3 files changed, 22 insertions, 16 deletions
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index af71961..bd5cd70 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -2516,10 +2516,12 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated()
layout.addWidget(&edit);
w.show();
+ QApplication::setActiveWindow(&w);
QTest::qWaitForWindowShown(&w);
cb.clearEditText();
cb.setFocus();
QApplication::processEvents();
+ QTRY_VERIFY(cb.hasFocus());
QTest::keyClick(0, '1');
QCOMPARE(spy.count(), 0);
edit.setFocus();
diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp
index 7fbb760..aa6caae 100644
--- a/tests/auto/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/qmenubar/tst_qmenubar.cpp
@@ -168,7 +168,7 @@ private slots:
void task256322_highlight();
void menubarSizeHint();
void taskQTBUG4965_escapeEaten();
-
+
#if defined(QT3_SUPPORT)
void indexBasedInsertion_data();
void indexBasedInsertion();
@@ -1360,7 +1360,7 @@ tst_QMenuBar::allowActiveAndDisabled()
// disabled menu items are added
QMenu fileMenu("&File");
- // Task 241043 : check that second menu is activated
+ // Task 241043 : check that second menu is activated
// if all items are disabled
QAction *act = fileMenu.addAction("Disabled");
act->setEnabled(false);
@@ -1388,7 +1388,7 @@ tst_QMenuBar::allowActiveAndDisabled()
QCOMPARE(mb->activeAction()->text(), fileMenu.title());
else
QCOMPARE(mb->activeAction()->text(), fileMenu.title());
-
+
mb->hide();
#endif //Q_WS_MAC
}
@@ -1603,7 +1603,7 @@ void tst_QMenuBar::menubarSizeHint()
virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const
{
// I chose strange values (prime numbers to be more sure that the size of the menubar is correct)
- switch (metric)
+ switch (metric)
{
case QStyle::PM_MenuBarItemSpacing:
return 7;
@@ -1621,7 +1621,7 @@ void tst_QMenuBar::menubarSizeHint()
QMenuBar mb;
mb.setNativeMenuBar(false); //we can't check the geometry of native menubars
-
+
mb.setStyle(&style);
//this is a list of arbitrary strings so that we check the geometry
QStringList list = QStringList() << "trer" << "ezrfgtgvqd" << "sdgzgzerzerzer" << "eerzertz" << "er";
@@ -1675,7 +1675,7 @@ void tst_QMenuBar::taskQTBUG4965_escapeEaten()
QAction *first = menubar.addMenu(&menu);
menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC"));
menubar.show();
- menubar.setActiveWindow();
+ QApplication::setActiveWindow(&menubar);
QTest::qWaitForWindowShown(&menubar);
menubar.setActiveAction(first);
QTRY_VERIFY(menu.isVisible());
diff --git a/tests/auto/qwidget_window/tst_qwidget_window.cpp b/tests/auto/qwidget_window/tst_qwidget_window.cpp
index 13d1d2d..ec11ab3 100644
--- a/tests/auto/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/qwidget_window/tst_qwidget_window.cpp
@@ -52,6 +52,9 @@
#include <QX11Info>
#endif // Q_WS_X11
+#include "../../shared/util.h"
+
+
class tst_QWidget_window : public QWidget
{
Q_OBJECT
@@ -150,7 +153,7 @@ void tst_QWidget_window::tst_show_resize_hide_show()
class TestWidget : public QWidget
{
public:
- int m_first, m_next;
+ int m_first, m_next;
bool paintEventReceived;
void reset(){ m_first = m_next = 0; paintEventReceived = false; }
@@ -163,7 +166,7 @@ public:
case QEvent::Show:
if (m_first)
m_next = event->type();
- else
+ else
m_first = event->type();
break;
case QEvent::Paint:
@@ -173,7 +176,7 @@ public:
break;
}
return QWidget::event(event);
- }
+ }
};
void tst_QWidget_window::tst_windowFilePathAndwindowTitle_data()
@@ -289,7 +292,7 @@ void tst_QWidget_window::tst_showWithoutActivating()
#else
QWidget w;
w.show();
- qt_x11_wait_for_window_manager(&w);
+ QTest::qWaitForWindowShown(&w);
QApplication::processEvents();
QApplication::clipboard();
@@ -302,8 +305,11 @@ void tst_QWidget_window::tst_showWithoutActivating()
Window window;
int revertto;
- XGetInputFocus(QX11Info::display(), &window, &revertto);
- QCOMPARE(lineEdit->winId(), window);
+ QTRY_COMPARE(lineEdit->winId(),
+ (XGetInputFocus(QX11Info::display(), &window, &revertto), window) );
+ // Note the use of the , before window because we want the XGetInputFocus to be re-executed
+ // in each iteration of the inside loop of the QTRY_COMPARE macro
+
#endif // Q_WS_X11
}
@@ -315,11 +321,9 @@ void tst_QWidget_window::tst_paintEventOnSecondShow()
w.reset();
w.show();
-#ifdef Q_WS_X11
- QTest::qWait(500);
-#endif
+ QTest::qWaitForWindowShown(&w);
QApplication::processEvents();
- QVERIFY(w.paintEventReceived);
+ QTRY_VERIFY(w.paintEventReceived);
}
QTEST_MAIN(tst_QWidget_window)