Implement waitForWindowExposed and friends for widget windows.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Wed, 18 Jul 2012 11:12:59 +0000 (13:12 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 20 Jul 2012 07:27:28 +0000 (09:27 +0200)
- Implement waitForWindowExposed() for toplevel windows.
- Implement waitForWindowShown(QWidget *) and mark as
  deprecated in line with waitForWindowShown(QWindow*).
- Use in tests.
- Simplify tests (collapse waitForExposed, setActive
  into setActiveWindow, waitForActive), remove most
  hard-coded timeouts.
- Stabilize graphicsview tests by using waitForWindowActive.

Change-Id: Ic7c061e2745b36f71a715ee4e47c0346b11a91e8
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
43 files changed:
src/testlib/qtest_gui.h
src/testlib/qtestcase.cpp
src/testlib/qtestsystem.h
tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
tests/auto/opengl/qgl/tst_qgl.cpp
tests/auto/other/qaccessibility/tst_qaccessibility.cpp
tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro
tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
tests/auto/widgets/widgets/qsizegrip/tst_qsizegrip.cpp
tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp

index 5415b64..a4b1ba8 100644 (file)
@@ -150,10 +150,6 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c
 
 }
 
-#ifdef Q_WS_X11
-extern void qt_x11_wait_for_window_manager(QWidget *w);
-#endif
-
 QT_END_NAMESPACE
 
 QT_END_HEADER
index e0c330d..bf40218 100644 (file)
@@ -859,46 +859,75 @@ QT_BEGIN_NAMESPACE
     \sa QTest::qSleep()
 */
 
-/*! \fn bool QTest::qWaitForWindowShown(QWidget *window)
-    \since 4.6
+/*! \fn bool QTest::qWaitForWindowExposed(QWindow *window, int timeout)
+    \since 5.0
 
-    Waits until the \a window is shown on the screen. This is mainly useful for
-    asynchronous systems like X11, where a window will be mapped to screen some
-    time after being asked to show itself on the screen. Returns true.
+    Waits for \a timeout milliseconds or until the \a window is exposed.
+    Returns true if \c window is exposed within \a timeout milliseconds, otherwise returns false.
 
-    Example:
-    \snippet code/src_qtestlib_qtestcase.cpp 24
+    This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some
+    time after being asked to show itself on the screen.
+
+    \sa QTest::qWaitForWindowActive(), QWindow::isExposed()
+*/
+
+/*! \fn bool QTest::qWaitForWindowActive(QWindow *window, int timeout)
+    \since 5.0
+
+    Waits for \a timeout milliseconds or until the \a window is active.
+
+    Returns true if \c window is active within \a timeout milliseconds, otherwise returns false.
+
+    \sa QTest::qWaitForWindowExposed(), QWindow::isActive()
 */
 
 /*! \fn bool QTest::qWaitForWindowShown(QWindow *window, int timeout)
     \since 5.0
+    \deprecated
 
-    Waits for \a timeout milliseconds or until the \a window is shown on the screen.
-    This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some
-    time after being asked to show itself on the screen.
+    Waits for \a timeout milliseconds or until the \a window is exposed.
+    Returns true if \c window is exposed within \a timeout milliseconds, otherwise returns false.
 
-    Returns true if \c window is show in \a timout milliseconds, otherwise returns false.
+    This function does the same as qWaitForWindowExposed().
 
     \sa QTest::qWaitForWindowActive(), QTest::qWaitForWindowExposed()
 */
 
-/*! \fn bool QTest::qWaitForWindowActive(QWindow *window, int timeout)
+/*! \fn bool QTest::qWaitForWindowExposed(QWidget *widget, int timeout)
     \since 5.0
 
-    Waits for \a timeout milliseconds or until the \a window is active.
+    Waits for \a timeout milliseconds or until the \a widget's window is exposed.
+    Returns true if \c widget's window is exposed within \a timeout milliseconds, otherwise returns false.
 
-    Returns true if \c window is active in \a timout milliseconds, otherwise returns false.
+    This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some
+    time after being asked to show itself on the screen.
 
-    \sa QTest::qWaitForWindowActive(), QTest::qWaitForWindowShown(), QWindow::isActive()
+    \sa QTest::qWaitForWindowActive()
 */
 
-/*! \fn bool QTest::qWaitForWindowExposed(QWindow *window, int timeout)
+/*! \fn bool QTest::qWaitForWindowActive(QWidget *widget, int timeout)
     \since 5.0
 
-    Waits for \a timeout milliseconds or until the \a window is exposed.
-    Returns true if \c window is exposed in \a timout milliseconds, otherwise returns false.
+    Waits for \a timeout milliseconds or until the \a widget's window is active.
+
+    Returns true if \c widget's window is active within \a timeout milliseconds, otherwise returns false.
+
+    \sa QTest::qWaitForWindowExposed(), QWidget::isActiveWindow()
+*/
+
+/*! \fn bool QTest::qWaitForWindowShown(QWidget *widget, int timeout)
+    \since 5.0
+    \deprecated
+
+    Waits for \a timeout milliseconds or until the \a widget's window is exposed.
+    Returns true if \c widget's window is exposed within \a timeout milliseconds, otherwise returns false.
+
+    This function does the same as qWaitForWindowExposed().
 
-    \sa QTest::qWaitForWindowShown(), QTest::qWaitForWindowExposed(), QWindow::isExposed()
+    Example:
+    \snippet code/src_qtestlib_qtestcase.cpp 24
+
+    \sa QTest::qWaitForWindowActive(), QTest::qWaitForWindowExposed()
 */
 
 /*!
index eb0fcb8..66849f4 100644 (file)
 #include <QtCore/qcoreapplication.h>
 #include <QtCore/qelapsedtimer.h>
 #include <QtGui/QWindow>
+#ifdef QT_WIDGETS_LIB
+#  include <QtWidgets/QWidget>
+#endif
 
 QT_BEGIN_HEADER
 
 QT_BEGIN_NAMESPACE
 
-
-class QWidget;
-
 namespace QTest
 {
     inline static void qWait(int ms)
@@ -69,13 +69,6 @@ namespace QTest
         } while (timer.elapsed() < ms);
     }
 
-    inline static bool qWaitForWindowShown(QWidget *window)
-    {
-        Q_UNUSED(window);
-        qWait(200);
-        return true;
-    }
-
     inline static bool qWaitForWindowActive(QWindow *window, int timeout = 1000)
     {
         QElapsedTimer timer;
@@ -120,11 +113,34 @@ namespace QTest
         return window->isExposed();
     }
 
+#ifdef QT_WIDGETS_LIB
+    inline static bool qWaitForWindowActive(QWidget *widget, int timeout = 1000)
+    {
+        if (QWindow *window = widget->windowHandle())
+            return qWaitForWindowActive(window, timeout);
+        return false;
+    }
+
+    inline static bool qWaitForWindowExposed(QWidget *widget, int timeout = 1000)
+    {
+        if (QWindow *window = widget->windowHandle())
+            return qWaitForWindowExposed(window, timeout);
+        return false;
+    }
+#endif
+
 #if QT_DEPRECATED_SINCE(6, 0)
     QT_DEPRECATED inline static bool qWaitForWindowShown(QWindow *window, int timeout = 1000)
     {
         return qWaitForWindowExposed(window, timeout);
     }
+
+#  ifdef QT_WIDGETS_LIB
+    QT_DEPRECATED inline static bool qWaitForWindowShown(QWidget *widget, int timeout = 1000)
+    {
+        return qWaitForWindowExposed(widget, timeout);
+    }
+#  endif // QT_WIDGETS_LIB
 #endif // QT_DEPRECATED_SINCE(6, 0)
 }
 
index 16fccb7..b3d578e 100644 (file)
@@ -733,10 +733,7 @@ void tst_QPixmap::grabWindow()
     QWidget w;
     w.resize(640, 480);
     w.show();
-    QTest::qWait(100);
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&w);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&w));
     QVERIFY(QPixmap::grabWindow(w.winId()).isNull() == false);
 
     QWidget child(&w);
@@ -744,14 +741,12 @@ void tst_QPixmap::grabWindow()
     child.setPalette(Qt::red);
     child.setAutoFillBackground(true);
     child.show();
-    QTest::qWait(100);
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&child);
-#endif
-
-    QPixmap grabWindowPixmap = QPixmap::grabWindow(child.winId());
-    QPixmap grabWidgetPixmap = QPixmap::grabWidget(&child);
-    lenientCompare(grabWindowPixmap, grabWidgetPixmap);
+    QTest::qWait(20);
+    const QPixmap grabWidgetPixmap = QPixmap::grabWidget(&child);
+    const WId childWinId = child.winId(); // Create native child
+    QVERIFY(QTest::qWaitForWindowExposed(child.windowHandle()));
+    const QPixmap grabWindowPixmap = QPixmap::grabWindow(childWinId);
+    QVERIFY(lenientCompare(grabWindowPixmap, grabWidgetPixmap));
 #endif
 }
 
index 5da44df..dd0b0dc 100644 (file)
@@ -848,6 +848,8 @@ void tst_QGL::graphicsViewClipping()
     scene.addWidget(widget)->setPos(0, 0);
 
     QGraphicsView view(&scene);
+    // Use Qt::Tool as fully decorated windows have a minimum width of 160 on Windows.
+    view.setWindowFlags(view.windowFlags() | Qt::Tool);
     view.setBackgroundBrush(Qt::white);
 #ifdef Q_WS_QWS
     view.setWindowFlags(Qt::FramelessWindowHint);
@@ -857,16 +859,14 @@ void tst_QGL::graphicsViewClipping()
     QGLWidget *viewport = new QGLWidget;
     view.setViewport(viewport);
     view.show();
+    qApp->setActiveWindow(&view);
 
     if (!viewport->isValid())
         return;
 
     scene.setSceneRect(view.viewport()->rect());
 
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
-    QTest::qWait(500);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     QImage image = viewport->grabFrameBuffer();
     QImage expected = image;
@@ -966,9 +966,7 @@ void tst_QGL::glWidgetWithAlpha()
 {
     QGLWidget* w = new QGLWidget(QGLFormat(QGL::AlphaChannel));
     w->show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(w);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(w));
 
     delete w;
 }
@@ -1044,10 +1042,7 @@ void tst_QGL::glWidgetRendering()
     w.resize(256, 128);
     w.show();
 
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&w);
-#endif
-    QTest::qWait(200);
+    QVERIFY(QTest::qWaitForWindowExposed(&w));
 
     QVERIFY(w.beginOk);
     QVERIFY(w.engineType == QPaintEngine::OpenGL || w.engineType == QPaintEngine::OpenGL2);
@@ -1287,10 +1282,7 @@ void tst_QGL::glFBOUseInGLWidget()
     w.resize(100, 100);
     w.show();
 
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&w);
-#endif
-    QTest::qWait(200);
+    QVERIFY(QTest::qWaitForWindowExposed(&w));
 
     QVERIFY(w.widgetPainterBeginOk);
     QVERIFY(w.fboPainterBeginOk);
@@ -1325,32 +1317,23 @@ void tst_QGL::glWidgetReparent()
     grandParentWidget.setGeometry(0, 100, 200, 200);
     grandParentWidget.show();
 
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(widget);
-    qt_x11_wait_for_window_manager(&parentWidget);
-#endif
-    QTest::qWait(200);
+    QVERIFY(QTest::qWaitForWindowExposed(widget));
+    QVERIFY(QTest::qWaitForWindowExposed(&grandParentWidget));
 
     QVERIFY(parentWidget.children().count() == 1); // The layout
 
     // Now both widgets should be created & shown, time to re-parent:
     parentLayout.addWidget(widget);
 
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&parentWidget);
-#endif
-    QTest::qWait(200);
+    QVERIFY(QTest::qWaitForWindowExposed(&grandParentWidget));
 
     QVERIFY(parentWidget.children().count() == 2); // Layout & glwidget
     QVERIFY(parentWidget.children().contains(widget));
-    QVERIFY(widget->height() > 30);
+    QTRY_VERIFY(widget->height() > 30);
 
     delete widget;
 
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&parentWidget);
-#endif
-    QTest::qWait(200);
+    QVERIFY(QTest::qWaitForWindowExposed(&grandParentWidget));
 
     QVERIFY(parentWidget.children().count() == 1); // The layout
 
@@ -1359,10 +1342,7 @@ void tst_QGL::glWidgetReparent()
     widget = new GLWidget;
     parentLayout.addWidget(widget);
 
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&parentWidget);
-#endif
-    QTest::qWait(200);
+    QVERIFY(QTest::qWaitForWindowExposed(&grandParentWidget));
 
     QVERIFY(parentWidget.children().count() == 2); // Layout & glwidget
     QVERIFY(parentWidget.children().contains(widget));
@@ -1676,10 +1656,7 @@ void tst_QGL::replaceClipping()
     glw.resize(300, 300);
     glw.show();
 
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&glw);
-#endif
-    QTest::qWait(200);
+    QVERIFY(QTest::qWaitForWindowExposed(&glw));
 
     QImage reference(300, 300, QImage::Format_RGB32);
     QPainter referencePainter(&reference);
@@ -1793,10 +1770,7 @@ void tst_QGL::clipTest()
     glw.resize(220, 220);
     glw.show();
 
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&glw);
-#endif
-    QTest::qWait(200);
+    QVERIFY(QTest::qWaitForWindowExposed(&glw));
 
     QImage reference(glw.size(), QImage::Format_RGB32);
     QPainter referencePainter(&reference);
index fef8100..f06fa92 100644 (file)
@@ -798,10 +798,11 @@ void tst_QAccessibility::mainWindowTest()
     QMainWindow *mw = new QMainWindow;
     mw->resize(300, 200);
     mw->show(); // triggers layout
+    qApp->setActiveWindow(mw);
 
     QLatin1String name = QLatin1String("I am the main window");
     mw->setWindowTitle(name);
-    QTest::qWaitForWindowShown(mw);
+    QVERIFY(QTest::qWaitForWindowActive(mw));
 
     // The order of events is not really that important.
     QAccessibleEvent show(mw, QAccessible::ObjectShow);
@@ -1638,10 +1639,8 @@ void tst_QAccessibility::mdiSubWindowTest()
     QMdiArea mdiArea;
     mdiArea.show();
     qApp->setActiveWindow(&mdiArea);
-#if defined(Q_OS_UNIX)
-    QCoreApplication::processEvents();
-    QTest::qWait(150);
-#endif
+    QVERIFY(QTest::qWaitForWindowActive(&mdiArea));
+
 
     const int subWindowCount =  5;
     for (int i = 0; i < subWindowCount; ++i) {
index 74a7afd..98ea8f4 100644 (file)
@@ -468,6 +468,7 @@ void tst_QFiledialog::completer()
     QNonNativeFileDialog fd(0,QString("Test it"),startPath);
     fd.setOptions(QFileDialog::DontUseNativeDialog);
     fd.show();
+    QVERIFY(QTest::qWaitForWindowExposed(&fd));
     QVERIFY(fd.isVisible());
     QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model");
     QVERIFY(model);
index 1b0de0e..1721e83 100644 (file)
@@ -321,7 +321,7 @@ void tst_QGraphicsEffect::draw()
 
     QGraphicsView view(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(item->numRepaints > 0);
     item->reset();
 
@@ -707,7 +707,8 @@ void tst_QGraphicsEffect::prepareGeometryChangeInvalidateCache()
         view.showFullScreen();
     else
         view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(item->nbPaint >= 1);
 
     item->nbPaint = 0;
@@ -738,7 +739,8 @@ void tst_QGraphicsEffect::itemHasNoContents()
 
     QGraphicsView view(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(child->nbPaint >= 1);
 
     CustomEffect *effect = new CustomEffect;
index 18bec1d..a438472 100644 (file)
@@ -179,10 +179,7 @@ void tst_QGraphicsEffectSource::initTestCase()
     scene->addItem(item);
     view = new QGraphicsView(scene);
     view->show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(view);
-#endif
-    QTest::qWait(200);
+    QVERIFY(QTest::qWaitForWindowActive(view));
 }
 
 void tst_QGraphicsEffectSource::cleanupTestCase()
index 6c52dcb..c292e0f 100644 (file)
@@ -986,7 +986,7 @@ void tst_QGraphicsItem::inputMethodHints()
     QGraphicsView view(&scene);
     QApplication::setActiveWindow(&view);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     item->setFocus();
     QTRY_VERIFY(item->hasFocus());
     QCOMPARE(view.inputMethodHints(), item->inputMethodHints());
@@ -1035,7 +1035,8 @@ void tst_QGraphicsItem::toolTip()
     QGraphicsView view(&scene);
     view.setFixedSize(200, 200);
     view.show();
-    QTest::qWait(250);
+    QApplication::setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     {
         QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(),
                              view.viewport()->mapToGlobal(view.viewport()->rect().topLeft()));
@@ -2259,9 +2260,8 @@ void tst_QGraphicsItem::zValue()
 
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
+
     QApplication::processEvents();
 #ifdef Q_WS_QWS
     QApplication::sendPostedEvents(); //glib workaround
@@ -3238,8 +3238,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints()
     QGraphicsScene scene;
     QGraphicsView view(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
-    QTest::qWait(150);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     EventTester *tester = new EventTester;
     scene.addItem(tester);
@@ -4952,8 +4951,7 @@ void tst_QGraphicsItem::sceneEventFilter()
     QGraphicsView view(&scene);
     view.show();
     QApplication::setActiveWindow(&view);
-    QTest::qWaitForWindowShown(&view);
-    QTest::qWait(25);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     QGraphicsTextItem *text1 = scene.addText(QLatin1String("Text1"));
     QGraphicsTextItem *text2 = scene.addText(QLatin1String("Text2"));
@@ -6712,7 +6710,7 @@ void tst_QGraphicsItem::opacity2()
         view.showFullScreen();
     else
         view.show();
-    QTest::qWaitForWindowShown(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(view.repaints >= 1);
 
 #define RESET_REPAINT_COUNTERS \
@@ -6789,7 +6787,7 @@ void tst_QGraphicsItem::opacityZeroUpdates()
 
     MyGraphicsView view(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(view.repaints > 0);
 
     view.reset();
@@ -7068,10 +7066,7 @@ void tst_QGraphicsItem::sceneTransformCache()
     rect->translate(0, 50);
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
-
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
     rect->translate(0, 100);
     QTransform x;
     x.translate(0, 150);
@@ -7144,8 +7139,7 @@ void tst_QGraphicsItem::tabChangesFocus()
     QWidget widget;
     widget.setLayout(layout);
     widget.show();
-    QTest::qWaitForWindowShown(&widget);
-    QTest::qWait(2000);
+    QVERIFY(QTest::qWaitForWindowActive(&widget));
 
     QTRY_VERIFY(scene.isActive());
 
@@ -7596,10 +7590,7 @@ void tst_QGraphicsItem::update()
 
     topLevel.resize(300, 300);
     topLevel.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
 
     EventTester *item = new EventTester;
     scene.addItem(item);
@@ -7961,10 +7952,7 @@ void tst_QGraphicsItem::moveItem()
 
     MyGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     EventTester *parent = new EventTester;
     EventTester *child = new EventTester(parent);
@@ -8040,10 +8028,7 @@ void tst_QGraphicsItem::moveLineItem()
 
     MyGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
-    QTest::qWait(200);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     view.reset();
 
     QRectF brect = item->boundingRect();
@@ -8104,14 +8089,15 @@ void tst_QGraphicsItem::sorting()
     scene.addItem(item2);
 
     QGraphicsView view(&scene);
+    // Use Qt::Tool as fully decorated windows have a minimum width of 160 on Windows.
+    view.setWindowFlags(view.windowFlags() | Qt::Tool);
     view.setResizeAnchor(QGraphicsView::NoAnchor);
     view.setTransformationAnchor(QGraphicsView::NoAnchor);
     view.resize(120, 100);
     view.setFrameStyle(0);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTest::qWait(100);
 
     _paintedItems.clear();
@@ -8146,7 +8132,8 @@ void tst_QGraphicsItem::itemHasNoContents()
 
     QGraphicsView view(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(!_paintedItems.isEmpty());
 
     _paintedItems.clear();
@@ -8168,10 +8155,7 @@ void tst_QGraphicsItem::hitTestUntransformableItem()
 
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     // Confuse the BSP with dummy items.
     QGraphicsRectItem *dummy = new QGraphicsRectItem(0, 0, 20, 20);
@@ -8221,10 +8205,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem()
     QGraphicsView view(&scene, &toplevel);
     toplevel.resize(300, 300);
     toplevel.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&toplevel);
-#endif
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
 
     // Confuse the BSP with dummy items.
     QGraphicsRectItem *dummy = new QGraphicsRectItem(0, 0, 20, 20);
@@ -8992,10 +8973,7 @@ void tst_QGraphicsItem::moveWhileDeleting()
 
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
-    QTest::qWait(125);
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     delete rect;
 
@@ -10499,7 +10477,7 @@ void tst_QGraphicsItem::scroll()
     MyGraphicsView view(&scene);
     view.setFrameStyle(0);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(view.repaints > 0);
 
     view.reset();
@@ -10877,7 +10855,8 @@ void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent()
         view.showFullScreen();
     else
         view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(view.repaints > 0);
 
     // test case #1
@@ -10928,7 +10907,7 @@ void tst_QGraphicsItem::QT_2653_fullUpdateDiscardingOpacityUpdate()
         view.showFullScreen();
     else
         view.show();
-    QTest::qWaitForWindowShown(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     view.reset();
 
     parentGreen->setOpacity(1.0);
@@ -10961,7 +10940,7 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2()
     scene.addItem(parentGreen);
 
     origView.show();
-    QTest::qWaitForWindowShown(&origView);
+    QVERIFY(QTest::qWaitForWindowActive(&origView));
     origView.setGeometry(origView.width() + 20, 20,
                          origView.width(), origView.height());
 
@@ -10973,8 +10952,8 @@ void tst_QGraphicsItem::QTBUG_7714_fullUpdateDiscardingOpacityUpdate2()
     QTRY_COMPARE(origView.repaints, 1);
 
     view.show();
-
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     view.reset();
     origView.reset();
 
index d17a5a7..53c8be4 100644 (file)
@@ -406,9 +406,7 @@ void tst_QGraphicsProxyWidget::setWidget()
     QGraphicsScene scene;
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
     QPointer<SubQGraphicsProxyWidget> proxy = new SubQGraphicsProxyWidget;
     SubQGraphicsProxyWidget parentProxy;
     scene.addItem(proxy);
@@ -787,8 +785,7 @@ void tst_QGraphicsProxyWidget::focusNextPrevChild()
     QGraphicsView view(&scene);
     view.show();
     QApplication::setActiveWindow(&view);
-    QTest::qWaitForWindowShown(&view);
-    QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     if (hasScene) {
         scene.addItem(proxy);
         proxy->show();
@@ -835,7 +832,7 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
     QApplication::setActiveWindow(&view);
     view.activateWindow();
     view.setFocus();
-    QTest::qWaitForWindowShown(&view);
+    QTest::qWaitForWindowActive(&view);
     QTRY_VERIFY(view.isVisible());
     QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
 
@@ -968,9 +965,8 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent()
     //do not let the window manager move the window while we are moving the mouse on it
     view.setWindowFlags(Qt::X11BypassWindowManagerHint);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
+    QApplication::setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
     EventLogger *widget = new EventLogger;
@@ -1314,9 +1310,7 @@ void tst_QGraphicsProxyWidget::wheelEvent()
     QGraphicsScene scene;
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     WheelWidget *wheelWidget = new WheelWidget();
     wheelWidget->setFixedSize(400, 400);
@@ -1489,7 +1483,7 @@ void tst_QGraphicsProxyWidget::scrollUpdate()
 
     View view(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(view.npaints >= 1);
     QTest::qWait(20);
     widget->paintEventRegion = QRegion();
@@ -2051,8 +2045,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
     window.show();
     QApplication::setActiveWindow(&window);
     window.activateWindow();
-    QTest::qWaitForWindowShown(&window);
-    QTRY_COMPARE(QApplication::activeWindow(), &window);
+    QVERIFY(QTest::qWaitForWindowActive(&window));
 
     leftDial->setFocus();
     QApplication::processEvents();
@@ -2526,9 +2519,7 @@ void tst_QGraphicsProxyWidget::popup_subwidget()
 
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     box->showPopup();
 
@@ -2609,7 +2600,8 @@ void tst_QGraphicsProxyWidget::tooltip_basic()
     QGraphicsView view(&scene);
     view.setFixedSize(200, 200);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    QApplication::setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     {
         QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(),
                              view.viewport()->mapToGlobal(view.viewport()->rect().topLeft()));
@@ -2772,9 +2764,8 @@ void tst_QGraphicsProxyWidget::windowOpacity()
 
     QApplication::setActiveWindow(&view);
     view.show();
-    QTest::qWaitForWindowShown(&view);
-    QApplication::sendPostedEvents();
-    QTRY_VERIFY(view.isActiveWindow());
+    QVERIFY(QTest::qWaitForWindowActive(&view));
+    QVERIFY(view.isActiveWindow());
 
     qRegisterMetaType<QList<QRectF> >("QList<QRectF>");
     QSignalSpy signalSpy(&scene, SIGNAL(changed(const QList<QRectF> &)));
@@ -3260,9 +3251,7 @@ void tst_QGraphicsProxyWidget::dragDrop()
 
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     QMimeData data;
     data.setText("hei");
@@ -3367,9 +3356,7 @@ void tst_QGraphicsProxyWidget::updateAndDelete()
     QGraphicsProxyWidget *proxy = scene.addWidget(new QPushButton("Hello World"));
     View view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
     QTRY_VERIFY(view.npaints > 0);
     // Wait a bit to clear all pending paint events
     QTest::qWait(10);
@@ -3450,8 +3437,8 @@ void tst_QGraphicsProxyWidget::inputMethod()
     lineEdit->setAttribute(Qt::WA_InputMethodEnabled, true);
     QGraphicsProxyWidget *proxy = scene.addWidget(w);
     view.show();
-    QTest::qWaitForWindowShown(&view);
-    QTRY_VERIFY(!(proxy->flags() & QGraphicsItem::ItemAcceptsInputMethod));
+    QVERIFY(QTest::qWaitForWindowActive(&view));
+    QVERIFY(!(proxy->flags() & QGraphicsItem::ItemAcceptsInputMethod));
     lineEdit->setFocus();
     QVERIFY((proxy->flags() & QGraphicsItem::ItemAcceptsInputMethod));
 }
@@ -3471,11 +3458,8 @@ void tst_QGraphicsProxyWidget::clickFocus()
         view.setFrameStyle(0);
         view.resize(300, 300);
         view.show();
-#ifdef Q_WS_X11
-        qt_x11_wait_for_window_manager(&view);
-#endif
         QApplication::setActiveWindow(&view);
-        QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
+        QVERIFY(QTest::qWaitForWindowActive(&view));
 
         QVERIFY(!proxy->hasFocus());
         QVERIFY(!proxy->widget()->hasFocus());
index 3686619..1c5702d 100644 (file)
@@ -1277,7 +1277,8 @@ void tst_QGraphicsScene::removeItem()
     QGraphicsView view(&scene);
     view.setFixedSize(150, 150);
     view.show();
-    QTest::qWaitForWindowShown(view.windowHandle());
+    QApplication::setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTest::mouseMove(view.viewport(), QPoint(-1, -1));
     {
         QMouseEvent moveEvent(QEvent::MouseMove, view.mapFromScene(hoverItem->scenePos() + QPointF(20, 20)), Qt::NoButton, 0, 0);
@@ -1679,8 +1680,8 @@ void tst_QGraphicsScene::hoverEvents_parentChild()
     view.rotate(10);
     view.scale(1.7, 1.7);
     view.show();
-    QTest::qWaitForWindowShown(&view);
-    QTest::qWait(70);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
     mouseEvent.setScenePos(QPointF(-1000, -1000));
@@ -2842,7 +2843,8 @@ void tst_QGraphicsScene::update2()
     CustomView view;
     view.setScene(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(view.repaints >= 1);
     view.repaints = 0;
 
@@ -3034,7 +3036,7 @@ void tst_QGraphicsScene::tabFocus_emptyScene()
     widget.show();
     qApp->setActiveWindow(&widget);
     widget.activateWindow();
-    QTest::qWait(125);
+    QVERIFY(QTest::qWaitForWindowActive(&widget));
 
     dial1->setFocus();
     QVERIFY(dial1->hasFocus());
@@ -3082,8 +3084,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems()
     widget.show();
     qApp->setActiveWindow(&widget);
     widget.activateWindow();
-    QTest::qWaitForWindowShown(&widget);
-    QApplication::processEvents();
+    QVERIFY(QTest::qWaitForWindowActive(&widget));
 
     dial1->setFocus();
     QTRY_VERIFY(dial1->hasFocus());
@@ -3762,8 +3763,8 @@ void tst_QGraphicsScene::inputMethod()
     view.show();
     QApplication::setActiveWindow(&view);
     view.setFocus();
-    QTest::qWaitForWindowShown(&view);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+    QVERIFY(QTest::qWaitForWindowActive(&view));
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
 
     inputContext.m_resetCallCount = 0;
     inputContext.m_commitCallCount = 0;
@@ -4009,8 +4010,8 @@ void tst_QGraphicsScene::isActive()
 
         toplevel1.show();
         QApplication::setActiveWindow(&toplevel1);
-        QTest::qWaitForWindowShown(&toplevel1);
-        QTRY_COMPARE(QApplication::activeWindow(), &toplevel1);
+        QVERIFY(QTest::qWaitForWindowActive(&toplevel1));
+        QCOMPARE(QApplication::activeWindow(), &toplevel1);
 
         QVERIFY(!scene1.isActive()); //it is hidden;
         QVERIFY(scene2.isActive());
@@ -4039,8 +4040,8 @@ void tst_QGraphicsScene::isActive()
 
         toplevel1.show();
         QApplication::setActiveWindow(&toplevel1);
-        QApplication::processEvents();
-        QTRY_COMPARE(QApplication::activeWindow(), &toplevel1);
+        QVERIFY(QTest::qWaitForWindowActive(&toplevel1));
+        QCOMPARE(QApplication::activeWindow(), &toplevel1);
 
         QTRY_VERIFY(scene1.isActive());
         QTRY_VERIFY(!scene2.isActive());
@@ -4076,8 +4077,8 @@ void tst_QGraphicsScene::isActive()
 
         toplevel2.show();
         QApplication::setActiveWindow(&toplevel2);
-        QTest::qWaitForWindowShown(&toplevel2);
-        QTRY_COMPARE(QApplication::activeWindow(), &toplevel2);
+        QVERIFY(QTest::qWaitForWindowActive(&toplevel2));
+        QCOMPARE(QApplication::activeWindow(), &toplevel2);
 
         QVERIFY(scene1.isActive());
         QVERIFY(!scene2.isActive());
@@ -4125,8 +4126,8 @@ void tst_QGraphicsScene::isActive()
         topLevelView.show();
         QApplication::setActiveWindow(&topLevelView);
         topLevelView.setFocus();
-        QTest::qWaitForWindowShown(&topLevelView);
-        QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&topLevelView));
+        QVERIFY(QTest::qWaitForWindowActive(&topLevelView));
+        QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&topLevelView));
 
         QVERIFY(!scene1.isActive());
         QVERIFY(!scene2.isActive());
@@ -4152,7 +4153,7 @@ void tst_QGraphicsScene::isActive()
         QVERIFY(!scene2.hasFocus());
 
         QApplication::setActiveWindow(&toplevel2);
-        QTRY_COMPARE(QApplication::activeWindow(), &toplevel2);
+        QVERIFY(QTest::qWaitForWindowActive(&toplevel2));
 
         QVERIFY(!scene1.isActive());
         QVERIFY(scene2.isActive());
@@ -4289,7 +4290,8 @@ void tst_QGraphicsScene::removeFullyTransparentItem()
     CustomView view;
     view.setScene(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     // NB! The parent has the ItemHasNoContents flag set, which means
     // the parent itself doesn't generate any update requests, only the
index dca93ae..450b970 100644 (file)
@@ -309,10 +309,8 @@ void tst_QGraphicsSceneIndex::clear()
 
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
-    QTest::qWait(250);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
+    qApp->setActiveWindow(&view);
     scene.clear();
 
     // Make sure the index is re-generated after QGraphicsScene::clear();
index 49dca55..6f07718 100644 (file)
@@ -7,3 +7,5 @@ QT += core-private gui-private
 
 SOURCES  += tst_qgraphicsview.cpp tst_qgraphicsview_2.cpp
 DEFINES += QT_NO_CAST_TO_ASCII
+
+mac:CONFIG+=insignificant_test # QTBUG-26580
index d70d106..df15090 100644 (file)
@@ -430,10 +430,9 @@ void tst_QGraphicsView::interactive()
     view.setFixedSize(300, 300);
     QCOMPARE(item->events.size(), 0);
     view.show();
-    QTest::qWaitForWindowShown(&view);
     view.activateWindow();
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
-    QApplication::processEvents();
     QTRY_COMPARE(item->events.size(), 1); // activate
 
     QPoint itemPoint = view.mapFromScene(item->scenePos());
@@ -1524,7 +1523,7 @@ void tst_QGraphicsView::itemsInRect_cosmeticAdjust()
     view.setFrameStyle(0);
     view.resize(300, 300);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(rect->numPaints > 0);
 
     rect->numPaints = 0;
@@ -2337,7 +2336,8 @@ void tst_QGraphicsView::viewportUpdateMode()
 
     // Show the view, and initialize our test.
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(!view.lastUpdateRegions.isEmpty());
     view.lastUpdateRegions.clear();
 
@@ -2639,9 +2639,7 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
     view.rotate(45);
     view.scale(1.5, 1.5);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     // Make sure the view is repainted; otherwise the tests below will fail.
     view.viewport()->repaint();
@@ -2794,6 +2792,7 @@ void tst_QGraphicsView::scrollBarRanges()
     view.setVerticalScrollBarPolicy(vbarpolicy);
 
     view.show();
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     QCOMPARE(view.horizontalScrollBar()->minimum(), hmin);
     QCOMPARE(view.verticalScrollBar()->minimum(), vmin);
@@ -2997,7 +2996,8 @@ void tst_QGraphicsView::task187791_setSceneCausesUpdate()
     QGraphicsScene scene(0, 0, 200, 200);
     QGraphicsView view(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowShown(&view));
 
     EventSpy updateSpy(view.viewport(), QEvent::Paint);
     QCOMPARE(updateSpy.count(), 0);
@@ -3173,7 +3173,8 @@ void tst_QGraphicsView::task239729_noViewUpdate()
     QCOMPARE(spy.count(), 0);
 
     view->show();
-    QTest::qWaitForWindowShown(view);
+    qApp->setActiveWindow(view);
+    QVERIFY(QTest::qWaitForWindowActive(view));
 
     QTRY_VERIFY(spy.count() >= 1);
     spy.reset();
@@ -3752,7 +3753,9 @@ void tst_QGraphicsView::exposeRegion()
     CustomView view;
     view.setScene(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
+
     QTRY_VERIFY(item->paints > 0);
 
     item->paints = 0;
@@ -3904,7 +3907,8 @@ void tst_QGraphicsView::update2()
     view.setFrameStyle(0);
     view.resize(200, 200);
     view.show();
-    QTest::qWaitForWindowShown(&view) ;
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(rect->numPaints > 0);
 
     // Calculate expected update region for the rect.
@@ -3972,7 +3976,8 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape()
 
     CustomView view(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(view.painted);
 
     view.lastUpdateRegions.clear();
@@ -4024,7 +4029,8 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape2()
 
     CustomView view(&scene);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QTRY_VERIFY(view.painted);
 
     view.lastUpdateRegions.clear();
@@ -4179,9 +4185,9 @@ void tst_QGraphicsView::inputContextReset()
     QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled));
 
     view.show();
-    QTest::qWaitForWindowShown(&view);
     QApplication::setActiveWindow(&view);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+    QVERIFY(QTest::qWaitForWindowActive(&view));
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
 
     QGraphicsItem *item1 = new QGraphicsRectItem;
     item1->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod);
@@ -4329,9 +4335,8 @@ void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins()
     VpGraphicsView view(&scene);
     view.setWindowFlags(Qt::X11BypassWindowManagerHint);
     view.show();
-
-    QTest::qWaitForWindowShown(&view);
-    QTest::qWait(50);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
     QPoint mouseViewPos(20, 20);
     sendMouseMove(view.viewport(), mouseViewPos);
 
@@ -4491,7 +4496,8 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect()
         view.setWindowFlags(view.windowFlags()|Qt::X11BypassWindowManagerHint);
     view.scale(4.15, 4.15);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     view.viewport()->repaint(10,10,20,20);
     QApplication::processEvents();
@@ -4566,7 +4572,8 @@ void tst_QGraphicsView::hoverLeave()
     QCursor::setPos(1,1);
 
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     QPoint pos = view.viewport()->mapToGlobal(view.mapFromScene(item->mapToScene(10, 10)));
     QCursor::setPos(pos);
@@ -4613,7 +4620,7 @@ void tst_QGraphicsView::QTBUG_16063_microFocusRect()
 
     view.setFixedSize(40, 40);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     scene.setFocusItem(item);
     view.setFocus();
index 27ad4ff..66d228a 100644 (file)
@@ -1112,11 +1112,8 @@ void tst_QGraphicsWidget::initStyleOption()
     QGraphicsScene scene;
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
     QApplication::setActiveWindow(&view);
-    QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     view.setAlignment(Qt::AlignTop | Qt::AlignLeft);
     SubQGraphicsWidget *widget = new SubQGraphicsWidget;
@@ -1139,7 +1136,7 @@ void tst_QGraphicsWidget::initStyleOption()
     if (underMouse) {
         view.resize(300, 300);
         view.show();
-        QTest::qWaitForWindowShown(&view);
+        QVERIFY(QTest::qWaitForWindowActive(&view));
         sendMouseMove(view.viewport(), view.mapFromScene(widget->mapToScene(widget->boundingRect().center())));
     }
 
@@ -1441,11 +1438,8 @@ void tst_QGraphicsWidget::setTabOrder()
     QGraphicsScene scene;
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
     QApplication::setActiveWindow(&view);
-    QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     QGraphicsWidget *lastItem = 0;
     QTest::ignoreMessage(QtWarningMsg, "QGraphicsWidget::setTabOrder(0, 0) is undefined");
@@ -1647,8 +1641,7 @@ void tst_QGraphicsWidget::verifyFocusChain()
     QGraphicsView view(&scene);
     view.show();
     QApplication::setActiveWindow(&view);
-    QTest::qWaitForWindowShown(&view);
-    QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     {
         // parent/child focus
@@ -1722,7 +1715,7 @@ void tst_QGraphicsWidget::verifyFocusChain()
         scene.addItem(w1_2);
         window->show();
         QApplication::setActiveWindow(window);
-        QTest::qWaitForWindowShown(window);
+        QVERIFY(QTest::qWaitForWindowActive(window));
 
         lineEdit->setFocus();
         QTRY_VERIFY(lineEdit->hasFocus());
@@ -1771,9 +1764,8 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie()
     QGraphicsScene scene;
     QGraphicsView view(&scene);
     view.show();
-    QTest::qWaitForWindowExposed(view.windowHandle());
     QApplication::setActiveWindow(&view);
-    QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     // delete item in focus chain with no focus and verify chain
     SubQGraphicsWidget *parent = new SubQGraphicsWidget(0, Qt::Window);
@@ -2080,9 +2072,7 @@ void tst_QGraphicsWidget::task236127_bspTreeIndexFails()
 
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     QTRY_VERIFY(!scene.itemAt(25, 25));
     widget->setGeometry(0, 112, 360, 528);
@@ -2101,9 +2091,7 @@ void tst_QGraphicsWidget::defaultSize()
 
     QGraphicsView view(&scene);
     view.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&view);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
     QSizeF initialSize = widget->size();
 
     widget->resize(initialSize);
@@ -2975,7 +2963,7 @@ void tst_QGraphicsWidget::respectHFW()
 
     view->show();
     window->setGeometry(0, 0, 70, 70);
-    QTest::qWaitForWindowShown(view);
+    QVERIFY(QTest::qWaitForWindowActive(view));
 
     {   // here we go - simulate a interactive resize of the window
         QTest::mouseMove(view, view->mapFromScene(71, 71)); // bottom right corner
@@ -3141,7 +3129,8 @@ void tst_QGraphicsWidget::initialShow()
         view.showFullScreen();
     else
         view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
     scene.addItem(widget);
 
@@ -3170,7 +3159,8 @@ void tst_QGraphicsWidget::initialShow2()
     dummyView->setWindowFlags(Qt::X11BypassWindowManagerHint);
     EventSpy paintSpy(dummyView->viewport(), QEvent::Paint);
     dummyView->show();
-    QTest::qWaitForWindowShown(dummyView);
+    qApp->setActiveWindow(dummyView);
+    QVERIFY(QTest::qWaitForWindowActive(dummyView));
     const int expectedRepaintCount = paintSpy.count();
     delete dummyView;
     dummyView = 0;
@@ -3184,7 +3174,8 @@ void tst_QGraphicsWidget::initialShow2()
     QGraphicsView view(&scene);
     view.setWindowFlags(view.windowFlags()|Qt::X11BypassWindowManagerHint);
     view.show();
-    QTest::qWaitForWindowShown(&view);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
 
 #if defined(Q_OS_WIN) || defined(UBUNTU_LUCID)
     QEXPECT_FAIL("", "QTBUG-20778", Abort);
index c6c8131..70b8be8 100644 (file)
@@ -761,9 +761,7 @@ static void sendMouseMove(QWidget *widget, QPoint pos = QPoint())
     QMouseEvent event(QEvent::MouseMove, pos, widget->mapToGlobal(pos), Qt::NoButton, 0, 0);
     QCursor::setPos(widget->mapToGlobal(pos));
     qApp->processEvents();
-#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(widget);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(widget));
     QApplication::sendEvent(widget, &event);
 }
 
@@ -920,10 +918,8 @@ void tst_QAbstractItemView::dragAndDrop()
 
         widget.show();
         view.show();
-#if defined(Q_WS_X11)
-        qt_x11_wait_for_window_manager(&widget);
-        qt_x11_wait_for_window_manager(&view);
-#endif
+        QVERIFY(QTest::qWaitForWindowExposed(&widget));
+        QVERIFY(QTest::qWaitForWindowExposed(&view));
 
         widget.dragAndDrop(&view, dropAction);
         if (model.dropAction() == dropAction
@@ -965,9 +961,7 @@ void tst_QAbstractItemView::dragAndDropOnChild()
         view.setFixedSize(size, size);
         view.move(int(size * 1.5), int(size * 1.5));
         view.show();
-#if defined(Q_WS_X11)
-        qt_x11_wait_for_window_manager(&view);
-#endif
+        QVERIFY(QTest::qWaitForWindowExposed(&view));
 
         view.dragAndDrop(view.visualRect(parent).center(),
                          view.visualRect(child).center());
@@ -1046,8 +1040,8 @@ void tst_QAbstractItemView::setItemDelegate()
         }
     }
     v.show();
+    QVERIFY(QTest::qWaitForWindowExposed(&v));
 #ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&v);
     QCursor::setPos(v.geometry().center());
     QApplication::syncX();
 #endif
index 9d27b7d..b3afdb9 100644 (file)
@@ -460,9 +460,7 @@ void tst_QItemDelegate::font()
     TestItemDelegate *delegate = new TestItemDelegate(&table);
     table.setItemDelegate(delegate);
     table.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&table);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&table));
 
     QTableWidgetItem *item = new QTableWidgetItem;
     item->setText(itemText);
@@ -993,11 +991,8 @@ void tst_QItemDelegate::decoration()
     TestItemDelegate delegate;
     table.setItemDelegate(&delegate);
     table.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&table);
-#endif
     QApplication::setActiveWindow(&table);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&table));
+    QVERIFY(QTest::qWaitForWindowActive(&table));
 
     QVariant value;
     switch ((QVariant::Type)type) {
index 14d3f07..6ed83a3 100644 (file)
@@ -1682,7 +1682,9 @@ void tst_QListView::keyboardSearch()
     QListView view;
     view.setModel(&model);
     view.show();
-    QTest::qWait(30);
+    qApp->setActiveWindow(&view);
+    QVERIFY(QTest::qWaitForWindowActive(&view));
+
 //    QCOMPARE(view.currentIndex() , model.index(0,0));
 
     QTest::keyClick(&view, Qt::Key_K);
index 9407fe0..31cc87b 100644 (file)
@@ -1523,12 +1523,7 @@ void tst_QListWidget::fastScroll()
     // Make sure the widget gets the first full repaint. On
     // some WMs, we'll get two (first inactive exposure, then
     // active exposure.
-    QTest::qWaitForWindowShown(&widget);
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&widget);
-#endif
-    QApplication::processEvents();
-    QTest::qWait(500);
+    QVERIFY(QTest::qWaitForWindowActive(&topLevel));
 
     QSize itemSize = widget.visualItemRect(widget.item(0)).size();
     QVERIFY(!itemSize.isEmpty());
@@ -1671,7 +1666,8 @@ void tst_QListWidget::QTBUG14363_completerWithAnyKeyPressedEditTriggers()
     new QListWidgetItem(QLatin1String("completer"), &listWidget);
        listWidget.show();
     listWidget.setCurrentItem(item);
-    QTest::qWaitForWindowShown(&listWidget);
+    qApp->setActiveWindow(&listWidget);
+    QVERIFY(QTest::qWaitForWindowActive(&listWidget));
     listWidget.setFocus();
     QCOMPARE(qApp->focusWidget(), &listWidget);
 
index 320483b..f61b776 100644 (file)
@@ -3360,9 +3360,8 @@ void tst_QTreeView::task224091_appendColumns()
     treeView->setModel(model);
     topLevel->show();
     treeView->resize(50,50);
-
-    QTest::qWaitForWindowShown(treeView);
-    qApp->processEvents();
+    qApp->setActiveWindow(topLevel);
+    QVERIFY(QTest::qWaitForWindowActive(topLevel));
 
     QList<QStandardItem *> projlist;
     for (int k = 0; k < 10; ++k)
@@ -3846,8 +3845,8 @@ void tst_QTreeView::keyboardNavigationWithDisabled()
     view.resize(200, view.visualRect(model.index(0,0)).height()*10);
     topLevel.show();
     QApplication::setActiveWindow(&topLevel);
-    QTest::qWaitForWindowShown(&topLevel);
-    QTRY_VERIFY(topLevel.isActiveWindow());
+    QVERIFY(QTest::qWaitForWindowActive(&topLevel));
+    QVERIFY(topLevel.isActiveWindow());
 
     view.setCurrentIndex(model.index(1, 0));
     QTest::keyClick(view.viewport(), Qt::Key_Up);
index 69a9bc2..9c495f8 100644 (file)
@@ -242,9 +242,7 @@ void tst_QTreeWidget::initTestCase()
 
     testWidget = new CustomTreeWidget();
     testWidget->show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(testWidget);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(testWidget));
 }
 
 void tst_QTreeWidget::cleanupTestCase()
@@ -459,7 +457,7 @@ void tst_QTreeWidget::editItem()
     QTreeWidget tree;
     populate(&tree, topLevelItems, new TreeItem(QStringList() << "1" << "2"));
     tree.show();
-    QTest::qWaitForWindowShown(&tree);
+    QVERIFY(QTest::qWaitForWindowActive(&tree));
 
     QSignalSpy itemChangedSpy(
         &tree, SIGNAL(itemChanged(QTreeWidgetItem*,int)));
index e0028be..aebe416 100644 (file)
@@ -274,10 +274,8 @@ void tst_QApplication::alert()
     app.alert(&widget, 100);
     widget.show();
     widget2.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&widget);
-    qt_x11_wait_for_window_manager(&widget2);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&widget));
+    QVERIFY(QTest::qWaitForWindowExposed(&widget2));
     QTest::qWait(100);
     app.alert(&widget, -1);
     app.alert(&widget, 250);
index fc47e09..8ec0ef8 100644 (file)
@@ -348,9 +348,7 @@ void tst_QFormLayout::contentsRect()
     w.setLayout(&form);
     form.addRow("Label", new QPushButton(&w));
     w.show();
-/*#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(&w);     // wait for the show
-#endif*/
+    QVERIFY(QTest::qWaitForWindowExposed(&w));
     int l, t, r, b;
     form.getContentsMargins(&l, &t, &r, &b);
     QRect geom = form.geometry();
index 6b424ab..be2d49a 100644 (file)
@@ -906,10 +906,7 @@ void tst_QGridLayout::minMaxSize()
         }
 
         m_toplevel->show();
-#if defined(Q_WS_X11)
-        qt_x11_wait_for_window_manager(m_toplevel);     // wait for the show
-#endif
-        QTest::qWait(40);
+        QVERIFY(QTest::qWaitForWindowExposed(m_toplevel));
         m_toplevel->adjustSize();
         QTest::qWait(240);                              // wait for the implicit adjustSize
         // If the following fails we might have to wait longer.
@@ -1462,9 +1459,7 @@ void tst_QGridLayout::layoutSpacingImplementation()
     widget->setParent(&toplevel);
     widget->resize(widget->sizeHint());
     toplevel.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&toplevel);     // wait for the show
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
 
     QLayout *layout = widget->layout();
     QVERIFY(layout);
@@ -1586,9 +1581,7 @@ void tst_QGridLayout::contentsRect()
     w.setLayout(&grid);
     grid.addWidget(new QPushButton(&w));
     w.show();
-#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(&w);     // wait for the show
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&w));
     int l, t, r, b;
     grid.getContentsMargins(&l, &t, &r, &b);
     QRect geom = grid.geometry();
index 971f60b..dd91e69 100644 (file)
@@ -1004,9 +1004,7 @@ void tst_QShortcut::context()
     layout->addWidget(other1);
     layout->addWidget(other2);
     myBox.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&myBox);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&myBox));
 
     setupShortcut(other1, "ActiveWindow", TriggerSlot1, QKeySequence("Alt+1"), Qt::WindowShortcut);
     setupShortcut(other2, "Focus",        TriggerSlot2, QKeySequence("Alt+2"), Qt::WidgetShortcut);
