OpenCoverage

qquickbehavior.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/util/qquickbehavior.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7class QQuickBehaviorPrivate : public QObjectPrivate, public QAnimationJobChangeListener-
8{-
9 inline QQuickBehavior* q_func() { return static_cast<QQuickBehavior *>(q_ptr); } inline const QQuickBehavior* q_func() const { return static_cast<const QQuickBehavior *>(q_ptr); } friend class QQuickBehavior;-
10public:-
11 QQuickBehaviorPrivate() : animation(nullptr), animationInstance(nullptr), enabled(true), finalized(false)-
12 , blockRunningChanged(false) {}
executed 560 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
560
13-
14 void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override;-
15-
16 QQmlProperty property;-
17 QVariant targetValue;-
18 QPointer<QQuickAbstractAnimation> animation;-
19 QAbstractAnimationJob *animationInstance;-
20 bool enabled;-
21 bool finalized;-
22 bool blockRunningChanged;-
23};-
24QQuickBehavior::QQuickBehavior(QObject *parent)-
25 : QObject(*(new QQuickBehaviorPrivate), parent)-
26{-
27}
executed 560 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
560
28-
29QQuickBehavior::~QQuickBehavior()-
30{-
31 QQuickBehaviorPrivate * const d = d_func();-
32 delete d->animationInstance;-
33}
executed 558 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
558
34QQuickAbstractAnimation *QQuickBehavior::animation()-
35{-
36 QQuickBehaviorPrivate * const d = d_func();-
37 return
executed 10 times by 1 test: return d->animation;
Executed by:
  • tst_qquickbehaviors
d->animation;
executed 10 times by 1 test: return d->animation;
Executed by:
  • tst_qquickbehaviors
10
38}-
39-
40void QQuickBehavior::setAnimation(QQuickAbstractAnimation *animation)-
41{-
42 QQuickBehaviorPrivate * const d = d_func();-
43 if (d->animation
d->animationDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickbehaviors
FALSEevaluated 194 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
) {
2-194
44 qmlWarning(this) << tr("Cannot change the animation assigned to a Behavior.");-
45 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquickbehaviors
2
46 }-
47-
48 d->animation = animation;-
49 if (d->animation
d->animationDescription
TRUEevaluated 194 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
FALSEnever evaluated
) {
0-194
50 d->animation->setDefaultTarget(d->property);-
51 d->animation->setDisableUserControl();-
52 }
executed 194 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
194
53}
executed 194 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
194
54-
55-
56void QQuickBehaviorPrivate::animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState,QAbstractAnimationJob::State)-
57{-
58 if (!blockRunningChanged
!blockRunningChangedDescription
TRUEevaluated 444 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
FALSEnever evaluated
)
0-444
59 animation->notifyRunningChanged(newState == QAbstractAnimationJob::Running);
executed 444 times by 7 tests: animation->notifyRunningChanged(newState == QAbstractAnimationJob::Running);
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
444
60}
executed 444 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
444
61bool QQuickBehavior::enabled() const-
62{-
63 const QQuickBehaviorPrivate * const d = d_func();-
64 return
executed 6 times by 1 test: return d->enabled;
Executed by:
  • tst_qquickbehaviors
d->enabled;
executed 6 times by 1 test: return d->enabled;
Executed by:
  • tst_qquickbehaviors
6
65}-
66-
67void QQuickBehavior::setEnabled(bool enabled)-
68{-
69 QQuickBehaviorPrivate * const d = d_func();-
70 if (d->enabled == enabled
d->enabled == enabledDescription
TRUEevaluated 34 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicklistview
FALSEevaluated 42 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicklistview
)
34-42
71 return;
executed 34 times by 2 tests: return;
Executed by:
  • tst_examples
  • tst_qquicklistview
34
72 d->enabled = enabled;-
73 enabledChanged();-
74}
executed 42 times by 2 tests: end of block
Executed by:
  • tst_qquickbehaviors
  • tst_qquicklistview
