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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // This test mocks capturer, encoder and network layer to operate one recording | 106 // This test mocks capturer, encoder and network layer to operate one recording |
107 // cycle. | 107 // cycle. |
108 TEST_F(ScreenRecorderTest, OneRecordCycle) { | 108 TEST_F(ScreenRecorderTest, OneRecordCycle) { |
109 SkRegion update_region(SkIRect::MakeXYWH(0, 0, 10, 10)); | 109 SkRegion update_region(SkIRect::MakeXYWH(0, 0, 10, 10)); |
110 DataPlanes planes; | 110 DataPlanes planes; |
111 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { | 111 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { |
112 planes.data[i] = reinterpret_cast<uint8*>(i); | 112 planes.data[i] = reinterpret_cast<uint8*>(i); |
113 planes.strides[i] = kWidth * 4; | 113 planes.strides[i] = kWidth * 4; |
114 } | 114 } |
115 gfx::Size size(kWidth, kHeight); | 115 SkISize size(SkISize::Make(kWidth, kHeight)); |
116 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat)); | 116 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat)); |
117 EXPECT_CALL(capturer_, InvalidateFullScreen()); | 117 EXPECT_CALL(capturer_, InvalidateFullScreen()); |
118 | 118 |
119 // First the capturer is called. | 119 // First the capturer is called. |
120 EXPECT_CALL(capturer_, CaptureInvalidRegion(NotNull())) | 120 EXPECT_CALL(capturer_, CaptureInvalidRegion(NotNull())) |
121 .WillOnce(RunCallback(update_region, data)); | 121 .WillOnce(RunCallback(update_region, data)); |
122 | 122 |
123 // Expect the encoder be called. | 123 // Expect the encoder be called. |
124 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) | 124 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) |
125 .WillOnce(FinishEncode()); | 125 .WillOnce(FinishEncode()); |
(...skipping 28 matching lines...) Expand all Loading... |
154 // ScreenRecorder is instructed to come to a complete stop. We expect the stop | 154 // ScreenRecorder is instructed to come to a complete stop. We expect the stop |
155 // sequence to be executed successfully. | 155 // sequence to be executed successfully. |
156 TEST_F(ScreenRecorderTest, StartAndStop) { | 156 TEST_F(ScreenRecorderTest, StartAndStop) { |
157 SkRegion update_region(SkIRect::MakeXYWH(0, 0, 10, 10)); | 157 SkRegion update_region(SkIRect::MakeXYWH(0, 0, 10, 10)); |
158 DataPlanes planes; | 158 DataPlanes planes; |
159 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { | 159 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { |
160 planes.data[i] = reinterpret_cast<uint8*>(i); | 160 planes.data[i] = reinterpret_cast<uint8*>(i); |
161 planes.strides[i] = kWidth * 4; | 161 planes.strides[i] = kWidth * 4; |
162 } | 162 } |
163 | 163 |
164 gfx::Size size(kWidth, kHeight); | 164 SkISize size(SkISize::Make(kWidth, kHeight)); |
165 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat)); | 165 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat)); |
166 EXPECT_CALL(capturer_, InvalidateFullScreen()); | 166 EXPECT_CALL(capturer_, InvalidateFullScreen()); |
167 | 167 |
168 // First the capturer is called. | 168 // First the capturer is called. |
169 EXPECT_CALL(capturer_, CaptureInvalidRegion(NotNull())) | 169 EXPECT_CALL(capturer_, CaptureInvalidRegion(NotNull())) |
170 .WillRepeatedly(RunCallback(update_region, data)); | 170 .WillRepeatedly(RunCallback(update_region, data)); |
171 | 171 |
172 // Expect the encoder be called. | 172 // Expect the encoder be called. |
173 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) | 173 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) |
174 .WillRepeatedly(FinishEncode()); | 174 .WillRepeatedly(FinishEncode()); |
(...skipping 22 matching lines...) Expand all Loading... |
197 record_->Start(); | 197 record_->Start(); |
198 message_loop_.Run(); | 198 message_loop_.Run(); |
199 } | 199 } |
200 | 200 |
201 TEST_F(ScreenRecorderTest, StopWithoutStart) { | 201 TEST_F(ScreenRecorderTest, StopWithoutStart) { |
202 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); | 202 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); |
203 message_loop_.Run(); | 203 message_loop_.Run(); |
204 } | 204 } |
205 | 205 |
206 } // namespace remoting | 206 } // namespace remoting |
OLD | NEW |