summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-18 23:37:49 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-18 23:37:49 +0000
commite786cd109052f1a14d2108bebb7eeff87eb07f60 (patch)
tree08fd63f48a6a7b1a74b03ebfc8caa02a11f6216a /remoting
parent5651d6e2a0ae969603428b9facf007d59214c4f0 (diff)
downloadchromium_src-e786cd109052f1a14d2108bebb7eeff87eb07f60.zip
chromium_src-e786cd109052f1a14d2108bebb7eeff87eb07f60.tar.gz
chromium_src-e786cd109052f1a14d2108bebb7eeff87eb07f60.tar.bz2
Mocked VideoFrameCapturer should use the VideoFrameCapturer::Delegate pointer.
BUG=170626 Review URL: https://chromiumcodereview.appspot.com/12027002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177799 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/video_scheduler_unittest.cc86
1 files changed, 57 insertions, 29 deletions
diff --git a/remoting/host/video_scheduler_unittest.cc b/remoting/host/video_scheduler_unittest.cc
index 1126233..04e1b0a 100644
--- a/remoting/host/video_scheduler_unittest.cc
+++ b/remoting/host/video_scheduler_unittest.cc
@@ -70,31 +70,18 @@ MockVideoEncoder::~MockVideoEncoder() {}
class VideoSchedulerTest : public testing::Test {
public:
- VideoSchedulerTest() {
- }
+ VideoSchedulerTest();
- virtual void SetUp() OVERRIDE {
- task_runner_ = new AutoThreadTaskRunner(
- message_loop_.message_loop_proxy(), run_loop_.QuitClosure());
-
- encoder_ = new MockVideoEncoder();
- }
-
- void StartVideoScheduler(scoped_ptr<VideoFrameCapturer> capturer) {
- scheduler_ = VideoScheduler::Create(
- task_runner_, // Capture
- task_runner_, // Encode
- task_runner_, // Network
- capturer.Pass(),
- scoped_ptr<VideoEncoder>(encoder_),
- &client_stub_,
- &video_stub_);
- }
-
- void GenerateOnCaptureCompleted();
+ virtual void SetUp() OVERRIDE;
+ void StartVideoScheduler(scoped_ptr<VideoFrameCapturer> capturer);
void StopVideoScheduler();
+ // VideoFrameCapturer mocks.
+ void OnCapturerStart(VideoFrameCapturer::Delegate* delegate);
+ void OnCapturerStop();
+ void OnCaptureFrame();
+
protected:
MessageLoop message_loop_;
base::RunLoop run_loop_;
@@ -109,15 +96,35 @@ class VideoSchedulerTest : public testing::Test {
scoped_refptr<CaptureData> data_;
+ // Points to the delegate passed to VideoFrameCapturer::Start().
+ VideoFrameCapturer::Delegate* capturer_delegate_;
+
private:
DISALLOW_COPY_AND_ASSIGN(VideoSchedulerTest);
};
-void VideoSchedulerTest::GenerateOnCaptureCompleted() {
- SkRegion update_region(SkIRect::MakeXYWH(0, 0, 10, 10));
- data_->mutable_dirty_region().op(update_region, SkRegion::kUnion_Op);
+VideoSchedulerTest::VideoSchedulerTest()
+ : encoder_(NULL),
+ capturer_delegate_(NULL) {
+}
+
+void VideoSchedulerTest::SetUp() {
+ task_runner_ = new AutoThreadTaskRunner(
+ message_loop_.message_loop_proxy(), run_loop_.QuitClosure());
+
+ encoder_ = new MockVideoEncoder();
+}
- scheduler_->OnCaptureCompleted(data_);
+void VideoSchedulerTest::StartVideoScheduler(
+ scoped_ptr<VideoFrameCapturer> capturer) {
+ scheduler_ = VideoScheduler::Create(
+ task_runner_, // Capture
+ task_runner_, // Encode
+ task_runner_, // Network
+ capturer.Pass(),
+ scoped_ptr<VideoEncoder>(encoder_),
+ &client_stub_,
+ &video_stub_);
}
void VideoSchedulerTest::StopVideoScheduler() {
@@ -125,13 +132,34 @@ void VideoSchedulerTest::StopVideoScheduler() {
scheduler_ = NULL;
}
+void VideoSchedulerTest::OnCapturerStart(
+ VideoFrameCapturer::Delegate* delegate) {
+ EXPECT_FALSE(capturer_delegate_);
+ EXPECT_TRUE(delegate);
+
+ capturer_delegate_ = delegate;
+}
+
+void VideoSchedulerTest::OnCapturerStop() {
+ capturer_delegate_ = NULL;
+}
+
+void VideoSchedulerTest::OnCaptureFrame() {
+ SkRegion update_region(SkIRect::MakeXYWH(0, 0, 10, 10));
+ data_->mutable_dirty_region().op(update_region, SkRegion::kUnion_Op);
+
+ capturer_delegate_->OnCaptureCompleted(data_);
+}
+
// This test mocks capturer, encoder and network layer to simulate one capture
// cycle. When the first encoded packet is submitted to the network
// VideoScheduler is instructed to come to a complete stop. We expect the stop
// sequence to be executed successfully.
TEST_F(VideoSchedulerTest, StartAndStop) {
scoped_ptr<MockVideoFrameCapturer> capturer_(new MockVideoFrameCapturer());
- Expectation capturer_start = EXPECT_CALL(*capturer_, Start(_));
+ Expectation capturer_start =
+ EXPECT_CALL(*capturer_, Start(_))
+ .WillOnce(Invoke(this, &VideoSchedulerTest::OnCapturerStart));
data_ = new CaptureData(NULL, kWidth * CaptureData::kBytesPerPixel,
SkISize::Make(kWidth, kHeight));
@@ -139,8 +167,7 @@ TEST_F(VideoSchedulerTest, StartAndStop) {
// First the capturer is called.
Expectation capturer_capture = EXPECT_CALL(*capturer_, CaptureFrame())
.After(capturer_start)
- .WillRepeatedly(InvokeWithoutArgs(
- this, &VideoSchedulerTest::GenerateOnCaptureCompleted));
+ .WillRepeatedly(Invoke(this, &VideoSchedulerTest::OnCaptureFrame));
// Expect the encoder be called.
EXPECT_CALL(*encoder_, Encode(data_, false, _))
@@ -159,7 +186,8 @@ TEST_F(VideoSchedulerTest, StartAndStop) {
.RetiresOnSaturation();
EXPECT_CALL(*capturer_, Stop())
- .After(capturer_capture);
+ .After(capturer_capture)
+ .WillOnce(Invoke(this, &VideoSchedulerTest::OnCapturerStop));
// Start video frame capture.
StartVideoScheduler(capturer_.PassAs<VideoFrameCapturer>());