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

Document that qtest-qml's SignalSpy can be used for confirming that signal in *not* emitted

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • Not Evaluated
    • 5.0.0
    • 4.7.3
    • Testing: QuickTest
    • None

    Description

      qtest-qml and has pretty good documentation http://qt.gitorious.net/qt-labs/qtest-qml
      Its SignalSpy is a good tool for verifying that the signal is emitted. It took me however quite some time to realize that it can also be used for verifying that signal is not emitted within the given time.

      SignalSpy's wait() method fails if signal is not emitted, but TestCase's wait() method provides an alternative for waiting and SignalSpy continues to listen to signal without any extra activation needed. It would be cool to document the following:

      1) SignalSpy is listening all the time, not only when its wait() is called
      2) Show an example of a test that confirms that signal is not emitted within a given time. Something like the following:

      import QtQuick 1.0
      import QtQuickTest 1.0
      
      Rectangle{
          id: main
          width: 400
          height: 300
          color: "lightblue"
      
          MouseArea {
              id: testArea
              anchors.fill: parent
          }
      
          SignalSpy {
              id: clickSpy
              target: testArea
              signalName: "clicked"
          }
      
          TestCase {
              id: mainCase
              name: "SignalSpy tests"
      
              /** mouse signals cannot be simulated until window is shown */
              when: windowShown
      
              function test_canCaptureClickSignal() {
                  clickSpy.clear()
                  mouseClick(testArea, 5, 5)
                  clickSpy.wait()
                  compare(clickSpy.count, 1)
              }
      
              function test_canConfirmThatSignalIsNotEmittedWithin600Ms() {
                  clickSpy.clear()
      
                  // if the following line is uncommented, test will fail
                  // mouseClick(testArea, 5, 5)
                  wait(600)
                  compare(clickSpy.count, 0)
              }
      
          }
      
      
      }
      

      Attachments

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

        Activity

          People

            charles Charles Yin (closed Nokia identity) (Inactive)
            artem.marchenko Artem Marchenko
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes