DurationConstraint Item¶
-
class
DurationConstraint¶ Checks the time between two signal occurrences.
| Inherits: | Component |
|---|---|
| Properties: | beginOn, duration, enabled
endOn, evaluateOnFinished,
evaluateOnValidation, maxDuration,
minDuration. timedOut, valid |
| Methods: | begin(), end() |
Detailed Description¶
DurationConstraint measures the time between two signals
beginOn and endOn. The methods begin()
or end() may be used as an alternative if no signals are available.
The expected duration is configured with minDuration and
maxDuration.
The constraint has two stages: validation and evaluation. Validation happens
immediately after the endOn signal has fired. In the same moment,
the duration property is updated and shows the measured duration.
Whether the duration is within the expected range, can be seen at the property
valid.
During the evaluation stage, it is decided whether the test case is aborted.
Evaluation can either happen immediately after validation
(evaluateOnValidation is true) or just before the
Testcase::finished() event (evaluateOnFinished is
true). The enabled property switches measurement completely on
and off.
Example for measuring the duration between two signals:
import qst 1.0
Testcase {
ProcessProbe {
id: process
command: "sleep"
arguments: [ 3 ]
}
DurationConstraint {
id: constraint
minDuration: 2.9
maxDuration: 3.1
beginOn: process.started
endOn: process.finished
}
function run() {
process.start()
Qst.wait(4000)
}
Example for monitoring a sequence of actions:
import qst 1.0
Testcase {
DurationConstraint {
id: constraint
minDuration: 5
maxDuration: 10
}
function run() {
constraint.begin()
// Now do something very time consuming...
Qst.wait(20); // will be aborted because constraint
// is violated after 10 ms.
}
Properties¶
-
signal
beginOn¶ Default: undefined Starts a measurement action. This property must either be QML signal or an object that defines a
connect()method with a signal handler as parameter. When updating this property, the old signal will be disconnected.
-
bool
enabled¶ Default: trueWhen
false, the signalsbeginOnandendOndo not have any effect and the constraint is neither validated nor evaluated.
-
signal
endOn¶ Default: undefined Ends a measurement cycle and triggers validation. This property must either be QML signal or an object that defines a
connect()method with a signal handler as parameter. When updating this property, the old signal will be disconnected.
-
bool
evaluateOnFinished¶ Default: false If
true, the constraint will be evaluated by Qst just beforeTestcase::finished().See also
evaluateOnValidation
-
bool
evaluateOnValidation¶ Default: true If
true, the test case will fail immediately when validation fails. Iffalse, then the constraint will not be evaluated immediately. Instead, it will be evaluated onTestcase::finished().See also
evaluateOnFinished
-
double
maxDuration¶ Default: 0.0 Specifies the maximum allowed time between
beginOnandendOn. The value must be greater or equalminDuration.See also
minDuration
-
double
minDuration¶ Default: 0.0 Specifies the minimum allowed time between
beginOnandendOn. The value must be less or equalmaxDuration.See also
maxDuration