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::Return; | 29 using ::testing::Return; |
29 using ::testing::SaveArg; | 30 using ::testing::SaveArg; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 68 |
68 class ScreenRecorderTest : public testing::Test { | 69 class ScreenRecorderTest : public testing::Test { |
69 public: | 70 public: |
70 ScreenRecorderTest() { | 71 ScreenRecorderTest() { |
71 } | 72 } |
72 | 73 |
73 virtual void SetUp() { | 74 virtual void SetUp() { |
74 // Capturer and Encoder are owned by ScreenRecorder. | 75 // Capturer and Encoder are owned by ScreenRecorder. |
75 encoder_ = new MockEncoder(); | 76 encoder_ = new MockEncoder(); |
76 | 77 |
| 78 session_ = new MockSession(); |
| 79 EXPECT_CALL(*session_, SetStateChangeCallback(_)); |
77 connection_ = new MockConnectionToClient( | 80 connection_ = new MockConnectionToClient( |
78 &handler_, &host_stub_, &event_executor_); | 81 session_, &host_stub_, &event_executor_); |
| 82 connection_->SetEventHandler(&handler_); |
79 | 83 |
80 record_ = new ScreenRecorder( | 84 record_ = new ScreenRecorder( |
81 &message_loop_, &message_loop_, | 85 &message_loop_, &message_loop_, |
82 base::MessageLoopProxy::current(), | 86 base::MessageLoopProxy::current(), |
83 &capturer_, encoder_); | 87 &capturer_, encoder_); |
84 } | 88 } |
85 | 89 |
86 protected: | 90 protected: |
87 scoped_refptr<ScreenRecorder> record_; | 91 scoped_refptr<ScreenRecorder> record_; |
88 | 92 |
89 MockConnectionToClientEventHandler handler_; | 93 MockConnectionToClientEventHandler handler_; |
90 MockHostStub host_stub_; | 94 MockHostStub host_stub_; |
91 MockEventExecutor event_executor_; | 95 MockEventExecutor event_executor_; |
| 96 MockSession* session_; // Owned by |connection_|. |
92 scoped_refptr<MockConnectionToClient> connection_; | 97 scoped_refptr<MockConnectionToClient> connection_; |
93 | 98 |
94 // The following mock objects are owned by ScreenRecorder. | 99 // The following mock objects are owned by ScreenRecorder. |
95 MockCapturer capturer_; | 100 MockCapturer capturer_; |
96 MockEncoder* encoder_; | 101 MockEncoder* encoder_; |
97 MessageLoop message_loop_; | 102 MessageLoop message_loop_; |
98 private: | 103 private: |
99 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); | 104 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); |
100 }; | 105 }; |
101 | 106 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 record_->Start(); | 152 record_->Start(); |
148 message_loop_.Run(); | 153 message_loop_.Run(); |
149 } | 154 } |
150 | 155 |
151 TEST_F(ScreenRecorderTest, StopWithoutStart) { | 156 TEST_F(ScreenRecorderTest, StopWithoutStart) { |
152 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); | 157 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); |
153 message_loop_.Run(); | 158 message_loop_.Run(); |
154 } | 159 } |
155 | 160 |
156 } // namespace remoting | 161 } // namespace remoting |
OLD | NEW |