Skip to content

Latest commit

 

History

History
155 lines (101 loc) · 3.29 KB

signalprobe-item.rst

File metadata and controls

155 lines (101 loc) · 3.29 KB

SignalProbe Item

Properties

  • :cppcondition
  • :cppcount
  • :cppsignal

Methods:

  • :cppclear()
  • :cppconnect()

Signals:

  • :cpptriggered()

Detailed Description

SignalProbe can be used to watch signals of other items. A typical use-case is a counter for asynchronous events:

import qst 1.0
import QtQml 2.0 as QtQml

Testcase {
    QtQml.Timer {
        id : timer
        interval: 5
        periodic: true
    }

    SignalProbe {
        id: probe
        signal: timer.triggered
    }

    function run() {
        Qst.compare(probe.count, 0, "Timer triggered too early");
        timer.start();
        Qst.wait(50);
        timer.stop();
        Qst.verify(probe.count >= 10, "Timer triggered only "
            + probe.count + " times");
    }

The following example shows, how SignalProbe can be used, to attach to a signal that is not directly accessible:

import qst 1.0

Testcase {
    property var pinProbe : PinProbe {
        // properties
        // ...

        // Can attach directly to the valueChanged() signal.
        onValueChanged: {
            Qst.info("pin value is " + pinProbe.value)
        }
    }
}
import qst 1.0

BaseTestcase {
    // Cannot attach directly to pinProbe's valueChanged() signal.
    // Use SignalProbe instead.
    SignalProbe {
        signal: pinProbe.valueChanged
        onTriggered: {
            Qst.info("pin value is " + pinProbe.value)
        }
    }
}

Properties

Methods

Signals