[Development] QTest qWaitForWindowExposed and qWaitForWindowActive (was: Consistently flaky test QTabWidget test)

Morten Sørvig Morten.Sorvig at qt.io
Wed May 2 15:07:21 CEST 2018


> On 2 May 2018, at 09:29, Thiago Macieira <thiago.macieira at intel.com> wrote:
> 
> FAIL!  : tst_QTabWidget::paintEventCount() Compared values are not the same
>    Actual   (tab2->count): 2
>    Expected (1)          : 1
>    Loc: [tst_qtabwidget.cpp(573)]
> [on macOS 10.12]

Hi,

I recently investigated a similar issue as to the one described here, where
tests where failing due to extra paint events. This resulted in a couple of
patches to stabilize tests, and discussions on how to proceed, all of which
is documented on QTBUG-61967. (I unfortunately failed to share the outcome of 
the discussions beyond posting on that bug, which I’m rectifying now).

To recap:

* WindowExposed occurs when the window becomes visible on screen and is
  about to draw the first frame.

* WindowActive occurs if/when the platform makes the window active, which
  may trigger a repaint to make widgets etc have the “active” styling.

WindowActive may occur either before or after Exposed, depending on
platform (plugin) implementation and/or platform timing outside of our
control. This means that a test that waits for Exposed before starting
to count paint events may have the count erroneously increased when the
Active event arrives.

It could be argued that WindowActive a sub-state of WindowExposed and that
the platform plugin should enforce the ordering, but in the end we settled
on keeping them separate. This means tests might want to wait for both:

    QTest::qWaitForWindowExposed(window);
    QTest::qWaitForWindowActive(window);
    // Now count paint events.

This is obviously a bit unwieldy so we want to improve the API as well:
watch QTBUG-61967 for updates.

Morten





More information about the Development mailing list