@@ -1076,11 +1074,7 @@ void tst_QShortcut::context()
     other2->activateWindow();
     other2->setFocus(); // ###
     qApp->syncX();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(other2);
-#endif
-    QTest::qWait(100);
-    QCOMPARE(qApp->activeWindow(), other2->window());
+    QTRY_COMPARE(qApp->activeWindow(), other2->window());
     QCOMPARE(qApp->focusWidget(), (QWidget *)other2);
 
     currentResult = NoResult;
@@ -1097,14 +1091,6 @@ void tst_QShortcut::context()
     QCOMPARE(other2->toPlainText(), QString(""));
 
     clearAllShortcuts();
-    delete other1;
-    delete other2;
-    edit->activateWindow();
-    qApp->syncX();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(edit);
-#endif
-    QTest::qWait(100);
 }
 
 // ------------------------------------------------------------------
index cf65556..37e945d 100644 (file)
@@ -4874,7 +4874,8 @@ void tst_QWidget::showAndMoveChild()
     parent.setGeometry(desktopDimensions);
     parent.setPalette(Qt::red);
     parent.show();
-    QTest::qWaitForWindowShown(&parent);
+    qApp->setActiveWindow(&parent);
+    QVERIFY(QTest::qWaitForWindowActive(&parent));
     QTest::qWait(10);
 
     const QPoint tlwOffset = parent.geometry().topLeft();
