ValueRangeConstraint Item

class ValueRangeConstraint

Checks whether a property is in a certain range.

Inherits:Component
Properties:enabled, evaluateOnFinished, evaluateOnValidation, maxValue minValue, valid, value

Detailed Description

ValueRangeConstraint checks whether value is within a range given by minValue and maxValue.

The constraint has two stages: validation and evaluation. Validation happens immediately after the value property has changed. Whether value 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
import QtQml 2.0 as QtQml

Testcase {

    QtQml.Timer {
        id: timer
        repeat: true
        interval: 123

        onTriggered: adc.start
    }

    AdcProbe {
        id: adc
        ioid: 23
    }

    ValueRangeConstraint {
        id: constraint
        minValue: 100
        maxValue: 300

        value: adc.value
    }

    function run() {
        timer.start
        Qst.wait(4000)
    }

Properties

bool enabled
Default:true

When false, the value property does not have any effect and the constraint is neither validated nor evaluated.

bool evaluateOnFinished
Default:false

If true, the constraint will be evaluated by Qst just before Testcase::finished().

See also evaluateOnValidation

bool evaluateOnValidation
Default:true

If true, the test case will fail immediately when validation fails. If false, then the constraint will not be evaluated immediately. Instead, it will be evaluated on Testcase::finished().

See also evaluateOnFinished

var maxValue
Default:undefined

Specifies the maximum allowed value.

See also minValue

var minValue
Default:undefined

Specifies the minimum allowed value.

See also maxValue

bool valid
Default:false

Reflects whether value is within the specified range.

var value
Default:undefined

The value to be validated. This property is usually bound to a property of another component. It may also be written manually if desired.