| 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_, SetStateChangeCallback(_)); | 80 EXPECT_CALL(*session_, SetStateChangeCallback(_)); |
| 81 EXPECT_CALL(*session_, SetRouteChangeCallback(_)); | 81 EXPECT_CALL(*session_, SetRouteChangeCallback(_)); |
| 82 EXPECT_CALL(*session_, Close()) | 82 EXPECT_CALL(*session_, Close()) |
| 83 .Times(AnyNumber()); | 83 .Times(AnyNumber()); |
| 84 connection_.reset(new MockConnectionToClient( | 84 connection_.reset(new MockConnectionToClient( |
| 85 session_, &host_stub_, &event_executor_)); | 85 session_, &host_stub_, &event_executor_)); |
| 86 connection_->SetEventHandler(&handler_); | 86 connection_->SetEventHandler(&handler_); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 101 MessageLoop message_loop_; | 101 MessageLoop message_loop_; |
| 102 scoped_refptr<ScreenRecorder> record_; | 102 scoped_refptr<ScreenRecorder> record_; |
| 103 | 103 |
| 104 MockConnectionToClientEventHandler handler_; | 104 MockConnectionToClientEventHandler handler_; |
| 105 MockHostStub host_stub_; | 105 MockHostStub host_stub_; |
| 106 MockEventExecutor event_executor_; | 106 MockEventExecutor event_executor_; |
| 107 MockSession* session_; // Owned by |connection_|. | 107 MockSession* session_; // Owned by |connection_|. |
| 108 scoped_ptr<MockConnectionToClient> connection_; | 108 scoped_ptr<MockConnectionToClient> connection_; |
| 109 | 109 |
| 110 // The following mock objects are owned by ScreenRecorder. | 110 // The following mock objects are owned by ScreenRecorder. |
| 111 MockCapturer capturer_; | 111 MockVideoFrameCapturer capturer_; |
| 112 MockEncoder* encoder_; | 112 MockEncoder* encoder_; |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); | 115 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 // This test mocks capturer, encoder and network layer to simulate one recording | 118 // This test mocks capturer, encoder and network layer to simulate one recording |
| 119 // cycle. When the first encoded packet is submitted to the network | 119 // cycle. When the first encoded packet is submitted to the network |
| 120 // ScreenRecorder is instructed to come to a complete stop. We expect the stop | 120 // ScreenRecorder is instructed to come to a complete stop. We expect the stop |
| 121 // sequence to be executed successfully. | 121 // sequence to be executed successfully. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 message_loop_.Run(); | 170 message_loop_.Run(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 TEST_F(ScreenRecorderTest, StopWithoutStart) { | 173 TEST_F(ScreenRecorderTest, StopWithoutStart) { |
| 174 EXPECT_CALL(capturer_, Stop()); | 174 EXPECT_CALL(capturer_, Stop()); |
| 175 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); | 175 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); |
| 176 message_loop_.Run(); | 176 message_loop_.Run(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace remoting | 179 } // namespace remoting |
| OLD | NEW |