@@ -4976,25 +4977,23 @@ void tst_QWidget::multipleToplevelFocusCheck()
 
     w1.resize(200, 200);
     w1.show();
-    QTest::qWaitForWindowShown(&w1);
+    QVERIFY(QTest::qWaitForWindowExposed(&w1));
     w2.resize(200,200);
     w2.show();
-    QTest::qWaitForWindowShown(&w2);
-
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowExposed(&w2));
 
     QApplication::setActiveWindow(&w1);
     w1.activateWindow();
-    QApplication::processEvents();
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w1));
+    QVERIFY(QTest::qWaitForWindowActive(&w1));
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w1));
     QTest::qWait(50);
     QTest::mouseDClick(&w1, Qt::LeftButton);
     QTRY_COMPARE(QApplication::focusWidget(), static_cast<QWidget *>(w1.edit));
 
     w2.activateWindow();
     QApplication::setActiveWindow(&w2);
-    QApplication::processEvents();
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w2));
+    QVERIFY(QTest::qWaitForWindowActive(&w2));
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w2));
     QTest::mouseClick(&w2, Qt::LeftButton);
     QTRY_COMPARE(QApplication::focusWidget(), (QWidget *)0);
 
@@ -5003,15 +5002,15 @@ void tst_QWidget::multipleToplevelFocusCheck()
 
     w1.activateWindow();
     QApplication::setActiveWindow(&w1);
