OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/screen_recorder.h" | 5 #include "remoting/host/screen_recorder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "remoting/base/base_mock_objects.h" | 9 #include "remoting/base/base_mock_objects.h" |
10 #include "remoting/host/host_mock_objects.h" | 10 #include "remoting/host/host_mock_objects.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 static const media::VideoFrame::Format kFormat = media::VideoFrame::RGB32; | 66 static const media::VideoFrame::Format kFormat = media::VideoFrame::RGB32; |
67 static const VideoPacketFormat::Encoding kEncoding = | 67 static const VideoPacketFormat::Encoding kEncoding = |
68 VideoPacketFormat::ENCODING_VERBATIM; | 68 VideoPacketFormat::ENCODING_VERBATIM; |
69 | 69 |
70 class ScreenRecorderTest : public testing::Test { | 70 class ScreenRecorderTest : public testing::Test { |
71 public: | 71 public: |
72 ScreenRecorderTest() { | 72 ScreenRecorderTest() { |
73 } | 73 } |
74 | 74 |
75 virtual void SetUp() OVERRIDE { | 75 virtual void SetUp() OVERRIDE { |
76 // Capturer and Encoder are owned by ScreenRecorder. | 76 // VideoFrameCapturer and Encoder are owned by ScreenRecorder. |
77 encoder_ = new MockEncoder(); | 77 encoder_ = new MockEncoder(); |
78 | 78 |
79 session_ = new MockSession(); | 79 session_ = new MockSession(); |
80 EXPECT_CALL(*session_, SetEventHandler(_)); | 80 EXPECT_CALL(*session_, SetEventHandler(_)); |
81 EXPECT_CALL(*session_, Close()) | 81 EXPECT_CALL(*session_, Close()) |
82 .Times(AnyNumber()); | 82 .Times(AnyNumber()); |
83 connection_.reset(new MockConnectionToClient( | 83 connection_.reset(new MockConnectionToClient( |
84 session_, &host_stub_, &event_executor_)); | 84 session_, &host_stub_, &event_executor_)); |
85 connection_->SetEventHandler(&handler_); | 85 connection_->SetEventHandler(&handler_); |
86 | 86 |
(...skipping 13 matching lines...) Expand all Loading... |
100 MessageLoop message_loop_; | 100 MessageLoop message_loop_; |
101 scoped_refptr<ScreenRecorder> record_; | 101 scoped_refptr<ScreenRecorder> record_; |
102 | 102 |
103 MockConnectionToClientEventHandler handler_; | 103 MockConnectionToClientEventHandler handler_; |
104 MockHostStub host_stub_; | 104 MockHostStub host_stub_; |
105 MockEventExecutor event_executor_; | 105 MockEventExecutor event_executor_; |
106 MockSession* session_; // Owned by |connection_|. | 106 MockSession* session_; // Owned by |connection_|. |
107 scoped_ptr<MockConnectionToClient> connection_; | 107 scoped_ptr<MockConnectionToClient> connection_; |
108 | 108 |
109 // The following mock objects are owned by ScreenRecorder. | 109 // The following mock objects are owned by ScreenRecorder. |
110 MockCapturer capturer_; | 110 MockVideoFrameCapturer capturer_; |
111 MockEncoder* encoder_; | 111 MockEncoder* encoder_; |
112 | 112 |
113 private: | 113 private: |
114 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); | 114 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); |
115 }; | 115 }; |
116 | 116 |
117 // This test mocks capturer, encoder and network layer to simulate one recording | 117 // This test mocks capturer, encoder and network layer to simulate one recording |
118 // cycle. When the first encoded packet is submitted to the network | 118 // cycle. When the first encoded packet is submitted to the network |
119 // ScreenRecorder is instructed to come to a complete stop. We expect the stop | 119 // ScreenRecorder is instructed to come to a complete stop. We expect the stop |
120 // sequence to be executed successfully. | 120 // sequence to be executed successfully. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 message_loop_.Run(); | 169 message_loop_.Run(); |
170 } | 170 } |
171 | 171 |
172 TEST_F(ScreenRecorderTest, StopWithoutStart) { | 172 TEST_F(ScreenRecorderTest, StopWithoutStart) { |
173 EXPECT_CALL(capturer_, Stop()); | 173 EXPECT_CALL(capturer_, Stop()); |
174 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); | 174 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); |
175 message_loop_.Run(); | 175 message_loop_.Run(); |
176 } | 176 } |
177 | 177 |
178 } // namespace remoting | 178 } // namespace remoting |
OLD | NEW |