Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1239)

Side by Side Diff: remoting/host/screen_recorder_unittest.cc

Issue 7622002: Revert 96327 - Switch over to using SkRegions to calculate dirty areas. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/screen_recorder.cc ('k') | remoting/host/x_server_pixel_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/task.h" 6 #include "base/task.h"
7 #include "remoting/base/base_mock_objects.h" 7 #include "remoting/base/base_mock_objects.h"
8 #include "remoting/host/host_mock_objects.h" 8 #include "remoting/host/host_mock_objects.h"
9 #include "remoting/host/screen_recorder.h" 9 #include "remoting/host/screen_recorder.h"
10 #include "remoting/proto/video.pb.h" 10 #include "remoting/proto/video.pb.h"
(...skipping 13 matching lines...) Expand all
24 using ::testing::InSequence; 24 using ::testing::InSequence;
25 using ::testing::InvokeWithoutArgs; 25 using ::testing::InvokeWithoutArgs;
26 using ::testing::NotNull; 26 using ::testing::NotNull;
27 using ::testing::Return; 27 using ::testing::Return;
28 using ::testing::SaveArg; 28 using ::testing::SaveArg;
29 29
30 namespace remoting { 30 namespace remoting {
31 31
32 namespace { 32 namespace {
33 33
34 ACTION_P2(RunCallback, region, data) { 34 ACTION_P2(RunCallback, rects, data) {
35 SkRegion& dirty_region = data->mutable_dirty_region(); 35 InvalidRects& dirty_rects = data->mutable_dirty_rects();
36 dirty_region.op(region, SkRegion::kUnion_Op); 36 InvalidRects temp_rects;
37 std::set_union(dirty_rects.begin(), dirty_rects.end(),
38 rects.begin(), rects.end(),
39 std::inserter(temp_rects, temp_rects.begin()));
40 dirty_rects.swap(temp_rects);
37 arg0->Run(data); 41 arg0->Run(data);
38 delete arg0; 42 delete arg0;
39 } 43 }
40 44
41 ACTION(FinishEncode) { 45 ACTION(FinishEncode) {
42 scoped_ptr<VideoPacket> packet(new VideoPacket()); 46 scoped_ptr<VideoPacket> packet(new VideoPacket());
43 packet->set_flags(VideoPacket::LAST_PACKET | VideoPacket::LAST_PARTITION); 47 packet->set_flags(VideoPacket::LAST_PACKET | VideoPacket::LAST_PARTITION);
44 arg2->Run(packet.release()); 48 arg2->Run(packet.release());
45 delete arg2; 49 delete arg2;
46 } 50 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 MockCapturer capturer_; 100 MockCapturer capturer_;
97 MockEncoder* encoder_; 101 MockEncoder* encoder_;
98 MessageLoop message_loop_; 102 MessageLoop message_loop_;
99 private: 103 private:
100 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); 104 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest);
101 }; 105 };
102 106
103 // This test mocks capturer, encoder and network layer to operate one recording 107 // This test mocks capturer, encoder and network layer to operate one recording
104 // cycle. 108 // cycle.
105 TEST_F(ScreenRecorderTest, OneRecordCycle) { 109 TEST_F(ScreenRecorderTest, OneRecordCycle) {
106 SkRegion update_region(SkIRect::MakeXYWH(0, 0, 10, 10)); 110 InvalidRects update_rects;
111 update_rects.insert(gfx::Rect(0, 0, 10, 10));
107 DataPlanes planes; 112 DataPlanes planes;
108 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { 113 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) {
109 planes.data[i] = reinterpret_cast<uint8*>(i); 114 planes.data[i] = reinterpret_cast<uint8*>(i);
110 planes.strides[i] = kWidth * 4; 115 planes.strides[i] = kWidth * 4;
111 } 116 }
112 gfx::Size size(kWidth, kHeight); 117 gfx::Size size(kWidth, kHeight);
113 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat)); 118 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat));
114 EXPECT_CALL(capturer_, InvalidateFullScreen()); 119 EXPECT_CALL(capturer_, InvalidateFullScreen());
115 120
116 // First the capturer is called. 121 // First the capturer is called.
117 EXPECT_CALL(capturer_, CaptureInvalidRegion(NotNull())) 122 EXPECT_CALL(capturer_, CaptureInvalidRects(NotNull()))
118 .WillOnce(RunCallback(update_region, data)); 123 .WillOnce(RunCallback(update_rects, data));
119 124
120 // Expect the encoder be called. 125 // Expect the encoder be called.
121 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) 126 EXPECT_CALL(*encoder_, Encode(data, false, NotNull()))
122 .WillOnce(FinishEncode()); 127 .WillOnce(FinishEncode());
123 128
124 MockVideoStub video_stub; 129 MockVideoStub video_stub;
125 EXPECT_CALL(*connection_, video_stub()) 130 EXPECT_CALL(*connection_, video_stub())
126 .WillRepeatedly(Return(&video_stub)); 131 .WillRepeatedly(Return(&video_stub));
127 132
128 // Expect the client be notified. 133 // Expect the client be notified.
(...skipping 15 matching lines...) Expand all
144 149
145 // Make sure all tasks are completed. 150 // Make sure all tasks are completed.
146 message_loop_.RunAllPending(); 151 message_loop_.RunAllPending();
147 } 152 }
148 153
149 // This test mocks capturer, encoder and network layer to simulate one recording 154 // This test mocks capturer, encoder and network layer to simulate one recording
150 // cycle. When the first encoded packet is submitted to the network 155 // cycle. When the first encoded packet is submitted to the network
151 // ScreenRecorder is instructed to come to a complete stop. We expect the stop 156 // ScreenRecorder is instructed to come to a complete stop. We expect the stop
152 // sequence to be executed successfully. 157 // sequence to be executed successfully.
153 TEST_F(ScreenRecorderTest, StartAndStop) { 158 TEST_F(ScreenRecorderTest, StartAndStop) {
154 SkRegion update_region(SkIRect::MakeXYWH(0, 0, 10, 10)); 159 InvalidRects update_rects;
160 update_rects.insert(gfx::Rect(0, 0, 10, 10));
155 DataPlanes planes; 161 DataPlanes planes;
156 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { 162 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) {
157 planes.data[i] = reinterpret_cast<uint8*>(i); 163 planes.data[i] = reinterpret_cast<uint8*>(i);
158 planes.strides[i] = kWidth * 4; 164 planes.strides[i] = kWidth * 4;
159 } 165 }
160 166
161 gfx::Size size(kWidth, kHeight); 167 gfx::Size size(kWidth, kHeight);
162 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat)); 168 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat));
163 EXPECT_CALL(capturer_, InvalidateFullScreen()); 169 EXPECT_CALL(capturer_, InvalidateFullScreen());
164 170
165 // First the capturer is called. 171 // First the capturer is called.
166 EXPECT_CALL(capturer_, CaptureInvalidRegion(NotNull())) 172 EXPECT_CALL(capturer_, CaptureInvalidRects(NotNull()))
167 .WillRepeatedly(RunCallback(update_region, data)); 173 .WillRepeatedly(RunCallback(update_rects, data));
168 174
169 // Expect the encoder be called. 175 // Expect the encoder be called.
170 EXPECT_CALL(*encoder_, Encode(data, false, NotNull())) 176 EXPECT_CALL(*encoder_, Encode(data, false, NotNull()))
171 .WillRepeatedly(FinishEncode()); 177 .WillRepeatedly(FinishEncode());
172 178
173 MockVideoStub video_stub; 179 MockVideoStub video_stub;
174 EXPECT_CALL(*connection_, video_stub()) 180 EXPECT_CALL(*connection_, video_stub())
175 .WillRepeatedly(Return(&video_stub)); 181 .WillRepeatedly(Return(&video_stub));
176 182
177 // By default delete the arguments when ProcessVideoPacket is received. 183 // By default delete the arguments when ProcessVideoPacket is received.
(...skipping 17 matching lines...) Expand all
195 record_->Start(); 201 record_->Start();
196 message_loop_.Run(); 202 message_loop_.Run();
197 } 203 }
198 204
199 TEST_F(ScreenRecorderTest, StopWithoutStart) { 205 TEST_F(ScreenRecorderTest, StopWithoutStart) {
200 record_->Stop(NewRunnableFunction(&QuitMessageLoop, &message_loop_)); 206 record_->Stop(NewRunnableFunction(&QuitMessageLoop, &message_loop_));
201 message_loop_.Run(); 207 message_loop_.Run();
202 } 208 }
203 209
204 } // namespace remoting 210 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/screen_recorder.cc ('k') | remoting/host/x_server_pixel_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698