Re-implement dependency injection of TickTime into VCM and tests

This change basicly re-enables the change of r1220, which was
reverted in r1235 due to Clang issues.

The difference from r1220 is that the TickTimeInterface was
renamed to TickTimeClass, and no longer inherits from TickTime.

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1267 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org
2011-12-21 15:24:01 +00:00
parent 5490c71a1b
commit 7d8c72e2db
47 changed files with 357 additions and 317 deletions

View File

@@ -8,33 +8,40 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#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_
#ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_H_
#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_H_
#include "modules/video_coding/main/source/tick_time_interface.h"
#include <assert.h>
#include <limits>
#include "modules/video_coding/main/source/tick_time_base.h"
namespace webrtc {
class FakeTickTime : public TickTimeInterface {
// Provides a fake implementation of TickTimeBase, intended for offline
// testing. This implementation does not query the system clock, but returns a
// time value set by the user when creating the object, and incremented with
// the method IncrementDebugClock.
class FakeTickTime : public TickTimeBase {
public:
explicit 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_; }
explicit FakeTickTime(int64_t start_time_ms) : fake_now_ms_(start_time_ms) {}
virtual ~FakeTickTime() {}
virtual int64_t MillisecondTimestamp() const {
return TicksToMilliseconds(Now().Ticks());
return fake_now_ms_;
}
virtual int64_t MicrosecondTimestamp() const {
return 1000 * TicksToMilliseconds(Now().Ticks());
return 1000 * fake_now_ms_;
}
virtual void IncrementDebugClock(int64_t increase_ms) {
fake_now_ += MillisecondsToTicks(increase_ms);
assert(increase_ms <= std::numeric_limits<int64_t>::max() - fake_now_ms_);
fake_now_ms_ += increase_ms;
}
private:
TickTime fake_now_;
int64_t fake_now_ms_;
};
} // namespace
#endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_WRAPPER_H_
#endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_H_