summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/qanimation
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-04-29 10:59:05 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-04-29 10:59:05 (GMT)
commit36aa9e0468bfa874679dd94b2d50850a1dd7a1d1 (patch)
tree585b145cfa67baedfa06beabd397645343c7fbbe /tests/benchmarks/qanimation
parent6f955aedcdb6c2b1de04d1cd7e959e284581b3b3 (diff)
downloadQt-36aa9e0468bfa874679dd94b2d50850a1dd7a1d1.zip
Qt-36aa9e0468bfa874679dd94b2d50850a1dd7a1d1.tar.gz
Qt-36aa9e0468bfa874679dd94b2d50850a1dd7a1d1.tar.bz2
compile fix for the benchmark
QItemAnimation has disappeared and it's now better to start the animation instead of pausing it
Diffstat (limited to 'tests/benchmarks/qanimation')
-rw-r--r--tests/benchmarks/qanimation/main.cpp57
-rw-r--r--tests/benchmarks/qanimation/rectanimation.cpp28
-rw-r--r--tests/benchmarks/qanimation/rectanimation.h10
3 files changed, 36 insertions, 59 deletions
diff --git a/tests/benchmarks/qanimation/main.cpp b/tests/benchmarks/qanimation/main.cpp
index 7bbcffb..7bb770f 100644
--- a/tests/benchmarks/qanimation/main.cpp
+++ b/tests/benchmarks/qanimation/main.cpp
@@ -11,8 +11,6 @@ class tst_qanimation : public QObject
{
Q_OBJECT
private slots:
- void itemAnimation();
- void itemAnimation_data() { data();}
void itemPropertyAnimation();
void itemPropertyAnimation_data() { data();}
void dummyAnimation();
@@ -32,35 +30,14 @@ private:
void tst_qanimation::data()
{
- QTest::addColumn<bool>("paused");
+ QTest::addColumn<bool>("started");
QTest::newRow("NotRunning") << false;
- QTest::newRow("Paused") << true;
-}
-
-void tst_qanimation::itemAnimation()
-{
- QFETCH(bool, paused);
- QGraphicsWidget item;
-
- //first the item animation
- {
- QItemAnimation anim(&item, QItemAnimation::Position);
- anim.setDuration(ITERATION_COUNT);
- anim.setStartValue(QPointF(0,0));
- anim.setEndValue(QPointF(ITERATION_COUNT,ITERATION_COUNT));
- if (paused)
- anim.pause();
- QBENCHMARK {
- for(int i = 0; i < anim.duration(); ++i) {
- anim.setCurrentTime(i);
- }
- }
- }
+ QTest::newRow("Running") << true;
}
void tst_qanimation::itemPropertyAnimation()
{
- QFETCH(bool, paused);
+ QFETCH(bool, started);
QGraphicsWidget item;
//then the property animation
@@ -69,8 +46,8 @@ void tst_qanimation::itemPropertyAnimation()
anim.setDuration(ITERATION_COUNT);
anim.setStartValue(QPointF(0,0));
anim.setEndValue(QPointF(ITERATION_COUNT,ITERATION_COUNT));
- if (paused)
- anim.pause();
+ if (started)
+ anim.start();
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
anim.setCurrentTime(i);
@@ -82,7 +59,7 @@ void tst_qanimation::itemPropertyAnimation()
void tst_qanimation::dummyAnimation()
{
- QFETCH(bool, paused);
+ QFETCH(bool, started);
DummyObject dummy;
//first the dummy animation
@@ -91,8 +68,8 @@ void tst_qanimation::dummyAnimation()
anim.setDuration(ITERATION_COUNT);
anim.setStartValue(QRect(0, 0, 0, 0));
anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT));
- if (paused)
- anim.pause();
+ if (started)
+ anim.start();
QBENCHMARK {
for(int i = 0; i < anim.duration(); ++i) {
anim.setCurrentTime(i);
@@ -103,7 +80,7 @@ void tst_qanimation::dummyAnimation()
void tst_qanimation::dummyPropertyAnimation()
{
- QFETCH(bool, paused);
+ QFETCH(bool, started);
DummyObject dummy;
//then the property animation
@@ -112,8 +89,8 @@ void tst_qanimation::dummyPropertyAnimation()
anim.setDuration(ITERATION_COUNT);
anim.setStartValue(QRect(0, 0, 0, 0));
anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT));
- if (paused)
- anim.pause();
+ if (started)
+ anim.start();
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
anim.setCurrentTime(i);
@@ -125,7 +102,7 @@ void tst_qanimation::dummyPropertyAnimation()
void tst_qanimation::rectAnimation()
{
//this is the simplest animation you can do
- QFETCH(bool, paused);
+ QFETCH(bool, started);
DummyObject dummy;
//then the property animation
@@ -134,8 +111,8 @@ void tst_qanimation::rectAnimation()
anim.setDuration(ITERATION_COUNT);
anim.setStartValue(QRect(0, 0, 0, 0));
anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT));
- if (paused)
- anim.pause();
+ if (started)
+ anim.start();
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
anim.setCurrentTime(i);
@@ -147,7 +124,7 @@ void tst_qanimation::rectAnimation()
void tst_qanimation::floatAnimation()
{
//this is the simplest animation you can do
- QFETCH(bool, paused);
+ QFETCH(bool, started);
DummyObject dummy;
//then the property animation
@@ -156,8 +133,8 @@ void tst_qanimation::floatAnimation()
anim.setDuration(ITERATION_COUNT);
anim.setStartValue(0.f);
anim.setEndValue(1.f);
- if (paused)
- anim.pause();
+ if (started)
+ anim.start();
QBENCHMARK {
for(int i = 0; i < ITERATION_COUNT; ++i) {
anim.setCurrentTime(i);
diff --git a/tests/benchmarks/qanimation/rectanimation.cpp b/tests/benchmarks/qanimation/rectanimation.cpp
index 66c7a33..d60a943 100644
--- a/tests/benchmarks/qanimation/rectanimation.cpp
+++ b/tests/benchmarks/qanimation/rectanimation.cpp
@@ -7,49 +7,49 @@ static inline int interpolateInteger(int from, int to, qreal progress)
}
-RectAnimation::RectAnimation(DummyObject *obj) : object(obj), dura(250)
+RectAnimation::RectAnimation(DummyObject *obj) : m_object(obj), m_dura(250)
{
}
void RectAnimation::setEndValue(const QRect &rect)
{
- end = rect;
+ m_end = rect;
}
void RectAnimation::setStartValue(const QRect &rect)
{
- start = rect;
+ m_start = rect;
}
void RectAnimation::setDuration(int d)
{
- dura = d;
+ m_dura = d;
}
int RectAnimation::duration() const
{
- return dura;
+ return m_dura;
}
void RectAnimation::updateCurrentTime(int msecs)
{
- qreal progress = easing.valueForProgress( qreal(msecs) / qreal(dura) );
+ qreal progress = m_easing.valueForProgress( qreal(msecs) / qreal(m_dura) );
QRect now;
- now.setCoords(interpolateInteger(start.left(), end.left(), progress),
- interpolateInteger(start.top(), end.top(), progress),
- interpolateInteger(start.right(), end.right(), progress),
- interpolateInteger(start.bottom(), end.bottom(), progress));
+ now.setCoords(interpolateInteger(m_start.left(), m_end.left(), progress),
+ interpolateInteger(m_start.top(), m_end.top(), progress),
+ interpolateInteger(m_start.right(), m_end.right(), progress),
+ interpolateInteger(m_start.bottom(), m_end.bottom(), progress));
- bool changed = (now != current);
+ bool changed = (now != m_current);
if (changed)
- current = now;
+ m_current = now;
if (state() == Stopped)
return;
- if (object)
- object->setRect(current);
+ if (m_object)
+ m_object->setRect(m_current);
}
void RectAnimation::updateState(QAbstractAnimation::State state)
diff --git a/tests/benchmarks/qanimation/rectanimation.h b/tests/benchmarks/qanimation/rectanimation.h
index c9770c4..99b82b4 100644
--- a/tests/benchmarks/qanimation/rectanimation.h
+++ b/tests/benchmarks/qanimation/rectanimation.h
@@ -21,10 +21,10 @@ public:
virtual void updateState(QAbstractAnimation::State state);
private:
- DummyObject *object;
- QEasingCurve easing;
- QRect start, end, current;
- int dura;
+ DummyObject *m_object;
+ QEasingCurve m_easing;
+ QRect m_start, m_end, m_current;
+ int m_dura;
};
-#endif \ No newline at end of file
+#endif