| 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/base/mock_objects.h" | 7 #include "remoting/base/mock_objects.h" |
| 8 #include "remoting/host/mock_objects.h" | 8 #include "remoting/host/mock_objects.h" |
| 9 #include "remoting/host/session_manager.h" | 9 #include "remoting/host/session_manager.h" |
| 10 #include "remoting/proto/video.pb.h" |
| 10 #include "remoting/protocol/mock_objects.h" | 11 #include "remoting/protocol/mock_objects.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 using ::remoting::protocol::MockConnectionToClient; | 15 using ::remoting::protocol::MockConnectionToClient; |
| 15 | 16 |
| 16 using ::testing::_; | 17 using ::testing::_; |
| 17 using ::testing::AtLeast; | 18 using ::testing::AtLeast; |
| 18 using ::testing::NotNull; | 19 using ::testing::NotNull; |
| 19 using ::testing::Return; | 20 using ::testing::Return; |
| 20 | 21 |
| 21 namespace remoting { | 22 namespace remoting { |
| 22 | 23 |
| 23 static const int kWidth = 640; | 24 static const int kWidth = 640; |
| 24 static const int kHeight = 480; | 25 static const int kHeight = 480; |
| 25 static const PixelFormat kFormat = PIXEL_FORMAT_RGB32; | 26 static const media::VideoFrame::Format kFormat = media::VideoFrame::RGB32; |
| 26 static const VideoPacketFormat::Encoding kEncoding = | 27 static const VideoPacketFormat::Encoding kEncoding = |
| 27 VideoPacketFormat::ENCODING_VERBATIM; | 28 VideoPacketFormat::ENCODING_VERBATIM; |
| 28 | 29 |
| 29 class SessionManagerTest : public testing::Test { | 30 class SessionManagerTest : public testing::Test { |
| 30 public: | 31 public: |
| 31 SessionManagerTest() { | 32 SessionManagerTest() { |
| 32 } | 33 } |
| 33 | 34 |
| 34 protected: | 35 protected: |
| 35 void Init() { | 36 void Init() { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 planes.strides[i] = kWidth * 4; | 85 planes.strides[i] = kWidth * 4; |
| 85 } | 86 } |
| 86 scoped_refptr<CaptureData> data(new CaptureData(planes, kWidth, | 87 scoped_refptr<CaptureData> data(new CaptureData(planes, kWidth, |
| 87 kHeight, kFormat)); | 88 kHeight, kFormat)); |
| 88 // Set the recording rate to very low to avoid capture twice. | 89 // Set the recording rate to very low to avoid capture twice. |
| 89 record_->SetMaxRate(0.01); | 90 record_->SetMaxRate(0.01); |
| 90 | 91 |
| 91 // Add the mock client connection to the session. | 92 // Add the mock client connection to the session. |
| 92 EXPECT_CALL(*capturer_, width()).WillRepeatedly(Return(kWidth)); | 93 EXPECT_CALL(*capturer_, width()).WillRepeatedly(Return(kWidth)); |
| 93 EXPECT_CALL(*capturer_, height()).WillRepeatedly(Return(kHeight)); | 94 EXPECT_CALL(*capturer_, height()).WillRepeatedly(Return(kHeight)); |
| 94 EXPECT_CALL(*connection_, SendInitClientMessage(kWidth, kHeight)); | |
| 95 record_->AddConnection(connection_); | 95 record_->AddConnection(connection_); |
| 96 | 96 |
| 97 // First the capturer is called. | 97 // First the capturer is called. |
| 98 EXPECT_CALL(*capturer_, CaptureInvalidRects(NotNull())) | 98 EXPECT_CALL(*capturer_, CaptureInvalidRects(NotNull())) |
| 99 .WillOnce(RunCallback(update_rects, data)); | 99 .WillOnce(RunCallback(update_rects, data)); |
| 100 | 100 |
| 101 // Expect the encoder be called. | 101 // Expect the encoder be called. |
| 102 VideoPacket* packet = new VideoPacket(); | 102 VideoPacket* packet = new VideoPacket(); |
| 103 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) | 103 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) |
| 104 .WillOnce(FinishEncode(packet)); | 104 .WillOnce(FinishEncode(packet)); |
| 105 | 105 |
| 106 // Expect the client be notified. | 106 // Expect the client be notified. |
| 107 EXPECT_CALL(*connection_, SendVideoPacket(_)); | 107 EXPECT_CALL(*connection_, SendVideoPacket(_)); |
| 108 EXPECT_CALL(*connection_, GetPendingUpdateStreamMessages()) | 108 EXPECT_CALL(*connection_, GetPendingUpdateStreamMessages()) |
| 109 .Times(AtLeast(0)) | 109 .Times(AtLeast(0)) |
| 110 .WillRepeatedly(Return(0)); | 110 .WillRepeatedly(Return(0)); |
| 111 | 111 |
| 112 // Start the recording. | 112 // Start the recording. |
| 113 record_->Start(); | 113 record_->Start(); |
| 114 | 114 |
| 115 // Make sure all tasks are completed. | 115 // Make sure all tasks are completed. |
| 116 message_loop_.RunAllPending(); | 116 message_loop_.RunAllPending(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // TODO(hclam): Add test for double buffering. | 119 // TODO(hclam): Add test for double buffering. |
| 120 // TODO(hclam): Add test for multiple captures. | 120 // TODO(hclam): Add test for multiple captures. |
| 121 // TODO(hclam): Add test for interruption. | 121 // TODO(hclam): Add test for interruption. |
| 122 | 122 |
| 123 } // namespace remoting | 123 } // namespace remoting |
| OLD | NEW |