OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/task.h" | 6 #include "base/task.h" |
7 #include "remoting/base/base_mock_objects.h" | 7 #include "remoting/base/base_mock_objects.h" |
8 #include "remoting/host/host_mock_objects.h" | 8 #include "remoting/host/host_mock_objects.h" |
9 #include "remoting/host/screen_recorder.h" | 9 #include "remoting/host/screen_recorder.h" |
10 #include "remoting/proto/video.pb.h" | 10 #include "remoting/proto/video.pb.h" |
11 #include "remoting/protocol/protocol_mock_objects.h" | 11 #include "remoting/protocol/protocol_mock_objects.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using ::remoting::protocol::MockConnectionToClient; | 15 using ::remoting::protocol::MockConnectionToClient; |
| 16 using ::remoting::protocol::MockConnectionToClientEventHandler; |
| 17 using ::remoting::protocol::MockHostStub; |
| 18 using ::remoting::protocol::MockInputStub; |
16 using ::remoting::protocol::MockVideoStub; | 19 using ::remoting::protocol::MockVideoStub; |
17 | 20 |
18 using ::testing::_; | 21 using ::testing::_; |
19 using ::testing::AtLeast; | 22 using ::testing::AtLeast; |
20 using ::testing::DeleteArg; | 23 using ::testing::DeleteArg; |
21 using ::testing::DoAll; | 24 using ::testing::DoAll; |
22 using ::testing::InSequence; | 25 using ::testing::InSequence; |
23 using ::testing::InvokeWithoutArgs; | 26 using ::testing::InvokeWithoutArgs; |
24 using ::testing::NotNull; | 27 using ::testing::NotNull; |
25 using ::testing::Return; | 28 using ::testing::Return; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 VideoPacketFormat::ENCODING_VERBATIM; | 73 VideoPacketFormat::ENCODING_VERBATIM; |
71 | 74 |
72 class ScreenRecorderTest : public testing::Test { | 75 class ScreenRecorderTest : public testing::Test { |
73 public: | 76 public: |
74 ScreenRecorderTest() { | 77 ScreenRecorderTest() { |
75 } | 78 } |
76 | 79 |
77 virtual void SetUp() { | 80 virtual void SetUp() { |
78 // Capturer and Encoder are owned by ScreenRecorder. | 81 // Capturer and Encoder are owned by ScreenRecorder. |
79 encoder_ = new MockEncoder(); | 82 encoder_ = new MockEncoder(); |
80 connection_ = new MockConnectionToClient(); | 83 |
| 84 connection_ = new MockConnectionToClient(&message_loop_, &handler_, |
| 85 &host_stub_, &input_stub_); |
| 86 |
81 record_ = new ScreenRecorder( | 87 record_ = new ScreenRecorder( |
82 &message_loop_, &message_loop_, &message_loop_, | 88 &message_loop_, &message_loop_, &message_loop_, |
83 &capturer_, encoder_); | 89 &capturer_, encoder_); |
84 } | 90 } |
85 | 91 |
86 protected: | 92 protected: |
87 scoped_refptr<ScreenRecorder> record_; | 93 scoped_refptr<ScreenRecorder> record_; |
| 94 |
| 95 MockConnectionToClientEventHandler handler_; |
| 96 MockHostStub host_stub_; |
| 97 MockInputStub input_stub_; |
88 scoped_refptr<MockConnectionToClient> connection_; | 98 scoped_refptr<MockConnectionToClient> connection_; |
89 | 99 |
90 // The following mock objects are owned by ScreenRecorder. | 100 // The following mock objects are owned by ScreenRecorder. |
91 MockCapturer capturer_; | 101 MockCapturer capturer_; |
92 MockEncoder* encoder_; | 102 MockEncoder* encoder_; |
93 MessageLoop message_loop_; | 103 MessageLoop message_loop_; |
94 private: | 104 private: |
95 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); | 105 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); |
96 }; | 106 }; |
97 | 107 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 record_->Start(); | 205 record_->Start(); |
196 message_loop_.Run(); | 206 message_loop_.Run(); |
197 } | 207 } |
198 | 208 |
199 TEST_F(ScreenRecorderTest, StopWithoutStart) { | 209 TEST_F(ScreenRecorderTest, StopWithoutStart) { |
200 record_->Stop(NewRunnableFunction(&QuitMessageLoop, &message_loop_)); | 210 record_->Stop(NewRunnableFunction(&QuitMessageLoop, &message_loop_)); |
201 message_loop_.Run(); | 211 message_loop_.Run(); |
202 } | 212 } |
203 | 213 |
204 } // namespace remoting | 214 } // namespace remoting |
OLD | NEW |