diff options
author | mflodman@webrtc.org <mflodman@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-06-26 11:23:01 +0000 |
---|---|---|
committer | mflodman@webrtc.org <mflodman@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-06-26 11:23:01 +0000 |
commit | f8f91d6b9b69eaf2c73a63419a502034cdf371c1 (patch) | |
tree | da54894c87b7bb22b6450361835b667856ec927e /video_engine/overuse_frame_detector_unittest.cc | |
parent | 0291c803da147cf113e829562f281479be8f2c11 (diff) | |
download | webrtc-f8f91d6b9b69eaf2c73a63419a502034cdf371c1.tar.gz |
Adding a first simple version of overuse detection, but not hooked up.
BUG=
R=asapersson@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/1717004
git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@4268 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'video_engine/overuse_frame_detector_unittest.cc')
-rw-r--r-- | video_engine/overuse_frame_detector_unittest.cc | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/video_engine/overuse_frame_detector_unittest.cc b/video_engine/overuse_frame_detector_unittest.cc new file mode 100644 index 00000000..383f80f4 --- /dev/null +++ b/video_engine/overuse_frame_detector_unittest.cc @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2013 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 "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +#include "webrtc/system_wrappers/interface/clock.h" +#include "webrtc/system_wrappers/interface/scoped_ptr.h" +#include "webrtc/video_engine/overuse_frame_detector.h" + +using ::testing::_; +using ::testing::AnyNumber; +using ::testing::Return; + +namespace webrtc { + +const int kProcessIntervalMs = 2000; + +class MockOveruseObserver : public OveruseObserver { + public: + MockOveruseObserver() {} + virtual ~MockOveruseObserver() {} + + MOCK_METHOD0(OveruseDetected, void()); +}; + +class OveruseFrameDetectorTest : public ::testing::Test { + protected: + virtual void SetUp() { + clock_.reset(new SimulatedClock(1234)); + observer_.reset(new MockOveruseObserver()); + overuse_detector_.reset(new OveruseFrameDetector(clock_.get(), + observer_.get())); + } + scoped_ptr<SimulatedClock> clock_; + scoped_ptr<MockOveruseObserver> observer_; + scoped_ptr<OveruseFrameDetector> overuse_detector_; +}; + +TEST_F(OveruseFrameDetectorTest, TriggerOveruse) { + EXPECT_EQ(overuse_detector_->TimeUntilNextProcess(), kProcessIntervalMs); + overuse_detector_->CapturedFrame(); + overuse_detector_->EncodedFrame(); + clock_->AdvanceTimeMilliseconds(kProcessIntervalMs); + EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(0); + overuse_detector_->Process(); + + overuse_detector_->CapturedFrame(); + clock_->AdvanceTimeMilliseconds(kProcessIntervalMs); + EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(1); + overuse_detector_->Process(); + + clock_->AdvanceTimeMilliseconds(5000); + overuse_detector_->CapturedFrame(); + overuse_detector_->EncodedFrame(); + EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(0); + overuse_detector_->Process(); +} +} // namespace webrtc |