| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 using ::testing::_; | 22 using ::testing::_; |
| 23 using ::testing::AtLeast; | 23 using ::testing::AtLeast; |
| 24 using ::testing::AnyNumber; | 24 using ::testing::AnyNumber; |
| 25 using ::testing::DeleteArg; | 25 using ::testing::DeleteArg; |
| 26 using ::testing::DoAll; | 26 using ::testing::DoAll; |
| 27 using ::testing::Expectation; | 27 using ::testing::Expectation; |
| 28 using ::testing::InSequence; | 28 using ::testing::InSequence; |
| 29 using ::testing::InvokeWithoutArgs; | 29 using ::testing::InvokeWithoutArgs; |
| 30 using ::testing::Return; | 30 using ::testing::Return; |
| 31 using ::testing::ReturnRef; |
| 31 using ::testing::SaveArg; | 32 using ::testing::SaveArg; |
| 32 | 33 |
| 33 namespace remoting { | 34 namespace remoting { |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 ACTION_P2(RunCallback, region, data) { | 38 ACTION_P2(RunCallback, region, data) { |
| 38 SkRegion& dirty_region = data->mutable_dirty_region(); | 39 SkRegion& dirty_region = data->mutable_dirty_region(); |
| 39 dirty_region.op(region, SkRegion::kUnion_Op); | 40 dirty_region.op(region, SkRegion::kUnion_Op); |
| 40 arg0.Run(data); | 41 arg0.Run(data); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 DataPlanes planes; | 124 DataPlanes planes; |
| 124 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { | 125 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { |
| 125 planes.data[i] = reinterpret_cast<uint8*>(i); | 126 planes.data[i] = reinterpret_cast<uint8*>(i); |
| 126 planes.strides[i] = kWidth * 4; | 127 planes.strides[i] = kWidth * 4; |
| 127 } | 128 } |
| 128 | 129 |
| 129 Expectation capturer_start = EXPECT_CALL(capturer_, Start(_)); | 130 Expectation capturer_start = EXPECT_CALL(capturer_, Start(_)); |
| 130 | 131 |
| 131 SkISize size(SkISize::Make(kWidth, kHeight)); | 132 SkISize size(SkISize::Make(kWidth, kHeight)); |
| 132 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat)); | 133 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat)); |
| 133 EXPECT_CALL(capturer_, InvalidateFullScreen()); | 134 |
| 135 EXPECT_CALL(capturer_, size_most_recent()) |
| 136 .WillRepeatedly(ReturnRef(size)); |
| 137 |
| 138 EXPECT_CALL(capturer_, InvalidateRegion(_)); |
| 134 | 139 |
| 135 // First the capturer is called. | 140 // First the capturer is called. |
| 136 Expectation capturer_capture = EXPECT_CALL(capturer_, CaptureInvalidRegion(_)) | 141 Expectation capturer_capture = EXPECT_CALL(capturer_, CaptureInvalidRegion(_)) |
| 137 .After(capturer_start) | 142 .After(capturer_start) |
| 138 .WillRepeatedly(RunCallback(update_region, data)); | 143 .WillRepeatedly(RunCallback(update_region, data)); |
| 139 | 144 |
| 140 // Expect the encoder be called. | 145 // Expect the encoder be called. |
| 141 EXPECT_CALL(*encoder_, Encode(data, false, _)) | 146 EXPECT_CALL(*encoder_, Encode(data, false, _)) |
| 142 .WillRepeatedly(FinishEncode()); | 147 .WillRepeatedly(FinishEncode()); |
| 143 | 148 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 169 message_loop_.Run(); | 174 message_loop_.Run(); |
| 170 } | 175 } |
| 171 | 176 |
| 172 TEST_F(ScreenRecorderTest, StopWithoutStart) { | 177 TEST_F(ScreenRecorderTest, StopWithoutStart) { |
| 173 EXPECT_CALL(capturer_, Stop()); | 178 EXPECT_CALL(capturer_, Stop()); |
| 174 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); | 179 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); |
| 175 message_loop_.Run(); | 180 message_loop_.Run(); |
| 176 } | 181 } |
| 177 | 182 |
| 178 } // namespace remoting | 183 } // namespace remoting |
| OLD | NEW |