| 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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 ACTION(FinishEncode) { | 43 ACTION(FinishEncode) { |
| 44 scoped_ptr<VideoPacket> packet(new VideoPacket()); | 44 scoped_ptr<VideoPacket> packet(new VideoPacket()); |
| 45 packet->set_flags(VideoPacket::LAST_PACKET | VideoPacket::LAST_PARTITION); | 45 packet->set_flags(VideoPacket::LAST_PACKET | VideoPacket::LAST_PARTITION); |
| 46 arg2->Run(packet.release()); | 46 arg2->Run(packet.release()); |
| 47 delete arg2; | 47 delete arg2; |
| 48 } | 48 } |
| 49 | 49 |
| 50 ACTION(FinishSend) { | 50 ACTION(FinishSend) { |
| 51 arg1->Run(); | 51 arg1.Run(); |
| 52 delete arg1; | |
| 53 } | 52 } |
| 54 | 53 |
| 55 // Helper method to quit the main message loop. | 54 // Helper method to quit the main message loop. |
| 56 void QuitMessageLoop(MessageLoop* message_loop) { | 55 void QuitMessageLoop(MessageLoop* message_loop) { |
| 57 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 56 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| 58 } | 57 } |
| 59 | 58 |
| 60 ACTION_P2(StopScreenRecorder, recorder, task) { | 59 ACTION_P2(StopScreenRecorder, recorder, task) { |
| 61 recorder->Stop(task); | 60 recorder->Stop(task); |
| 62 } | 61 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) | 123 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) |
| 125 .WillOnce(FinishEncode()); | 124 .WillOnce(FinishEncode()); |
| 126 | 125 |
| 127 MockVideoStub video_stub; | 126 MockVideoStub video_stub; |
| 128 EXPECT_CALL(*connection_, video_stub()) | 127 EXPECT_CALL(*connection_, video_stub()) |
| 129 .WillRepeatedly(Return(&video_stub)); | 128 .WillRepeatedly(Return(&video_stub)); |
| 130 | 129 |
| 131 // Expect the client be notified. | 130 // Expect the client be notified. |
| 132 EXPECT_CALL(video_stub, ProcessVideoPacket(_, _)) | 131 EXPECT_CALL(video_stub, ProcessVideoPacket(_, _)) |
| 133 .Times(1) | 132 .Times(1) |
| 134 .WillOnce(DoAll(DeleteArg<0>(), DeleteArg<1>())); | 133 .WillOnce(DeleteArg<0>()); |
| 135 EXPECT_CALL(video_stub, GetPendingPackets()) | 134 EXPECT_CALL(video_stub, GetPendingPackets()) |
| 136 .Times(AtLeast(0)) | 135 .Times(AtLeast(0)) |
| 137 .WillRepeatedly(Return(0)); | 136 .WillRepeatedly(Return(0)); |
| 138 | 137 |
| 139 // Set the recording rate to very low to avoid capture twice. | 138 // Set the recording rate to very low to avoid capture twice. |
| 140 record_->SetMaxRate(0.01); | 139 record_->SetMaxRate(0.01); |
| 141 | 140 |
| 142 // Add the mock client connection to the session. | 141 // Add the mock client connection to the session. |
| 143 record_->AddConnection(connection_); | 142 record_->AddConnection(connection_); |
| 144 | 143 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 record_->Start(); | 196 record_->Start(); |
| 198 message_loop_.Run(); | 197 message_loop_.Run(); |
| 199 } | 198 } |
| 200 | 199 |
| 201 TEST_F(ScreenRecorderTest, StopWithoutStart) { | 200 TEST_F(ScreenRecorderTest, StopWithoutStart) { |
| 202 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); | 201 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); |
| 203 message_loop_.Run(); | 202 message_loop_.Run(); |
| 204 } | 203 } |
| 205 | 204 |
| 206 } // namespace remoting | 205 } // namespace remoting |
| OLD | NEW |