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/capture_data.h" |
| 10 #include "remoting/codec/video_encoder.h" |
10 #include "remoting/host/host_mock_objects.h" | 11 #include "remoting/host/host_mock_objects.h" |
11 #include "remoting/proto/video.pb.h" | 12 #include "remoting/proto/video.pb.h" |
12 #include "remoting/protocol/protocol_mock_objects.h" | 13 #include "remoting/protocol/protocol_mock_objects.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 using ::remoting::protocol::MockConnectionToClient; | 17 using ::remoting::protocol::MockConnectionToClient; |
17 using ::remoting::protocol::MockConnectionToClientEventHandler; | 18 using ::remoting::protocol::MockConnectionToClientEventHandler; |
18 using ::remoting::protocol::MockHostStub; | 19 using ::remoting::protocol::MockHostStub; |
19 using ::remoting::protocol::MockSession; | 20 using ::remoting::protocol::MockSession; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 62 } |
62 | 63 |
63 } // namespace | 64 } // namespace |
64 | 65 |
65 static const int kWidth = 640; | 66 static const int kWidth = 640; |
66 static const int kHeight = 480; | 67 static const int kHeight = 480; |
67 static const media::VideoFrame::Format kFormat = media::VideoFrame::RGB32; | 68 static const media::VideoFrame::Format kFormat = media::VideoFrame::RGB32; |
68 static const VideoPacketFormat::Encoding kEncoding = | 69 static const VideoPacketFormat::Encoding kEncoding = |
69 VideoPacketFormat::ENCODING_VERBATIM; | 70 VideoPacketFormat::ENCODING_VERBATIM; |
70 | 71 |
| 72 class MockEncoder : public Encoder { |
| 73 public: |
| 74 MockEncoder(); |
| 75 virtual ~MockEncoder(); |
| 76 |
| 77 MOCK_METHOD3(Encode, void( |
| 78 scoped_refptr<CaptureData> capture_data, |
| 79 bool key_frame, |
| 80 const DataAvailableCallback& data_available_callback)); |
| 81 |
| 82 private: |
| 83 DISALLOW_COPY_AND_ASSIGN(MockEncoder); |
| 84 }; |
| 85 |
| 86 MockEncoder::MockEncoder() {} |
| 87 |
| 88 MockEncoder::~MockEncoder() {} |
| 89 |
71 class ScreenRecorderTest : public testing::Test { | 90 class ScreenRecorderTest : public testing::Test { |
72 public: | 91 public: |
73 ScreenRecorderTest() { | 92 ScreenRecorderTest() { |
74 } | 93 } |
75 | 94 |
76 virtual void SetUp() OVERRIDE { | 95 virtual void SetUp() OVERRIDE { |
77 // VideoFrameCapturer and Encoder are owned by ScreenRecorder. | 96 // VideoFrameCapturer and Encoder are owned by ScreenRecorder. |
78 encoder_ = new MockEncoder(); | 97 encoder_ = new MockEncoder(); |
79 | 98 |
80 session_ = new MockSession(); | 99 session_ = new MockSession(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 message_loop_.Run(); | 193 message_loop_.Run(); |
175 } | 194 } |
176 | 195 |
177 TEST_F(ScreenRecorderTest, StopWithoutStart) { | 196 TEST_F(ScreenRecorderTest, StopWithoutStart) { |
178 EXPECT_CALL(capturer_, Stop()); | 197 EXPECT_CALL(capturer_, Stop()); |
179 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); | 198 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); |
180 message_loop_.Run(); | 199 message_loop_.Run(); |
181 } | 200 } |
182 | 201 |
183 } // namespace remoting | 202 } // namespace remoting |
OLD | NEW |