42
75-
76void QQuickBehavior::write(const QVariant &value)-
77{-
78 QQuickBehaviorPrivate * const d = d_func();-
79 bool bypass = !d->enabled
!d->enabledDescription
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicklistview
FALSEevaluated 280 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
|| !d->finalized
!d->finalizedDescription
TRUEevaluated 22 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickbehaviors
  • tst_qquickloader
FALSEevaluated 258 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
|| QQmlEnginePrivate::designerMode()
QQmlEnginePriv...designerMode()Description
TRUEnever evaluated
FALSEevaluated 258 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
;
0-280
80 if (!bypass
!bypassDescription
TRUEevaluated 258 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
FALSEevaluated 30 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
)
30-258
81 qmlExecuteDeferred(this);
executed 258 times by 7 tests: qmlExecuteDeferred(this);
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
258
82 if (!d->animation
!d->animationDescription
TRUEevaluated 28 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
FALSEevaluated 260 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
|| bypass
bypassDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickbehaviors
FALSEevaluated 256 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
) {
4-260
83 if (d->animationInstance
d->animationInstanceDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickbehaviors
FALSEevaluated 28 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
)
4-28
84 d->animationInstance->stop();
executed 4 times by 1 test: d->animationInstance->stop();
Executed by:
  • tst_qquickbehaviors
4
85 QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);-
86 d->targetValue = value;-
87 return;
executed 32 times by 5 tests: return;
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
32
88 }-
89-
90 bool behaviorActive = d->animation->isRunning();-
91 if (behaviorActive
behaviorActiveDescription
TRUEevaluated 52 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicksmoothedanimation
FALSEevaluated 204 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
&& value == d->targetValue
value == d->targetValueDescription
TRUEnever evaluated
FALSEevaluated 52 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicksmoothedanimation
)
0-204
92 return;
never executed: return;
0
93-
94 d->targetValue = value;-
95-
96 if (d->animationInstance
d->animationInstanceDescription
TRUEevaluated 68 times by 3 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquicksmoothedanimation
FALSEevaluated 188 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
68-188
97 && (d->animationInstance->duration() != -1
d->animationIn...ration() != -1Description
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicklistview
FALSEevaluated 54 times by 3 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquicksmoothedanimation
14-54
98 || d->animationInstance->isRenderThreadProxy()
d->animationIn...rThreadProxy()Description
TRUEnever evaluated
FALSEevaluated 54 times by 3 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquicksmoothedanimation
)
0-54
99 && !d->animationInstance->isStopped()
!d->animationI...e->isStopped()Description
TRUEnever evaluated
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicklistview
) {
0-14
100 d->blockRunningChanged = true;-
101 d->animationInstance->stop();-
102 }
never executed: end of block
0
103-
104-
105 const QVariant &currentValue = d->property.read();-
106-
107-
108-
109-
110 if (!behaviorActive
!behaviorActiveDescription
TRUEevaluated 204 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
FALSEevaluated 52 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicksmoothedanimation
&& d->targetValue == currentValue
d->targetValue == currentValueDescription
TRUEevaluated 34 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickbehaviors
FALSEevaluated 170 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
) {
34-204
111 QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);-
112 return;
executed 34 times by 3 tests: return;
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickbehaviors
34
113 }-
114-
115 QQuickStateOperation::ActionList actions;-
116 QQuickStateAction action;-
117 action.property = d->property;-
118 action.fromValue = currentValue;-
119 action.toValue = value;-
120 actions << action;-
121-
122 QList<QQmlProperty> after;-
123 QAbstractAnimationJob *prev = d->animationInstance;-
124 d->animationInstance = d->animation->transition(actions, after, QQuickAbstractAnimation::Forward);-
125-
126 if (d->animationInstance
d->animationInstanceDescription
TRUEevaluated 222 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
FALSEnever evaluated
&& d->animation->threadingModel() == QQuickAbstractAnimation::RenderThread
d->animation->...::RenderThreadDescription
TRUEnever evaluated
FALSEevaluated 222 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
)
0-222
127 d->animationInstance = new QQuickAnimatorProxyJob(d->animationInstance, d->animation);
never executed: d->animationInstance = new QQuickAnimatorProxyJob(d->animationInstance, d->animation);
0
128-
129 if (prev
prevDescription
TRUEevaluated 64 times by 3 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquicksmoothedanimation
FALSEevaluated 158 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
&& prev != d->animationInstance
prev != d->animationInstanceDescription
TRUEevaluated 64 times by 3 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquicksmoothedanimation
FALSEnever evaluated
)
0-158
130 delete prev;
executed 64 times by 3 tests: delete prev;
Executed by:
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquicksmoothedanimation
64
131-
132 if (d->animationInstance
d->animationInstanceDescription
TRUEevaluated 222 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
FALSEnever evaluated
) {
0-222
133 if (d->animationInstance != prev
d->animationInstance != prevDescription
TRUEevaluated 222 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
FALSEnever evaluated
)
0-222
134 d->animationInstance->addAnimationChangeListener(d, QAbstractAnimationJob::StateChange);
executed 222 times by 7 tests: d->animationInstance->addAnimationChangeListener(d, QAbstractAnimationJob::StateChange);
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
222
135 d->animationInstance->start();-
136 d->blockRunningChanged = false;-
137 }
executed 222 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
222
138 if (!after.contains(d->property)
!after.contains(d->property)Description
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_qquickbehaviors
  • tst_qquickloader
FALSEevaluated 212 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquicksmoothedanimation
)
10-212
139 QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
executed 10 times by 2 tests: QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
Executed by:
  • tst_qquickbehaviors
  • tst_qquickloader
10
140}
executed 222 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
222
141-
142void QQuickBehavior::setTarget(const QQmlProperty &property)-
143{-
144 QQuickBehaviorPrivate * const d = d_func();-
145 d->property = property;-
146 if (d->animation
d->animationDescription
TRUEevaluated 24 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicksmoothedanimation
FALSEevaluated 534 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
)
24-534
147 d->animation->setDefaultTarget(property);
executed 24 times by 4 tests: d->animation->setDefaultTarget(property);
Executed by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicksmoothedanimation
24
148-
149 QQmlEnginePrivate *engPriv = QQmlEnginePrivate::get(qmlEngine(this));-
150 static int finalizedIdx = -1;-
151 if (finalizedIdx < 0
finalizedIdx < 0Description
TRUEevaluated 14 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
FALSEevaluated 544 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
)
14-544
152 finalizedIdx = metaObject()->indexOfSlot("componentFinalized()");
executed 14 times by 7 tests: finalizedIdx = metaObject()->indexOfSlot("componentFinalized()");
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
14
153 engPriv->registerFinalizeCallback(this, finalizedIdx);-
154}
executed 558 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
558
155-
156void QQuickBehavior::componentFinalized()-
157{-
158 QQuickBehaviorPrivate * const d = d_func();-
159 d->finalized = true;-
160}
executed 558 times by 7 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquicksmoothedanimation
558
161-
162-
163-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0