From 9c6794164de4f30e33e00a5d3d5d6f41706e523e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 6 Oct 2019 07:01:29 +0300 Subject: test: timer: Test that deadline() isn't reset upon time out MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- test/timer.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'test/timer.cpp') 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(duration).count(); - return abs(msecs - interval_); + std::chrono::steady_clock::duration duration = expiration_ - deadline(); + return abs(std::chrono::duration_cast(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_; }; -- cgit v1.2.1