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

QSignalSpy: allow for waiting multiple signals

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Testing: qtestlib
    • None

    Description

      It would be preferential to increase correctness of some tests by having the ability to wait for multiple signals simultaneously.

      MyServer server("localhost", 8888);
      server.listen();
      MyClient client ("localhost", 8888);
      client.connect();
      QSignalSpy server_spy(&server, &MyServer::newClient));
      QSignalSpy client_spy(&client, &MyClient::connected));
      //Wrong, but will mostly work => flaky tests
      QVERIFY(server_spy.wait());
      QCOPMARE(client_spy.count(), 1);
      //Correct, but very verbose
      QVERIFY(server_spy.wait());
      if(client_spy.count() != 0)
          QVERIFY(client_spy.wait());
      //Future
      QVERIFY(qWaitAll(client_spy, server_spy))
      

      Otherwise it will lead to flaky tests, because people keep forgetting that the other signal might not be delivered yet when QueuedConnection is used. Eg. because of Threads

      Attachments

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

        Activity

          People

            macadder Jason McDonald
            richardo Richard Öhlinger
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes