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

Side by Side Diff: remoting/base/codec_test.cc

Issue 3161034: Rename (Host|Client)Message to Chromoting(Host|Client)Message. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Fix merge conflicts Created 10 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
« no previous file with comments | « no previous file | remoting/base/decoder.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) 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 <deque> 5 #include <deque>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include "gfx/rect.h" 8 #include "gfx/rect.h"
9 #include "media/base/video_frame.h" 9 #include "media/base/video_frame.h"
10 #include "remoting/base/codec_test.h" 10 #include "remoting/base/codec_test.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 ~EncoderMessageTester() { 79 ~EncoderMessageTester() {
80 EXPECT_EQ(begin_rect_, end_rect_); 80 EXPECT_EQ(begin_rect_, end_rect_);
81 EXPECT_EQ(kWaitingForBeginRect, state_); 81 EXPECT_EQ(kWaitingForBeginRect, state_);
82 if (strict_){ 82 if (strict_){
83 EXPECT_EQ(begin_rect_, added_rects_); 83 EXPECT_EQ(begin_rect_, added_rects_);
84 } 84 }
85 } 85 }
86 86
87 // Test that we received the correct message. 87 // Test that we received the correct message.
88 void ReceivedMessage(HostMessage* message) { 88 void ReceivedMessage(ChromotingHostMessage* message) {
89 EXPECT_TRUE(message->has_update_stream_packet()); 89 EXPECT_TRUE(message->has_update_stream_packet());
90 90
91 if (state_ == kWaitingForBeginRect) { 91 if (state_ == kWaitingForBeginRect) {
92 EXPECT_TRUE(message->update_stream_packet().has_begin_rect()); 92 EXPECT_TRUE(message->update_stream_packet().has_begin_rect());
93 state_ = kWaitingForRectData; 93 state_ = kWaitingForRectData;
94 ++begin_rect_; 94 ++begin_rect_;
95 95
96 if (strict_) { 96 if (strict_) {
97 gfx::Rect rect = rects_.front(); 97 gfx::Rect rect = rects_.front();
98 rects_.pop_front(); 98 rects_.pop_front();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 : strict_(false), 155 : strict_(false),
156 decoder_(decoder), 156 decoder_(decoder),
157 decode_done_(false) { 157 decode_done_(false) {
158 media::VideoFrame::CreateFrame(media::VideoFrame::RGB32, 158 media::VideoFrame::CreateFrame(media::VideoFrame::RGB32,
159 kWidth, kHeight, 159 kWidth, kHeight,
160 base::TimeDelta(), 160 base::TimeDelta(),
161 base::TimeDelta(), &frame_); 161 base::TimeDelta(), &frame_);
162 EXPECT_TRUE(frame_.get()); 162 EXPECT_TRUE(frame_.get());
163 } 163 }
164 164
165 void ReceivedMessage(HostMessage* message) { 165 void ReceivedMessage(ChromotingHostMessage* message) {
166 if (message->has_update_stream_packet()) { 166 if (message->has_update_stream_packet()) {
167 decoder_->PartialDecode(message); 167 decoder_->PartialDecode(message);
168 return; 168 return;
169 } 169 }
170 170
171 if (message->has_begin_update_stream()) { 171 if (message->has_begin_update_stream()) {
172 decoder_->BeginDecode( 172 decoder_->BeginDecode(
173 frame_, &update_rects_, 173 frame_, &update_rects_,
174 NewRunnableMethod(this, &DecoderTester::OnPartialDecodeDone), 174 NewRunnableMethod(this, &DecoderTester::OnPartialDecodeDone),
175 NewRunnableMethod(this, &DecoderTester::OnDecodeDone)); 175 NewRunnableMethod(this, &DecoderTester::OnDecodeDone));
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 : message_tester_(message_tester), 258 : message_tester_(message_tester),
259 state_tester_(state_tester), 259 state_tester_(state_tester),
260 decoder_tester_(NULL), 260 decoder_tester_(NULL),
261 data_available_(0) { 261 data_available_(0) {
262 } 262 }
263 263
264 ~EncoderTester() { 264 ~EncoderTester() {
265 EXPECT_GT(data_available_, 0); 265 EXPECT_GT(data_available_, 0);
266 } 266 }
267 267
268 void DataAvailable(HostMessage* message, 268 void DataAvailable(ChromotingHostMessage* message,
269 Encoder::EncodingState state) { 269 Encoder::EncodingState state) {
270 ++data_available_; 270 ++data_available_;
271 message_tester_->ReceivedMessage(message); 271 message_tester_->ReceivedMessage(message);
272 state_tester_->ReceivedState(state); 272 state_tester_->ReceivedState(state);
273 273
274 // Send the message to the DecoderTester. 274 // Send the message to the DecoderTester.
275 if (decoder_tester_) { 275 if (decoder_tester_) {
276 if (state & Encoder::EncodingStarting) { 276 if (state & Encoder::EncodingStarting) {
277 HostMessage* begin_update = new HostMessage(); 277 ChromotingHostMessage* begin_update = new ChromotingHostMessage();
278 begin_update->mutable_begin_update_stream(); 278 begin_update->mutable_begin_update_stream();
279 decoder_tester_->ReceivedMessage(begin_update); 279 decoder_tester_->ReceivedMessage(begin_update);
280 } 280 }
281 281
282 if (state & Encoder::EncodingInProgress) { 282 if (state & Encoder::EncodingInProgress) {
283 decoder_tester_->ReceivedMessage(message); 283 decoder_tester_->ReceivedMessage(message);
284 } 284 }
285 285
286 if (state & Encoder::EncodingEnded) { 286 if (state & Encoder::EncodingEnded) {
287 HostMessage* end_update = new HostMessage(); 287 ChromotingHostMessage* end_update = new ChromotingHostMessage();
288 end_update->mutable_end_update_stream(); 288 end_update->mutable_end_update_stream();
289 decoder_tester_->ReceivedMessage(end_update); 289 decoder_tester_->ReceivedMessage(end_update);
290 } 290 }
291 } else { 291 } else {
292 delete message; 292 delete message;
293 } 293 }
294 } 294 }
295 295
296 void AddRects(const gfx::Rect* rects, int count) { 296 void AddRects(const gfx::Rect* rects, int count) {
297 message_tester_->AddRects(rects, count); 297 message_tester_->AddRects(rects, count);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, 421 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data,
422 kTestRects + 2, 1); 422 kTestRects + 2, 1);
423 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, 423 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data,
424 kTestRects + 3, 2); 424 kTestRects + 3, 2);
425 delete [] memory; 425 delete [] memory;
426 } 426 }
427 427
428 } // namespace remoting 428 } // namespace remoting
429 429
430 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::DecoderTester); 430 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::DecoderTester);
OLDNEW
« no previous file with comments | « no previous file | remoting/base/decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698