Adding a mockable wrapper class for TickTime in VCM

The class is called TickTimeInterface, with a fake implementation in FakeTickTime.

Review URL: http://webrtc-codereview.appspot.com/323012

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1183 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org 2011-12-14 10:36:10 +00:00
parent ef5247b5b1
commit fbf5af444b
3 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/video_coding/main/source/tick_time_wrapper.h"
#ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_WRAPPER_H_
#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_WRAPPER_H_
namespace webrtc {
class FakeTickTime : public TickTimeInterface
{
public:
FakeTickTime(int64_t start_time_ms)
: fake_now_(TickTime::Now()) {
fake_now_ += (MillisecondsToTicks(start_time_ms) - fake_now_.Ticks());
}
virtual TickTime Now() const { return fake_now_; }
virtual int64_t MillisecondTimestamp() const {
return TicksToMilliseconds(Now().Ticks());
}
virtual int64_t MicrosecondTimestamp() const {
return 1000 * TicksToMilliseconds(Now().Ticks());
}
virtual void IncrementDebugClock(int64_t increase_ms) {
fake_now_ += MillisecondsToTicks(increase_ms);
}
private:
TickTime fake_now_;
};
} // namespace
#endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_WRAPPER_H_

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "system_wrappers/interface/tick_util.h"
#ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TICK_TIME_WRAPPER_H_
#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TICK_TIME_WRAPPER_H_
namespace webrtc {
class TickTimeInterface : public TickTime {
public:
// Current time in the tick domain.
virtual TickTime Now() const { return TickTime::Now(); }
// Now in the time domain in ms.
virtual int64_t MillisecondTimestamp() const {
return TickTime::MillisecondTimestamp();
}
// Now in the time domain in us.
virtual int64_t MicrosecondTimestamp() const {
return TickTime::MicrosecondTimestamp();
}
};
} // namespace
#endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TICK_TIME_WRAPPER_H_

View File

@ -64,6 +64,7 @@
'rtt_filter.h',
'session_info.h',
'tick_time.h',
'tick_time_interface.h',
'timestamp_extrapolator.h',
'timestamp_map.h',
'timing.h',