| 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/host/mock_objects.h" | 7 #include "remoting/host/mock_objects.h" |
| 8 #include "remoting/host/session_manager.h" | 8 #include "remoting/host/session_manager.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 Init(); | 51 Init(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 ACTION_P2(RunCallback, rects, data) { | 54 ACTION_P2(RunCallback, rects, data) { |
| 55 RectVector& dirty_rects = data->mutable_dirty_rects(); | 55 RectVector& dirty_rects = data->mutable_dirty_rects(); |
| 56 dirty_rects.insert(dirty_rects.end(), rects.begin(), rects.end()); | 56 dirty_rects.insert(dirty_rects.end(), rects.begin(), rects.end()); |
| 57 arg0->Run(data); | 57 arg0->Run(data); |
| 58 delete arg0; | 58 delete arg0; |
| 59 } | 59 } |
| 60 | 60 |
| 61 ACTION_P3(FinishDecode, rects, buffer, header) { | 61 ACTION_P(FinishEncode, msg) { |
| 62 gfx::Rect& rect = (*rects)[0]; | |
| 63 Encoder::EncodingState state = (Encoder::EncodingStarting | | 62 Encoder::EncodingState state = (Encoder::EncodingStarting | |
| 64 Encoder::EncodingInProgress | | 63 Encoder::EncodingInProgress | |
| 65 Encoder::EncodingEnded); | 64 Encoder::EncodingEnded); |
| 66 header->set_x(rect.x()); | 65 arg2->Run(msg, state); |
| 67 header->set_y(rect.y()); | |
| 68 header->set_width(rect.width()); | |
| 69 header->set_height(rect.height()); | |
| 70 header->set_encoding(kEncoding); | |
| 71 header->set_pixel_format(kFormat); | |
| 72 arg2->Run(header, *buffer, state); | |
| 73 } | 66 } |
| 74 | 67 |
| 75 ACTION_P(AssignCaptureData, data) { | 68 ACTION_P(AssignCaptureData, data) { |
| 76 arg0[0] = data[0]; | 69 arg0[0] = data[0]; |
| 77 arg0[1] = data[1]; | 70 arg0[1] = data[1]; |
| 78 arg0[2] = data[2]; | 71 arg0[2] = data[2]; |
| 79 } | 72 } |
| 80 | 73 |
| 81 ACTION_P(AssignDirtyRect, rects) { | 74 ACTION_P(AssignDirtyRect, rects) { |
| 82 *arg0 = *rects; | 75 *arg0 = *rects; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 104 EXPECT_CALL(*capturer_, height()).WillRepeatedly(Return(kHeight)); | 97 EXPECT_CALL(*capturer_, height()).WillRepeatedly(Return(kHeight)); |
| 105 EXPECT_CALL(*client_, SendInitClientMessage(kWidth, kHeight)); | 98 EXPECT_CALL(*client_, SendInitClientMessage(kWidth, kHeight)); |
| 106 record_->AddClient(client_); | 99 record_->AddClient(client_); |
| 107 | 100 |
| 108 // First the capturer is called. | 101 // First the capturer is called. |
| 109 EXPECT_CALL(*capturer_, InvalidateFullScreen()); | 102 EXPECT_CALL(*capturer_, InvalidateFullScreen()); |
| 110 EXPECT_CALL(*capturer_, CaptureInvalidRects(NotNull())) | 103 EXPECT_CALL(*capturer_, CaptureInvalidRects(NotNull())) |
| 111 .WillOnce(RunCallback(update_rects, data)); | 104 .WillOnce(RunCallback(update_rects, data)); |
| 112 | 105 |
| 113 // Expect the encoder be called. | 106 // Expect the encoder be called. |
| 114 scoped_refptr<media::DataBuffer> buffer = new media::DataBuffer(0); | 107 HostMessage* msg = new HostMessage(); |
| 115 UpdateStreamPacketHeader *header = new UpdateStreamPacketHeader; | |
| 116 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) | 108 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) |
| 117 .WillOnce(FinishDecode(&update_rects, &buffer, header)); | 109 .WillOnce(FinishEncode(msg)); |
| 118 | 110 |
| 119 // Expect the client be notified. | 111 // Expect the client be notified. |
| 120 EXPECT_CALL(*client_, SendBeginUpdateStreamMessage()); | 112 EXPECT_CALL(*client_, SendBeginUpdateStreamMessage()); |
| 121 | 113 EXPECT_CALL(*client_, SendUpdateStreamPacketMessage(_)); |
| 122 EXPECT_CALL(*client_, SendUpdateStreamPacketMessage(header ,buffer)); | |
| 123 EXPECT_CALL(*client_, SendEndUpdateStreamMessage()); | 114 EXPECT_CALL(*client_, SendEndUpdateStreamMessage()); |
| 124 EXPECT_CALL(*client_, GetPendingUpdateStreamMessages()) | 115 EXPECT_CALL(*client_, GetPendingUpdateStreamMessages()) |
| 125 .Times(AtLeast(0)) | 116 .Times(AtLeast(0)) |
| 126 .WillRepeatedly(Return(0)); | 117 .WillRepeatedly(Return(0)); |
| 127 | 118 |
| 128 | 119 |
| 129 // Start the recording. | 120 // Start the recording. |
| 130 record_->Start(); | 121 record_->Start(); |
| 131 | 122 |
| 132 // Make sure all tasks are completed. | 123 // Make sure all tasks are completed. |
| 133 message_loop_.RunAllPending(); | 124 message_loop_.RunAllPending(); |
| 134 } | 125 } |
| 135 | 126 |
| 136 // TODO(hclam): Add test for double buffering. | 127 // TODO(hclam): Add test for double buffering. |
| 137 // TODO(hclam): Add test for multiple captures. | 128 // TODO(hclam): Add test for multiple captures. |
| 138 // TODO(hclam): Add test for interruption. | 129 // TODO(hclam): Add test for interruption. |
| 139 | 130 |
| 140 } // namespace remoting | 131 } // namespace remoting |
| OLD | NEW |