-    QApplication::processEvents();
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w1));
+    QVERIFY(QTest::qWaitForWindowActive(&w1));
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w1));
     QTest::mouseDClick(&w1, Qt::LeftButton);
     QTRY_COMPARE(QApplication::focusWidget(), static_cast<QWidget *>(w1.edit));
 
     w2.activateWindow();
     QApplication::setActiveWindow(&w2);
-    QApplication::processEvents();
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w2));
+    QVERIFY(QTest::qWaitForWindowActive(&w2));
+    QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w2));
     QTest::mouseClick(&w2, Qt::LeftButton);
     QTRY_COMPARE(QApplication::focusWidget(), (QWidget *)0);
 }
@@ -7531,7 +7530,8 @@ void tst_QWidget::resizeInPaintEvent()
     QWidget window;
     UpdateWidget widget(&window);
     window.show();
-    QTest::qWaitForWindowShown(&window);
+    qApp->setActiveWindow(&window);
+    QVERIFY(QTest::qWaitForWindowActive(&window));
     QTRY_VERIFY(widget.numPaintEvents > 0);
 
     widget.reset();
@@ -8132,7 +8132,8 @@ void tst_QWidget::setClearAndResizeMask()
     UpdateWidget topLevel;
     topLevel.resize(150, 150);
     topLevel.show();
-    QTest::qWaitForWindowShown(&topLevel);
+    qApp->setActiveWindow(&topLevel);
+    QVERIFY(QTest::qWaitForWindowActive(&topLevel));
     QTRY_VERIFY(topLevel.numPaintEvents > 0);
     topLevel.reset();
 
@@ -8919,6 +8920,7 @@ void tst_QWidget::focusProxyAndInputMethods()
     toplevel->show();
     QTest::qWaitForWindowShown(toplevel);
     QApplication::setActiveWindow(toplevel);
+    QVERIFY(QTest::qWaitForWindowActive(toplevel));
     QVERIFY(toplevel->hasFocus());
     QVERIFY(child->hasFocus());
 
index 3bff332..1d9c5e6 100644 (file)
@@ -1347,7 +1347,8 @@ void tst_QStyleSheetStyle::toolTip()
     wid4->setObjectName("wid4");
 
     w.show();
-    QTest::qWait(100);
+    qApp->setActiveWindow(&w);
+    QVERIFY(QTest::qWaitForWindowActive(&w));
 
     QColor normalToolTip = qApp->palette().toolTipBase().color();
     QList<QWidget *> widgets;
index 61b0e04..bd64777 100644 (file)
@@ -1384,13 +1384,8 @@ void tst_QCompleter::task253125_lineEditCompletion()
     edit.setCompleter(completer);
     edit.show();
     edit.setFocus();
-
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&edit);
-#endif
-    QTest::qWait(10);
     QApplication::setActiveWindow(&edit);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&edit));
+    QVERIFY(QTest::qWaitForWindowActive(&edit));
 
     QTest::keyClick(&edit, 'i');
     QCOMPARE(edit.completer()->currentCompletion(), QString("iota"));
@@ -1421,14 +1416,8 @@ void tst_QCompleter::task247560_keyboardNavigation()
     edit.setCompleter(&completer);
     edit.show();
     edit.setFocus();
-
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&edit);
-#endif
-
-    QTest::qWait(10);
     QApplication::setActiveWindow(&edit);
-    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&edit));
+    QVERIFY(QTest::qWaitForWindowActive(&edit));
 
     QTest::keyClick(&edit, 'r');
     QTest::keyClick(edit.completer()->popup(), Qt::Key_Down);
@@ -1469,8 +1458,8 @@ void tst_QCompleter::QTBUG_14292_filesystem()
 
     edit.show();
     QApplication::setActiveWindow(&edit);
-    QTest::qWaitForWindowShown(&edit);
-    QTRY_VERIFY(QApplication::activeWindow() == &edit);
+    QVERIFY(QTest::qWaitForWindowActive(&edit));
+    QCOMPARE(QApplication::activeWindow(), &edit);
     edit.setFocus();
     QTRY_VERIFY(edit.hasFocus());
 
index ce0049c..96dce56 100644 (file)
@@ -2095,11 +2095,8 @@ void tst_QComboBox::task190205_setModelAdjustToContents()
     correctBox.addItems(finalContent);
     correctBox.show();
 
-    QCoreApplication::processEvents();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&box);
-    qt_x11_wait_for_window_manager(&correctBox);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&box));
+    QVERIFY(QTest::qWaitForWindowExposed(&correctBox));
 
     // box should be resized to the same size as correctBox
     QTRY_COMPARE(box.size(), correctBox.size());
index 43c0022..494ba54 100644 (file)
@@ -352,9 +352,7 @@ void tst_QDockWidget::setFloating()
     mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
 
     mw.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mw);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mw));
 
     QVERIFY(!dw.isFloating());
 
@@ -719,9 +717,7 @@ void tst_QDockWidget::task165177_deleteFocusWidget()
     QLineEdit *ledit = new QLineEdit;
     dw->setWidget(ledit);
     mw.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mw);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mw));
     qApp->processEvents();
     dw->setFloating(true);
     delete ledit;
@@ -760,19 +756,15 @@ void tst_QDockWidget::task169808_setFloating()
        mw.addDockWidget(Qt::LeftDockWidgetArea, dw);
        dw->setFloating(true);
        mw.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mw);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mw));
 
     QCOMPARE(dw->widget()->size(), dw->widget()->sizeHint());
 
     //and now we try to test if the contents margin is taken into account
     dw->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        dw->setFloating(false);
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mw);
-#endif
-    QTest::qWait(100); //leave time processing events
+    QVERIFY(QTest::qWaitForWindowExposed(&mw));
+    qApp->processEvents(); //leave time processing events
 
 
     const QSize oldSize = dw->size();
@@ -780,10 +772,8 @@ void tst_QDockWidget::task169808_setFloating()
 
     dw->setContentsMargins(margin, margin, margin, margin);
 
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mw);
-#endif
-    QTest::qWait(100); //leave time processing events
+    QVERIFY(QTest::qWaitForWindowExposed(&mw));
+    qApp->processEvents(); //leave time processing events
 
     //widget size shouldn't have changed
     QCOMPARE(dw->widget()->size(), dw->widget()->sizeHint());
index f140e63..45b9653 100644 (file)
@@ -1066,9 +1066,9 @@ void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate()
     spinbox.activateWindow();
     spinbox.setFocus();
     QApplication::setActiveWindow(&spinbox);
-    QTest::qWaitForWindowShown(&spinbox);
+    QVERIFY(QTest::qWaitForWindowActive(&spinbox));
+    QCOMPARE(static_cast<QWidget *>(&spinbox), QApplication::activeWindow());
     QTRY_VERIFY(spinbox.hasFocus());
-    QTRY_COMPARE(static_cast<QWidget *>(&spinbox), QApplication::activeWindow());
     QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));
     spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator
     QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_0); // let's insert a 0
index 730992d..ab38223 100644 (file)
@@ -464,8 +464,8 @@ void tst_QGroupBox::propagateFocus()
     QLineEdit lineEdit(&box);
     box.show();
     QApplication::setActiveWindow(&box);
+    QVERIFY(QTest::qWaitForWindowActive(&box));
     box.setFocus();
-    QTest::qWait(250);
     QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit));
 }
 
index 35b9004..48ff37a 100644 (file)
@@ -3338,8 +3338,8 @@ void tst_QLineEdit::task174640_editingFinished()
     mw.show();
     QApplication::setActiveWindow(&mw);
     mw.activateWindow();
-    QTest::qWaitForWindowShown(&mw);
-    QTRY_COMPARE(&mw, QApplication::activeWindow());
+    QVERIFY(QTest::qWaitForWindowActive(&mw));
+    QCOMPARE(&mw, QApplication::activeWindow());
 
     QSignalSpy editingFinishedSpy(le1, SIGNAL(editingFinished()));
 
@@ -3448,10 +3448,7 @@ void tst_QLineEdit::task229938_dontEmitChangedWhenTextIsNotChanged()
     QLineEdit lineEdit;
     lineEdit.setMaxLength(5);
     lineEdit.show();
-#ifdef Q_WS_X11
-    // to be safe and avoid failing setFocus with window managers
-    qt_x11_wait_for_window_manager(&lineEdit);
-#endif
+    QTest::qWaitForWindowExposed(&lineEdit); // to be safe and avoid failing setFocus with window managers
     lineEdit.setFocus();
     QSignalSpy changedSpy(&lineEdit, SIGNAL(textChanged(QString)));
     QTest::qWait(200);
@@ -3648,8 +3645,8 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut()
     le.addAction(&action);
 
     le.show();
-    QTest::qWaitForWindowShown(&le);
     QApplication::setActiveWindow(&le);
+    QVERIFY(QTest::qWaitForWindowActive(&le));
     le.setFocus();
     QTRY_VERIFY(le.hasFocus());
 
index 7aa9bb2..4a04783 100644 (file)
@@ -464,12 +464,8 @@ void tst_QMdiArea::subWindowActivated2()
         mdiArea.addSubWindow(new QWidget);
     QCOMPARE(spy.count(), 0);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
-    QTest::qWaitForWindowShown(&mdiArea);
     mdiArea.activateWindow();
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowActive(&mdiArea));
 
     QTRY_COMPARE(spy.count(), 5);
     QCOMPARE(mdiArea.activeSubWindow(), mdiArea.subWindowList().back());
@@ -503,10 +499,7 @@ void tst_QMdiArea::subWindowActivated2()
     spy.clear();
 
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
     QTRY_COMPARE(spy.count(), 1);
     QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
     spy.clear();
@@ -517,13 +510,11 @@ void tst_QMdiArea::subWindowActivated2()
     // Check that we only emit _one_ signal and the active window
     // is unchanged after showMinimized/showNormal.
     mdiArea.showMinimized();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#elif defined (Q_OS_MAC)
+#if defined (Q_OS_MAC)
     if (!macHasAccessToWindowsServer())
         QEXPECT_FAIL("", "showMinimized doesn't really minimize if you don't have access to the server", Abort);
 #endif
-    QTest::qWait(10);
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 #if defined(Q_WS_QWS)
     QEXPECT_FAIL("", "task 168682", Abort);
 #endif
@@ -538,11 +529,11 @@ void tst_QMdiArea::subWindowActivated2()
     QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow);
     spy.clear();
 
+    // For this test, the QMdiArea widget must be active after minimizing and
+    // showing it again. QMdiArea has no active sub window if it is inactive itself.
+    qApp->setActiveWindow(&mdiArea);
     mdiArea.showNormal();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowActive(&mdiArea));
     QTRY_COMPARE(spy.count(), 1);
     QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
     spy.clear();
@@ -998,11 +989,8 @@ void tst_QMdiArea::activeSubWindow()
     mainWindow.addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
 
     mainWindow.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mainWindow);
-#endif
-
     qApp->setActiveWindow(&mainWindow);
+    QVERIFY(QTest::qWaitForWindowActive(&mainWindow));
     QCOMPARE(mdiArea->activeSubWindow(), subWindow);
     QCOMPARE(qApp->focusWidget(), (QWidget *)subWindowLineEdit);
 
@@ -1022,9 +1010,7 @@ void tst_QMdiArea::activeSubWindow()
 
     QLineEdit dummyTopLevel;
     dummyTopLevel.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&dummyTopLevel);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&dummyTopLevel));
 
     qApp->setActiveWindow(&dummyTopLevel);
     QCOMPARE(mdiArea->activeSubWindow(), subWindow);
@@ -1047,9 +1033,7 @@ void tst_QMdiArea::currentSubWindow()
 {
     QMdiArea mdiArea;
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     for (int i = 0; i < 5; ++i)
         mdiArea.addSubWindow(new QLineEdit)->show();
@@ -1065,9 +1049,7 @@ void tst_QMdiArea::currentSubWindow()
 
     QLineEdit dummyTopLevel;
     dummyTopLevel.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&dummyTopLevel);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&dummyTopLevel));
 
     // Move focus to another top-level and check that we still
     // have an active window.
@@ -1130,9 +1112,7 @@ void tst_QMdiArea::addAndRemoveWindows()
     QMdiArea workspace(&topLevel);
     workspace.resize(800, 600);
     topLevel.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&workspace);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
 
     { // addSubWindow with large widget
     QCOMPARE(workspace.subWindowList().count(), 0);
@@ -1605,9 +1585,7 @@ void tst_QMdiArea::tileSubWindows()
     if (PlatformQuirks::isAutoMaximizing())
         workspace.setWindowFlags(workspace.windowFlags() | Qt::X11BypassWindowManagerHint);
     workspace.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&workspace);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&workspace));
 
     const int windowCount = 10;
     for (int i = 0; i < windowCount; ++i) {
@@ -1784,9 +1762,7 @@ void tst_QMdiArea::tileSubWindows()
     QCOMPARE(vBar->minimum(), 0);
 
     workspace.tileSubWindows();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&workspace);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&workspace));
     qApp->processEvents();
 
     QTRY_VERIFY(workspace.size() != QSize(150, 150));
@@ -1799,9 +1775,7 @@ void tst_QMdiArea::cascadeAndTileSubWindows()
     QMdiArea workspace;
     workspace.resize(400, 400);
     workspace.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&workspace);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&workspace));
 
     const int windowCount = 10;
     QList<QMdiSubWindow *> windows;
@@ -1867,10 +1841,7 @@ void tst_QMdiArea::resizeMaximizedChildWindows()
     QWidget topLevel;
     QMdiArea workspace(&topLevel);
     topLevel.show();
-#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(&workspace);
-#endif
-    QTest::qWait(100);
+    QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
     workspace.resize(startSize, startSize);
     workspace.setOption(QMdiArea::DontMaximizeSubWindowOnActivation);
     QSize workspaceSize = workspace.size();
@@ -1932,9 +1903,7 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation()
 {
     QMdiArea mdiArea;
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
     qApp->setActiveWindow(&mdiArea);
 
     // Add one maximized window.
@@ -2040,9 +2009,7 @@ void tst_QMdiArea::delayedPlacement()
 
     mdiArea.resize(window3->minimumSizeHint().width() * 3, 400);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     QCOMPARE(window1->geometry().topLeft(), QPoint(0, 0));
     QCOMPARE(window2->geometry().topLeft(), window1->geometry().topRight() + QPoint(1, 0));
@@ -2058,9 +2025,7 @@ void tst_QMdiArea::iconGeometryInMenuBar()
     QMdiSubWindow *subWindow = mdiArea->addSubWindow(new QWidget);
     mainWindow.setCentralWidget(mdiArea);
     mainWindow.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mainWindow);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
 
     subWindow->showMaximized();
     QVERIFY(subWindow->isMaximized());
@@ -2108,10 +2073,7 @@ void tst_QMdiArea::resizeTimer()
     QMdiArea mdiArea;
     QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QWidget);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
-    QTest::qWaitForWindowShown(&mdiArea);
+    QVERIFY(QTest::qWaitForWindowActive(&mdiArea));
 
 #ifndef Q_OS_WINCE
     int time = 250;
@@ -2119,8 +2081,6 @@ void tst_QMdiArea::resizeTimer()
     int time = 1000;
 #endif
 
-    QTest::qWait(time);
-
     EventSpy timerEventSpy(subWindow, QEvent::Timer);
     QCOMPARE(timerEventSpy.count(), 0);
 
@@ -2149,9 +2109,7 @@ void tst_QMdiArea::updateScrollBars()
     QMdiSubWindow *subWindow2 = mdiArea.addSubWindow(new QWidget);
 
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
     qApp->processEvents();
 
     QScrollBar *hbar = mdiArea.horizontalScrollBar();
@@ -2178,9 +2136,7 @@ void tst_QMdiArea::updateScrollBars()
 
     // We still shouldn't get any scroll bars.
     mdiArea.resize(mdiArea.size() - QSize(20, 20));
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
     qApp->processEvents();
     QVERIFY(subWindow1->isMaximized());
     QVERIFY(!hbar->isVisible());
@@ -2272,9 +2228,7 @@ void tst_QMdiArea::setActivationOrder()
     QCOMPARE(mdiArea.subWindowList(activationOrder), subWindows);
 
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     for (int i = 0; i < subWindows.count(); ++i) {
         mdiArea.activateNextSubWindow();
@@ -2333,9 +2287,7 @@ void tst_QMdiArea::tabBetweenSubWindows()
         subWindows << mdiArea.addSubWindow(new QLineEdit);
 
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     qApp->setActiveWindow(&mdiArea);
     QWidget *focusWidget = subWindows.back()->widget();
@@ -2389,9 +2341,7 @@ void tst_QMdiArea::setViewMode()
     }
 
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     QMdiSubWindow *activeSubWindow = mdiArea.activeSubWindow();
     const QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
@@ -2553,9 +2503,7 @@ void tst_QMdiArea::setTabShape()
     QMdiArea mdiArea;
     mdiArea.addSubWindow(new QWidget);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     // Default.
     QCOMPARE(mdiArea.tabShape(), QTabWidget::Rounded);
@@ -2601,9 +2549,7 @@ void tst_QMdiArea::setTabPosition()
     QMdiArea mdiArea;
     mdiArea.addSubWindow(new QWidget);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     // Make sure there are no margins.
     mdiArea.setContentsMargins(0, 0, 0, 0);
@@ -2661,9 +2607,7 @@ void tst_QMdiArea::nativeSubWindows()
     mdiArea.addSubWindow(new QWidget);
     mdiArea.addSubWindow(new QWidget);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     // No native widgets.
     QVERIFY(!mdiArea.viewport()->internalWinId());
@@ -2694,9 +2638,7 @@ void tst_QMdiArea::nativeSubWindows()
     (void)nativeWidget->winId();
     mdiArea.addSubWindow(nativeWidget);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     // The viewport and all the sub-windows must be native.
     QVERIFY(mdiArea.viewport()->internalWinId());
@@ -2709,9 +2651,7 @@ void tst_QMdiArea::nativeSubWindows()
     mdiArea.addSubWindow(new QWidget);
     mdiArea.addSubWindow(new QWidget);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     QMdiSubWindow *nativeSubWindow = mdiArea.subWindowList().last();
     QVERIFY(!nativeSubWindow->internalWinId());
@@ -2734,9 +2674,7 @@ void tst_QMdiArea::nativeSubWindows()
     mdiArea.addSubWindow(new QWidget);
     mdiArea.addSubWindow(new QWidget);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     const QGLContext *context = glViewport->context();
     if (!context || !context->isValid())
index 79afd14..98a3675 100644 (file)
@@ -64,9 +64,6 @@
 #endif
 
 QT_BEGIN_NAMESPACE
-#if defined(Q_WS_X11)
-extern void qt_x11_wait_for_window_manager(QWidget *w);
-#endif
 #if !defined(Q_WS_WIN)
 extern bool qt_tab_all_widgets;
 #endif
@@ -254,9 +251,7 @@ void tst_QMdiSubWindow::minimumSize()
     QMdiSubWindow *subWindow1 = mdiArea.addSubWindow(new QWidget);
     subWindow1->setMinimumSize(1000, 1000);
     mdiArea.show();
-#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
     QCOMPARE(subWindow1->size(), QSize(1000, 1000));
 
     // Check that we respect the minimum size set on the internal widget.
