diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-10-06 07:01:29 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-10-07 06:02:21 +0300 |
commit | 9c6794164de4f30e33e00a5d3d5d6f41706e523e (patch) | |
tree | 2547f9bede082558f5d04e38a77dec91ea172ee1 /test | |
parent | 36c35345fa3ba4eb7c7652caae6eecb44ba37770 (diff) |
test: timer: Test that deadline() isn't reset upon time out
Verify that the timer deadline stays valid after the timer expires. As
the test now uses the deadline in order to compute the jitter, the
interval_ field isn't used anymore and can be removed.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/timer.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/test/timer.cpp b/test/timer.cpp index af922cb3..d4f16a9b 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -21,14 +21,13 @@ class ManagedTimer : public Timer { public: ManagedTimer() - : Timer(), interval_(0) + : Timer() { timeout.connect(this, &ManagedTimer::timeoutHandler); } void start(int msec) { - interval_ = msec; start_ = std::chrono::steady_clock::now(); expiration_ = std::chrono::steady_clock::time_point(); @@ -37,9 +36,8 @@ public: int jitter() { - std::chrono::steady_clock::duration duration = expiration_ - start_; - int msecs = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count(); - return abs(msecs - interval_); + std::chrono::steady_clock::duration duration = expiration_ - deadline(); + return abs(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count()); } private: @@ -48,7 +46,6 @@ private: expiration_ = std::chrono::steady_clock::now(); } - int interval_; std::chrono::steady_clock::time_point start_; std::chrono::steady_clock::time_point expiration_; }; |