Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-98921

tst_QGraphicsWidget::initialShow is uber flaky on OpenSUSE

    XMLWordPrintable

Details

    • a2c7428e4d (qt/qtbase/dev) a2c7428e4d (qt/tqtc-qtbase/dev) 17667ce074 (qt/qtbase/6.3) 17667ce074 (qt/tqtc-qtbase/6.3) ca7a2f84de (qt/qtbase/6.4) ca7a2f84de (qt/tqtc-qtbase/6.4) 04b8fb4d71 (qt/tqtc-qtbase/6.2) 7524a36a26 (qt/qtbase/dev)

    Description

      I keep seeing this FAIL on my OpenSUSE Tumbleweed system 9 out of 10 times. I see it failing on OpenSUSE on the CI too.

      $ TESTARGS=initialShow  ctest -V -R tst_qgraphicswidget
      
      498: ********* Start testing of tst_QGraphicsWidget *********
      498: Config: Using QtTest library 6.3.0, Qt 6.3.0 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 11.2.1 20210816 [revision 056e324ce46a7924b5cf10f61010cf9dd2ca10e9]), opensuse-tumbleweed 20211127
      498: PASS   : tst_QGraphicsWidget::initTestCase()
      498: FAIL!  : tst_QGraphicsWidget::initialShow() 'QTest::qWaitForWindowActive(dummyView.data())' returned FALSE. ()
      498:    Loc: [/home/qtjimis/dist/src/qt/qtbase/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp(3129)]
      498: PASS   : tst_QGraphicsWidget::cleanupTestCase()
      498: Totals: 2 passed, 1 failed, 0 skipped, 0 blacklisted, 5062ms
      498: ********* Finished testing of tst_QGraphicsWidget *********

      It always pauses for 5 seconds on the QVERIFY(QTest::qWaitForWindowActive() and then returns failure. The funny thing is that if I remove the 2 qWaitForWindowActive() calls, the test always passes!

      Here is the test (The "REMOVE THIS" annotations are mine and show how the test can be stabilised):

      void tst_QGraphicsWidget::initialShow()
      {
          class MyGraphicsWidget : public QGraphicsWidget
          { public:
              MyGraphicsWidget() : repaints(0) {}
              int repaints;
              void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget*) override { ++repaints; }
              void polishEvent() override { update(); }
          };
      
          // Don't let paint events triggered by the windowing system
          // influence our test case. We're only interested in knowing
          // whether a QGraphicsWidget generates an additional repaint
          // on the initial show. Hence create a dummy scenario to find out
          // how many repaints we should expect.
          QGraphicsScene dummyScene(0, 0, 200, 200);
          dummyScene.addItem(new QGraphicsRectItem(0, 0, 100, 100));
      
          QScopedPointer<QGraphicsView> dummyView(new QGraphicsView(&dummyScene));
          dummyView->setWindowFlags(Qt::X11BypassWindowManagerHint);
          EventSpy paintSpy(dummyView->viewport(), QEvent::Paint);
          dummyView->show();
          qApp->setActiveWindow(dummyView.data());
          QVERIFY(QTest::qWaitForWindowActive(dummyView.data()));        // REMOVE THIS!
          const int expectedRepaintCount = paintSpy.count();
          dummyView.reset();
      
          MyGraphicsWidget *widget = new MyGraphicsWidget;
          widget->resize(100, 100);
      
          QGraphicsScene scene(0, 0, 200, 200);
          scene.addItem(widget);
      
          QGraphicsView view(&scene);
          view.setWindowFlags(view.windowFlags()|Qt::X11BypassWindowManagerHint);
          view.show();
          qApp->setActiveWindow(&view);
          QVERIFY(QTest::qWaitForWindowActive(&view));                // REMOVE THIS TOO!
      
          QTRY_COMPARE(widget->repaints, expectedRepaintCount);
      }
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              vhilshei Volker Hilsheimer
              jimis Dimitrios Apostolou
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: