| 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 "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 using ::testing::_; | 13 using ::testing::_; |
| 14 using ::testing::AtLeast; | 14 using ::testing::AtLeast; |
| 15 using ::testing::NotNull; | 15 using ::testing::NotNull; |
| 16 using ::testing::Return; | 16 using ::testing::Return; |
| 17 | 17 |
| 18 namespace remoting { | 18 namespace remoting { |
| 19 | 19 |
| 20 static const int kWidth = 640; | 20 static const int kWidth = 640; |
| 21 static const int kHeight = 480; | 21 static const int kHeight = 480; |
| 22 static const PixelFormat kFormat = PixelFormatRgb32; | 22 static const PixelFormat kFormat = PIXEL_FORMAT_RGB32; |
| 23 static const UpdateStreamEncoding kEncoding = EncodingNone; | 23 static const VideoPacketFormat::Encoding kEncoding = |
| 24 VideoPacketFormat::ENCODING_VERBATIM; |
| 24 | 25 |
| 25 class SessionManagerTest : public testing::Test { | 26 class SessionManagerTest : public testing::Test { |
| 26 public: | 27 public: |
| 27 SessionManagerTest() { | 28 SessionManagerTest() { |
| 28 } | 29 } |
| 29 | 30 |
| 30 protected: | 31 protected: |
| 31 void Init() { | 32 void Init() { |
| 32 capturer_ = new MockCapturer(); | 33 capturer_ = new MockCapturer(); |
| 33 encoder_ = new MockEncoder(); | 34 encoder_ = new MockEncoder(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 57 InvalidRects temp_rects; | 58 InvalidRects temp_rects; |
| 58 std::set_union(dirty_rects.begin(), dirty_rects.end(), | 59 std::set_union(dirty_rects.begin(), dirty_rects.end(), |
| 59 rects.begin(), rects.end(), | 60 rects.begin(), rects.end(), |
| 60 std::inserter(temp_rects, temp_rects.begin())); | 61 std::inserter(temp_rects, temp_rects.begin())); |
| 61 dirty_rects.swap(temp_rects); | 62 dirty_rects.swap(temp_rects); |
| 62 arg0->Run(data); | 63 arg0->Run(data); |
| 63 delete arg0; | 64 delete arg0; |
| 64 } | 65 } |
| 65 | 66 |
| 66 ACTION_P(FinishEncode, msg) { | 67 ACTION_P(FinishEncode, msg) { |
| 67 Encoder::EncodingState state = (Encoder::EncodingStarting | | 68 arg2->Run(msg); |
| 68 Encoder::EncodingInProgress | | |
| 69 Encoder::EncodingEnded); | |
| 70 arg2->Run(msg, state); | |
| 71 delete arg2; | 69 delete arg2; |
| 72 } | 70 } |
| 73 | 71 |
| 74 // BUG 57351 | 72 // BUG 57351 |
| 75 TEST_F(SessionManagerTest, DISABLED_OneRecordCycle) { | 73 TEST_F(SessionManagerTest, DISABLED_OneRecordCycle) { |
| 76 Init(); | 74 Init(); |
| 77 | 75 |
| 78 InvalidRects update_rects; | 76 InvalidRects update_rects; |
| 79 update_rects.insert(gfx::Rect(0, 0, 10, 10)); | 77 update_rects.insert(gfx::Rect(0, 0, 10, 10)); |
| 80 DataPlanes planes; | 78 DataPlanes planes; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 91 EXPECT_CALL(*capturer_, width()).WillRepeatedly(Return(kWidth)); | 89 EXPECT_CALL(*capturer_, width()).WillRepeatedly(Return(kWidth)); |
| 92 EXPECT_CALL(*capturer_, height()).WillRepeatedly(Return(kHeight)); | 90 EXPECT_CALL(*capturer_, height()).WillRepeatedly(Return(kHeight)); |
| 93 EXPECT_CALL(*client_, SendInitClientMessage(kWidth, kHeight)); | 91 EXPECT_CALL(*client_, SendInitClientMessage(kWidth, kHeight)); |
| 94 record_->AddClient(client_); | 92 record_->AddClient(client_); |
| 95 | 93 |
| 96 // First the capturer is called. | 94 // First the capturer is called. |
| 97 EXPECT_CALL(*capturer_, CaptureInvalidRects(NotNull())) | 95 EXPECT_CALL(*capturer_, CaptureInvalidRects(NotNull())) |
| 98 .WillOnce(RunCallback(update_rects, data)); | 96 .WillOnce(RunCallback(update_rects, data)); |
| 99 | 97 |
| 100 // Expect the encoder be called. | 98 // Expect the encoder be called. |
| 101 ChromotingHostMessage* msg = new ChromotingHostMessage(); | 99 VideoPacket* packet = new VideoPacket(); |
| 102 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) | 100 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) |
| 103 .WillOnce(FinishEncode(msg)); | 101 .WillOnce(FinishEncode(packet)); |
| 104 | 102 |
| 105 // Expect the client be notified. | 103 // Expect the client be notified. |
| 106 EXPECT_CALL(*client_, SendBeginUpdateStreamMessage()); | 104 EXPECT_CALL(*client_, SendVideoPacket(_)); |
| 107 EXPECT_CALL(*client_, SendUpdateStreamPacketMessage(_)); | |
| 108 EXPECT_CALL(*client_, SendEndUpdateStreamMessage()); | |
| 109 EXPECT_CALL(*client_, GetPendingUpdateStreamMessages()) | 105 EXPECT_CALL(*client_, GetPendingUpdateStreamMessages()) |
| 110 .Times(AtLeast(0)) | 106 .Times(AtLeast(0)) |
| 111 .WillRepeatedly(Return(0)); | 107 .WillRepeatedly(Return(0)); |
| 112 | 108 |
| 113 // Start the recording. | 109 // Start the recording. |
| 114 record_->Start(); | 110 record_->Start(); |
| 115 | 111 |
| 116 // Make sure all tasks are completed. | 112 // Make sure all tasks are completed. |
| 117 message_loop_.RunAllPending(); | 113 message_loop_.RunAllPending(); |
| 118 } | 114 } |
| 119 | 115 |
| 120 // TODO(hclam): Add test for double buffering. | 116 // TODO(hclam): Add test for double buffering. |
| 121 // TODO(hclam): Add test for multiple captures. | 117 // TODO(hclam): Add test for multiple captures. |
| 122 // TODO(hclam): Add test for interruption. | 118 // TODO(hclam): Add test for interruption. |
| 123 | 119 |
| 124 } // namespace remoting | 120 } // namespace remoting |
| OLD | NEW |