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

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

Issue 8493020: Move code in src/remoting to the new callbacks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: - Created 9 years, 1 month 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 | « remoting/base/base_mock_objects.h ('k') | remoting/base/compound_buffer_unittest.cc » ('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 <deque> 5 #include <deque>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include "base/bind.h"
9 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "media/base/video_frame.h" 11 #include "media/base/video_frame.h"
10 #include "remoting/base/base_mock_objects.h" 12 #include "remoting/base/base_mock_objects.h"
11 #include "remoting/base/codec_test.h" 13 #include "remoting/base/codec_test.h"
12 #include "remoting/base/decoder.h" 14 #include "remoting/base/decoder.h"
13 #include "remoting/base/encoder.h" 15 #include "remoting/base/encoder.h"
14 #include "remoting/base/util.h" 16 #include "remoting/base/util.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 static const int kWidth = 320; 19 static const int kWidth = 320;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 static void TestEncodingRects(Encoder* encoder, 264 static void TestEncodingRects(Encoder* encoder,
263 EncoderTester* tester, 265 EncoderTester* tester,
264 scoped_refptr<CaptureData> data, 266 scoped_refptr<CaptureData> data,
265 const SkIRect* rects, int count) { 267 const SkIRect* rects, int count) {
266 data->mutable_dirty_region().setEmpty(); 268 data->mutable_dirty_region().setEmpty();
267 for (int i = 0; i < count; ++i) { 269 for (int i = 0; i < count; ++i) {
268 data->mutable_dirty_region().op(rects[i], SkRegion::kUnion_Op); 270 data->mutable_dirty_region().op(rects[i], SkRegion::kUnion_Op);
269 } 271 }
270 tester->AddRects(rects, count); 272 tester->AddRects(rects, count);
271 273
272 encoder->Encode(data, true, 274 encoder->Encode(data, true, base::Bind(
273 NewCallback(tester, &EncoderTester::DataAvailable)); 275 &EncoderTester::DataAvailable, base::Unretained(tester)));
274 } 276 }
275 277
276 void TestEncoder(Encoder* encoder, bool strict) { 278 void TestEncoder(Encoder* encoder, bool strict) {
277 EncoderMessageTester message_tester; 279 EncoderMessageTester message_tester;
278 message_tester.set_strict(strict); 280 message_tester.set_strict(strict);
279 281
280 EncoderTester tester(&message_tester); 282 EncoderTester tester(&message_tester);
281 283
282 uint8* memory; 284 uint8* memory;
283 scoped_refptr<CaptureData> data = 285 scoped_refptr<CaptureData> data =
(...skipping 27 matching lines...) Expand all
311 uint8* memory = data->data_planes().data[0] + 313 uint8* memory = data->data_planes().data[0] +
312 data->data_planes().strides[0] * rect.fTop + 314 data->data_planes().strides[0] * rect.fTop +
313 bytes_per_pixel * rect.fLeft; 315 bytes_per_pixel * rect.fLeft;
314 for (int y = 0; y < rect.height(); ++y) { 316 for (int y = 0; y < rect.height(); ++y) {
315 for (int x = 0; x < row_size; ++x) 317 for (int x = 0; x < row_size; ++x)
316 memory[x] = rand() % 256; 318 memory[x] = rand() % 256;
317 memory += data->data_planes().strides[0]; 319 memory += data->data_planes().strides[0];
318 } 320 }
319 } 321 }
320 322
321 encoder->Encode(data, true, 323 encoder->Encode(data, true, base::Bind(&EncoderTester::DataAvailable,
322 NewCallback(encoder_tester, &EncoderTester::DataAvailable)); 324 base::Unretained(encoder_tester)));
323 decoder_tester->VerifyResults(); 325 decoder_tester->VerifyResults();
324 decoder_tester->Reset(); 326 decoder_tester->Reset();
325 } 327 }
326 328
327 void TestEncoderDecoder(Encoder* encoder, Decoder* decoder, bool strict) { 329 void TestEncoderDecoder(Encoder* encoder, Decoder* decoder, bool strict) {
328 EncoderMessageTester message_tester; 330 EncoderMessageTester message_tester;
329 message_tester.set_strict(strict); 331 message_tester.set_strict(strict);
330 332
331 EncoderTester encoder_tester(&message_tester); 333 EncoderTester encoder_tester(&message_tester);
332 334
(...skipping 11 matching lines...) Expand all
344 kTestRects, 1); 346 kTestRects, 1);
345 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, 347 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data,
346 kTestRects + 1, 1); 348 kTestRects + 1, 1);
347 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, 349 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data,
348 kTestRects + 2, 1); 350 kTestRects + 2, 1);
349 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, 351 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data,
350 kTestRects + 3, 2); 352 kTestRects + 3, 2);
351 } 353 }
352 354
353 } // namespace remoting 355 } // namespace remoting
354
355 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::DecoderTester);
OLDNEW
« no previous file with comments | « remoting/base/base_mock_objects.h ('k') | remoting/base/compound_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698