tst_Q*AnimationGroup: use QBasicTimer instead of handling raw timer ids

Change-Id: I1392a62e358e8367c24f3db839d53fc0b072483a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ahmad Samir 2024-08-22 22:07:16 +03:00
parent 7595c21be8
commit 52fd8c716e
2 changed files with 16 additions and 12 deletions

View File

@ -8,9 +8,12 @@
#include <QSignalSpy>
#include <QtCore/qanimationgroup.h>
#include <QtCore/qbasictimer.h>
#include <QtCore/qsequentialanimationgroup.h>
#include <QtCore/qparallelanimationgroup.h>
using namespace std::chrono_literals;
Q_DECLARE_METATYPE(QAbstractAnimation::State)
class tst_QAnimationGroup : public QObject
@ -72,7 +75,7 @@ class UncontrolledAnimation : public QPropertyAnimation
Q_OBJECT
public:
UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = nullptr)
: QPropertyAnimation(target, propertyName, parent), id(0)
: QPropertyAnimation(target, propertyName, parent)
{
setDuration(250);
}
@ -82,22 +85,21 @@ public:
protected:
void timerEvent(QTimerEvent *event) override
{
if (event->timerId() == id)
if (event->id() == timer.id())
stop();
}
void updateRunning(bool running)
{
if (running) {
id = startTimer(500);
timer.start(500ms, this);
} else {
killTimer(id);
id = 0;
timer.stop();
}
}
private:
int id;
QBasicTimer timer;
};
void tst_QAnimationGroup::emptyGroup()

View File

@ -6,9 +6,12 @@
#include <QPropertyAnimation>
#include <QSignalSpy>
#include <QtCore/qbasictimer.h>
#include <QtCore/qparallelanimationgroup.h>
#include <QtCore/qscopeguard.h>
using namespace std::chrono_literals;
Q_DECLARE_METATYPE(QAbstractAnimation::State)
class tst_QParallelAnimationGroup : public QObject
@ -107,7 +110,7 @@ class UncontrolledAnimation : public QPropertyAnimation
Q_OBJECT
public:
UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = nullptr)
: QPropertyAnimation(target, propertyName, parent), id(0)
: QPropertyAnimation(target, propertyName, parent)
{
setDuration(250);
setEndValue(0);
@ -118,22 +121,21 @@ public:
protected:
void timerEvent(QTimerEvent *event) override
{
if (event->timerId() == id)
if (event->id() == timer.id())
stop();
}
void updateRunning(bool running)
{
if (running) {
id = startTimer(500);
timer.start(500ms, this);
} else {
killTimer(id);
id = 0;
timer.stop();
}
}
private:
int id;
QBasicTimer timer;
};
void tst_QParallelAnimationGroup::setCurrentTime()