@@ -322,9 +317,7 @@ void tst_QMdiSubWindow::setWindowState()
     QMdiSubWindow *window = qobject_cast<QMdiSubWindow *>(workspace.addSubWindow(new QLineEdit));
     window->show();
     workspace.show();
-#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(&workspace);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&workspace));
 
     QWidget *testWidget = 0;
     for (int iteration = 0; iteration < 2; ++iteration) {
@@ -535,9 +528,7 @@ void tst_QMdiSubWindow::emittingOfSignals()
 
     window->setParent(0);
     window->showNormal();
-#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(window);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(window));
     qApp->processEvents();
 
     spy.clear();
@@ -555,9 +546,7 @@ void tst_QMdiSubWindow::showShaded()
     window->resize(300, 300);
     qApp->processEvents();
     workspace.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&workspace);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&workspace));
 
     QVERIFY(!window->isShaded());
     QVERIFY(!window->isMaximized());
@@ -652,9 +641,7 @@ void tst_QMdiSubWindow::showNormal()
     qApp->processEvents();
     workspace.show();
     window->show();
-#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(&workspace);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&workspace));
 
     QRect originalGeometry = window->geometry();
     QVERIFY(QMetaObject::invokeMethod(window, slot.data()));
@@ -718,9 +705,7 @@ void tst_QMdiSubWindow::setOpaqueResizeAndMove()
     qApp->processEvents();
     workspace.resize(workspaceSize);
     workspace.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&workspace);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&workspace));
 
     QWidget *mouseReceiver = 0;
     if (window->style()->inherits("QMacStyle"))
@@ -918,9 +903,7 @@ void tst_QMdiSubWindow::setWindowFlags()
     qApp->processEvents();
     workspace.show();
     window->show();
-#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(&workspace);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&workspace));
 
     window->setWindowFlags(windowType | customFlags);
     QCOMPARE(window->windowType(), expectedWindowType);
@@ -1387,9 +1370,7 @@ void tst_QMdiSubWindow::resizeEvents()
     QMdiArea *mdiArea = new QMdiArea;
     mainWindow.setCentralWidget(mdiArea);
     mainWindow.show();
-#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(&mainWindow);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
 
     QMdiSubWindow *window = mdiArea->addSubWindow(new QTextEdit);
     window->show();
@@ -1464,9 +1445,7 @@ void tst_QMdiSubWindow::hideAndShow()
     QMenuBar *menuBar = mainWindow.menuBar();
     mainWindow.setCentralWidget(tabWidget);
     mainWindow.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mainWindow);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
 
     QVERIFY(!menuBar->cornerWidget(Qt::TopRightCorner));
     QMdiSubWindow *subWindow = mdiArea->addSubWindow(new QTextEdit);
@@ -1559,9 +1538,7 @@ void tst_QMdiSubWindow::keepWindowMaximizedState()
     QMdiArea mdiArea;
     QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QTextEdit);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     subWindow->showMaximized();
     QVERIFY(subWindow->isMaximized());
@@ -1600,9 +1577,7 @@ void tst_QMdiSubWindow::explicitlyHiddenWidget()
     textEdit->hide();
     QMdiSubWindow *subWindow = mdiArea.addSubWindow(textEdit);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     QVERIFY(subWindow->isVisible());
     QVERIFY(!textEdit->isVisible());
@@ -1673,9 +1648,7 @@ void tst_QMdiSubWindow::fixedMinMaxSize()
     QMdiArea mdiArea;
     mdiArea.setGeometry(0, 0, 640, 480);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     const QSize minimumSize = QSize(250, 150);
     const QSize maximumSize = QSize(300, 200);
@@ -1744,9 +1717,7 @@ void tst_QMdiSubWindow::replaceMenuBarWhileMaximized()
     mainWindow.setCentralWidget(mdiArea);
     QMenuBar *menuBar = mainWindow.menuBar();
     mainWindow.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mainWindow);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
 
     qApp->processEvents();
 
@@ -1803,9 +1774,7 @@ void tst_QMdiSubWindow::closeOnDoubleClick()
     QMdiArea mdiArea;
     QPointer<QMdiSubWindow> subWindow = mdiArea.addSubWindow(new QWidget);
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     subWindow->showSystemMenu();
     QTest::qWait(200);
@@ -1831,9 +1800,8 @@ void tst_QMdiSubWindow::setFont()
     subWindow->resize(300, 100);
     subWindow->setWindowTitle(QLatin1String("Window title"));
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
+
 
     const QFont originalFont = QApplication::font("QMdiSubWindowTitleBar");
     QStyleOptionTitleBar opt;
@@ -1870,9 +1838,7 @@ void tst_QMdiSubWindow::task_188849()
     QMdiSubWindow *subWindow = mdiArea->addSubWindow(new QWidget);
     mainWindow.setCentralWidget(mdiArea);
     mainWindow.show();
-#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(&mainWindow);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
 
     // QMdiSubWindow will now try to show its buttons in the menu bar.
     // Without checking that the menu bar is actually a QMenuBar
@@ -2015,9 +1981,7 @@ void tst_QMdiSubWindow::task_226929()
 {
     QMdiArea mdiArea;
     mdiArea.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mdiArea);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
 
     QMdiSubWindow *sub1 = mdiArea.addSubWindow(new QTextEdit);
     sub1->showMinimized();
index d5e8dce..8943735 100644 (file)
@@ -553,8 +553,8 @@ void tst_QMenu::tearOff()
     QVERIFY(menu->isTearOffEnabled());
 
     widget.show();
-    QTest::qWaitForWindowShown(&widget);
     widget.activateWindow();
+    QVERIFY(QTest::qWaitForWindowActive(&widget));
     menu->popup(QPoint(0,0));
     QTest::qWait(50);
     QVERIFY(!menu->isTearOffMenuVisible());
index 6f7d751..5a2cf0f 100644 (file)
@@ -1264,8 +1264,8 @@ void tst_QMenuBar::taskQTBUG11823_crashwithInvisibleActions()
     QAction * a = menubar.addAction( "&a" );
 
     menubar.show();
-    QTest::qWaitForWindowShown(&menubar);
     QApplication::setActiveWindow(&menubar);
+    QVERIFY(QTest::qWaitForWindowActive(&menubar));
     menubar.setActiveAction(m);
     QCOMPARE(menubar.activeAction(), m);
     QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Right);
index 89f2508..84e3acb 100644 (file)
@@ -219,9 +219,7 @@ void tst_QProgressBar::setMinMaxRepaint()
     pbar.setMaximum(10);
     pbar.setFormat("%v");
     pbar.show();
-    QTest::qWaitForWindowShown(&pbar);
-
-    QApplication::processEvents();
+    QVERIFY(QTest::qWaitForWindowActive(&pbar));
 
     // No repaint when setting minimum to the current minimum
     pbar.repainted = false;
index a0a314b..c40ad18 100644 (file)
@@ -88,11 +88,8 @@ public:
     void changeEvent(QEvent *event)
     {
         QWidget::changeEvent(event);
-        if (isWindow() && event->type() == QEvent::WindowStateChange) {
-#ifdef Q_WS_X11
-            qt_x11_wait_for_window_manager(this);
-#endif
-        }
+        if (isWindow() && event->type() == QEvent::WindowStateChange)
+            QVERIFY(QTest::qWaitForWindowExposed(this));
     }
 };
 
index 5105ed6..13da443 100644 (file)
@@ -919,13 +919,10 @@ void tst_QSpinBox::specialValue()
     spin.setMaximum(100);
     spin.setValue(50);
     topWidget.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&topWidget);
-#endif
-    QTest::qWait(100);
     //make sure we have the focus (even if editingFinished fails)
     qApp->setActiveWindow(&topWidget);
     topWidget.activateWindow();
+    QVERIFY(QTest::qWaitForWindowActive(&topWidget));
     spin.setFocus();
 
     QTest::keyClick(&spin, Qt::Key_Return);
index ca54564..1f7e746 100644 (file)
@@ -172,9 +172,7 @@ void tst_QStatusBar::setSizeGripEnabled()
     QPointer<QStatusBar> statusBar = mainWindow.statusBar();
     QVERIFY(statusBar);
     mainWindow.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mainWindow);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
 
     QTRY_VERIFY(statusBar->isVisible());
     QPointer<QSizeGrip> sizeGrip = qFindChild<QSizeGrip *>(statusBar);
@@ -203,9 +201,7 @@ void tst_QStatusBar::setSizeGripEnabled()
 #ifndef Q_OS_MAC // Work around Lion fullscreen issues on CI system - QTQAINFRA-506
     mainWindow.showFullScreen();
 #endif
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&mainWindow);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
     qApp->processEvents();
 
     mainWindow.setStatusBar(new QStatusBar(&mainWindow));
@@ -265,15 +261,15 @@ void tst_QStatusBar::QTBUG4334_hiddenOnMaximizedWindow()
     statusbar.setSizeGripEnabled(true);
     main.setStatusBar(&statusbar);
     main.showMaximized();
-    QTest::qWaitForWindowShown(&main);
+    QVERIFY(QTest::qWaitForWindowActive(&main));
 #ifndef Q_OS_MAC
     QVERIFY(!statusbar.findChild<QSizeGrip*>()->isVisible());
 #endif
     main.showNormal();
-    QTest::qWaitForWindowShown(&main);
+    QVERIFY(QTest::qWaitForWindowExposed(&main));
     QVERIFY(statusbar.findChild<QSizeGrip*>()->isVisible());
     main.showFullScreen();
-    QTest::qWaitForWindowShown(&main);
+    QVERIFY(QTest::qWaitForWindowExposed(&main));
     QVERIFY(!statusbar.findChild<QSizeGrip*>()->isVisible());
 }
 
index f4fb6a9..a7db9a0 100644 (file)
@@ -529,9 +529,7 @@ void tst_QToolBar::actionGeometry()
     tb.addAction(&action4);
 
     tb.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&tb);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&tb));
 
     QList<QToolBarExtension *> extensions = tb.findChildren<QToolBarExtension *>();
 
@@ -853,9 +851,7 @@ void tst_QToolBar::actionTriggered()
     tb.addAction(&action4);
 
     tb.show();
-#ifdef Q_WS_X11
-    qt_x11_wait_for_window_manager(&tb);
-#endif
+    QVERIFY(QTest::qWaitForWindowExposed(&tb));
 
     QList<QToolBarExtension *> extensions = tb.findChildren<QToolBarExtension *>();