OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/task.h" | 9 #include "base/task.h" |
10 #include "remoting/base/base_mock_objects.h" | 10 #include "remoting/base/base_mock_objects.h" |
11 #include "remoting/host/host_mock_objects.h" | 11 #include "remoting/host/host_mock_objects.h" |
12 #include "remoting/proto/video.pb.h" | 12 #include "remoting/proto/video.pb.h" |
13 #include "remoting/protocol/protocol_mock_objects.h" | 13 #include "remoting/protocol/protocol_mock_objects.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 using ::remoting::protocol::MockConnectionToClient; | 17 using ::remoting::protocol::MockConnectionToClient; |
18 using ::remoting::protocol::MockConnectionToClientEventHandler; | 18 using ::remoting::protocol::MockConnectionToClientEventHandler; |
19 using ::remoting::protocol::MockHostStub; | 19 using ::remoting::protocol::MockHostStub; |
| 20 using ::remoting::protocol::MockSession; |
20 using ::remoting::protocol::MockVideoStub; | 21 using ::remoting::protocol::MockVideoStub; |
21 | 22 |
22 using ::testing::_; | 23 using ::testing::_; |
23 using ::testing::AtLeast; | 24 using ::testing::AtLeast; |
24 using ::testing::DeleteArg; | 25 using ::testing::DeleteArg; |
25 using ::testing::DoAll; | 26 using ::testing::DoAll; |
26 using ::testing::InSequence; | 27 using ::testing::InSequence; |
27 using ::testing::InvokeWithoutArgs; | 28 using ::testing::InvokeWithoutArgs; |
28 using ::testing::NotNull; | 29 using ::testing::NotNull; |
29 using ::testing::Return; | 30 using ::testing::Return; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 71 |
71 class ScreenRecorderTest : public testing::Test { | 72 class ScreenRecorderTest : public testing::Test { |
72 public: | 73 public: |
73 ScreenRecorderTest() { | 74 ScreenRecorderTest() { |
74 } | 75 } |
75 | 76 |
76 virtual void SetUp() { | 77 virtual void SetUp() { |
77 // Capturer and Encoder are owned by ScreenRecorder. | 78 // Capturer and Encoder are owned by ScreenRecorder. |
78 encoder_ = new MockEncoder(); | 79 encoder_ = new MockEncoder(); |
79 | 80 |
| 81 session_ = new MockSession(); |
| 82 EXPECT_CALL(*session_, SetStateChangeCallback(_)); |
80 connection_ = new MockConnectionToClient( | 83 connection_ = new MockConnectionToClient( |
81 &handler_, &host_stub_, &event_executor_); | 84 session_, &host_stub_, &event_executor_); |
| 85 connection_->SetEventHandler(&handler_); |
82 | 86 |
83 record_ = new ScreenRecorder( | 87 record_ = new ScreenRecorder( |
84 &message_loop_, &message_loop_, | 88 &message_loop_, &message_loop_, |
85 base::MessageLoopProxy::current(), | 89 base::MessageLoopProxy::current(), |
86 &capturer_, encoder_); | 90 &capturer_, encoder_); |
87 } | 91 } |
88 | 92 |
89 protected: | 93 protected: |
90 scoped_refptr<ScreenRecorder> record_; | 94 scoped_refptr<ScreenRecorder> record_; |
91 | 95 |
92 MockConnectionToClientEventHandler handler_; | 96 MockConnectionToClientEventHandler handler_; |
93 MockHostStub host_stub_; | 97 MockHostStub host_stub_; |
94 MockEventExecutor event_executor_; | 98 MockEventExecutor event_executor_; |
| 99 MockSession* session_; // Owned by |connection_|. |
95 scoped_refptr<MockConnectionToClient> connection_; | 100 scoped_refptr<MockConnectionToClient> connection_; |
96 | 101 |
97 // The following mock objects are owned by ScreenRecorder. | 102 // The following mock objects are owned by ScreenRecorder. |
98 MockCapturer capturer_; | 103 MockCapturer capturer_; |
99 MockEncoder* encoder_; | 104 MockEncoder* encoder_; |
100 MessageLoop message_loop_; | 105 MessageLoop message_loop_; |
101 private: | 106 private: |
102 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); | 107 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); |
103 }; | 108 }; |
104 | 109 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 record_->Start(); | 155 record_->Start(); |
151 message_loop_.Run(); | 156 message_loop_.Run(); |
152 } | 157 } |
153 | 158 |
154 TEST_F(ScreenRecorderTest, StopWithoutStart) { | 159 TEST_F(ScreenRecorderTest, StopWithoutStart) { |
155 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); | 160 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); |
156 message_loop_.Run(); | 161 message_loop_.Run(); |
157 } | 162 } |
158 | 163 |
159 } // namespace remoting | 164 } // namespace remoting |
OLD | NEW |