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

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

Issue 2832043: Fixes leaks in remote_unittest.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Created 10 years, 5 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 | « remoting/host/differ.h ('k') | no next file » | 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 "base/scoped_ptr.h" 5 #include "base/scoped_ptr.h"
6 #include "remoting/host/differ.h" 6 #include "remoting/host/differ.h"
7 #include "testing/gmock/include/gmock/gmock.h" 7 #include "testing/gmock/include/gmock/gmock.h"
8 8
9 namespace remoting { 9 namespace remoting {
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 136
137 // Mark the range of blocks specified and then verify that they are 137 // Mark the range of blocks specified and then verify that they are
138 // merged correctly. 138 // merged correctly.
139 // Only one rectangular region of blocks can be checked with this routine. 139 // Only one rectangular region of blocks can be checked with this routine.
140 void MarkBlocksAndCheckMerge(int x_origin, int y_origin, 140 void MarkBlocksAndCheckMerge(int x_origin, int y_origin,
141 int width, int height) { 141 int width, int height) {
142 ClearDiffInfo(); 142 ClearDiffInfo();
143 MarkBlocks(x_origin, y_origin, width, height); 143 MarkBlocks(x_origin, y_origin, width, height);
144 144
145 DirtyRects* dirty = new DirtyRects(); 145 scoped_ptr<DirtyRects> dirty(new DirtyRects());
146 differ_->MergeBlocks(dirty); 146 differ_->MergeBlocks(dirty.get());
147 147
148 ASSERT_EQ(1UL, dirty->size()); 148 ASSERT_EQ(1UL, dirty->size());
149 CheckDirtyRect(dirty->at(0), x_origin, y_origin, width, height); 149 CheckDirtyRect(dirty->at(0), x_origin, y_origin, width, height);
150 } 150 }
151 151
152 // The differ class we're testing. 152 // The differ class we're testing.
153 scoped_ptr<Differ> differ_; 153 scoped_ptr<Differ> differ_;
154 154
155 // Screen/buffer info. 155 // Screen/buffer info.
156 int width_; 156 int width_;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // | | | | _ | 262 // | | | | _ |
263 // +---+---+---+---+ 263 // +---+---+---+---+
264 // | | | | _ | 264 // | | | | _ |
265 // +---+---+---+---+ 265 // +---+---+---+---+
266 // | | | | _ | 266 // | | | | _ |
267 // +---+---+---+---+ 267 // +---+---+---+---+
268 // | _ | _ | _ | _ | 268 // | _ | _ | _ | _ |
269 // +---+---+---+---+ 269 // +---+---+---+---+
270 ClearDiffInfo(); 270 ClearDiffInfo();
271 271
272 DirtyRects* dirty = new DirtyRects(); 272 scoped_ptr<DirtyRects> dirty(new DirtyRects());
273 differ_->MergeBlocks(dirty); 273 differ_->MergeBlocks(dirty.get());
274 274
275 EXPECT_EQ(0UL, dirty->size()); 275 EXPECT_EQ(0UL, dirty->size());
276 } 276 }
277 277
278 TEST_F(DifferTest, MergeBlocks_SingleBlock) { 278 TEST_F(DifferTest, MergeBlocks_SingleBlock) {
279 // Mark a single block and make sure that there is a single merged 279 // Mark a single block and make sure that there is a single merged
280 // rect with the correct bounds. 280 // rect with the correct bounds.
281 for (int y = 0; y < GetDiffInfoHeight() - 1; y++) { 281 for (int y = 0; y < GetDiffInfoHeight() - 1; y++) {
282 for (int x = 0; x < GetDiffInfoWidth() - 1; x++) { 282 for (int x = 0; x < GetDiffInfoWidth() - 1; x++) {
283 MarkBlocksAndCheckMerge(x, y, 1, 1); 283 MarkBlocksAndCheckMerge(x, y, 1, 1);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 // +---+---+---+---+ 409 // +---+---+---+---+
410 // | _ | _ | _ | _ | 410 // | _ | _ | _ | _ |
411 // +---+---+---+---+ 411 // +---+---+---+---+
412 MarkBlocksAndCheckMerge(0, 0, 3, 3); 412 MarkBlocksAndCheckMerge(0, 0, 3, 3);
413 } 413 }
414 414
415 // This tests marked regions that require more than 1 single dirty rect. 415 // This tests marked regions that require more than 1 single dirty rect.
416 // The exact rects returned depend on the current implementation, so these 416 // The exact rects returned depend on the current implementation, so these
417 // may need to be updated if we modify how we merge blocks. 417 // may need to be updated if we modify how we merge blocks.
418 TEST_F(DifferTest, MergeBlocks_MultiRect) { 418 TEST_F(DifferTest, MergeBlocks_MultiRect) {
419 DirtyRects* dirty; 419 scoped_ptr<DirtyRects> dirty;
420 420
421 // +---+---+---+---+ +---+---+---+ 421 // +---+---+---+---+ +---+---+---+
422 // | | X | | _ | | | 0 | | 422 // | | X | | _ | | | 0 | |
423 // +---+---+---+---+ +---+---+---+ 423 // +---+---+---+---+ +---+---+---+
424 // | X | | | _ | | 1 | | | 424 // | X | | | _ | | 1 | | |
425 // +---+---+---+---+ => +---+---+---+ 425 // +---+---+---+---+ => +---+---+---+
426 // | | | X | _ | | | | 2 | 426 // | | | X | _ | | | | 2 |
427 // +---+---+---+---+ +---+---+---+ 427 // +---+---+---+---+ +---+---+---+
428 // | _ | _ | _ | _ | 428 // | _ | _ | _ | _ |
429 // +---+---+---+---+ 429 // +---+---+---+---+
430 ClearDiffInfo(); 430 ClearDiffInfo();
431 MarkBlocks(1, 0, 1, 1); 431 MarkBlocks(1, 0, 1, 1);
432 MarkBlocks(0, 1, 1, 1); 432 MarkBlocks(0, 1, 1, 1);
433 MarkBlocks(2, 2, 1, 1); 433 MarkBlocks(2, 2, 1, 1);
434 434
435 dirty = new DirtyRects(); 435 dirty.reset(new DirtyRects());
436 differ_->MergeBlocks(dirty); 436 differ_->MergeBlocks(dirty.get());
437 437
438 ASSERT_EQ(3UL, dirty->size()); 438 ASSERT_EQ(3UL, dirty->size());
439 CheckDirtyRect(dirty->at(0), 1, 0, 1, 1); 439 CheckDirtyRect(dirty->at(0), 1, 0, 1, 1);
440 CheckDirtyRect(dirty->at(1), 0, 1, 1, 1); 440 CheckDirtyRect(dirty->at(1), 0, 1, 1, 1);
441 CheckDirtyRect(dirty->at(2), 2, 2, 1, 1); 441 CheckDirtyRect(dirty->at(2), 2, 2, 1, 1);
442 442
443 // +---+---+---+---+ +---+---+---+ 443 // +---+---+---+---+ +---+---+---+
444 // | | | X | _ | | | | 0 | 444 // | | | X | _ | | | | 0 |
445 // +---+---+---+---+ +---+---+ + 445 // +---+---+---+---+ +---+---+ +
446 // | X | X | X | _ | | 1 1 | 0 | 446 // | X | X | X | _ | | 1 1 | 0 |
447 // +---+---+---+---+ => + + + 447 // +---+---+---+---+ => + + +
448 // | X | X | X | _ | | 1 1 | 0 | 448 // | X | X | X | _ | | 1 1 | 0 |
449 // +---+---+---+---+ +---+---+---+ 449 // +---+---+---+---+ +---+---+---+
450 // | _ | _ | _ | _ | 450 // | _ | _ | _ | _ |
451 // +---+---+---+---+ 451 // +---+---+---+---+
452 ClearDiffInfo(); 452 ClearDiffInfo();
453 MarkBlocks(2, 0, 1, 3); 453 MarkBlocks(2, 0, 1, 3);
454 MarkBlocks(0, 1, 2, 2); 454 MarkBlocks(0, 1, 2, 2);
455 455
456 dirty = new DirtyRects(); 456 dirty.reset(new DirtyRects());
457 differ_->MergeBlocks(dirty); 457 differ_->MergeBlocks(dirty.get());
458 458
459 ASSERT_EQ(2UL, dirty->size()); 459 ASSERT_EQ(2UL, dirty->size());
460 CheckDirtyRect(dirty->at(0), 2, 0, 1, 3); 460 CheckDirtyRect(dirty->at(0), 2, 0, 1, 3);
461 CheckDirtyRect(dirty->at(1), 0, 1, 2, 2); 461 CheckDirtyRect(dirty->at(1), 0, 1, 2, 2);
462 462
463 // +---+---+---+---+ +---+---+---+ 463 // +---+---+---+---+ +---+---+---+
464 // | | | | _ | | | | | 464 // | | | | _ | | | | |
465 // +---+---+---+---+ +---+---+---+ 465 // +---+---+---+---+ +---+---+---+
466 // | X | | X | _ | | 0 | | 1 | 466 // | X | | X | _ | | 0 | | 1 |
467 // +---+---+---+---+ => + +---+ + 467 // +---+---+---+---+ => + +---+ +
468 // | X | X | X | _ | | 0 | 2 | 1 | 468 // | X | X | X | _ | | 0 | 2 | 1 |
469 // +---+---+---+---+ +---+---+---+ 469 // +---+---+---+---+ +---+---+---+
470 // | _ | _ | _ | _ | 470 // | _ | _ | _ | _ |
471 // +---+---+---+---+ 471 // +---+---+---+---+
472 ClearDiffInfo(); 472 ClearDiffInfo();
473 MarkBlocks(0, 1, 1, 1); 473 MarkBlocks(0, 1, 1, 1);
474 MarkBlocks(2, 1, 1, 1); 474 MarkBlocks(2, 1, 1, 1);
475 MarkBlocks(0, 2, 3, 1); 475 MarkBlocks(0, 2, 3, 1);
476 476
477 dirty = new DirtyRects(); 477 dirty.reset(new DirtyRects());
478 differ_->MergeBlocks(dirty); 478 differ_->MergeBlocks(dirty.get());
479 479
480 ASSERT_EQ(3UL, dirty->size()); 480 ASSERT_EQ(3UL, dirty->size());
481 CheckDirtyRect(dirty->at(0), 0, 1, 1, 2); 481 CheckDirtyRect(dirty->at(0), 0, 1, 1, 2);
482 CheckDirtyRect(dirty->at(1), 2, 1, 1, 2); 482 CheckDirtyRect(dirty->at(1), 2, 1, 1, 2);
483 CheckDirtyRect(dirty->at(2), 1, 2, 1, 1); 483 CheckDirtyRect(dirty->at(2), 1, 2, 1, 1);
484 484
485 // +---+---+---+---+ +---+---+---+ 485 // +---+---+---+---+ +---+---+---+
486 // | X | X | X | _ | | 0 0 0 | 486 // | X | X | X | _ | | 0 0 0 |
487 // +---+---+---+---+ +---+---+---+ 487 // +---+---+---+---+ +---+---+---+
488 // | X | | X | _ | | 1 | | 2 | 488 // | X | | X | _ | | 1 | | 2 |
489 // +---+---+---+---+ => + +---+ + 489 // +---+---+---+---+ => + +---+ +
490 // | X | X | X | _ | | 1 | 3 | 2 | 490 // | X | X | X | _ | | 1 | 3 | 2 |
491 // +---+---+---+---+ +---+---+---+ 491 // +---+---+---+---+ +---+---+---+
492 // | _ | _ | _ | _ | 492 // | _ | _ | _ | _ |
493 // +---+---+---+---+ 493 // +---+---+---+---+
494 ClearDiffInfo(); 494 ClearDiffInfo();
495 MarkBlocks(0, 0, 3, 1); 495 MarkBlocks(0, 0, 3, 1);
496 MarkBlocks(0, 1, 1, 1); 496 MarkBlocks(0, 1, 1, 1);
497 MarkBlocks(2, 1, 1, 1); 497 MarkBlocks(2, 1, 1, 1);
498 MarkBlocks(0, 2, 3, 1); 498 MarkBlocks(0, 2, 3, 1);
499 499
500 dirty = new DirtyRects(); 500 dirty.reset(new DirtyRects());
501 differ_->MergeBlocks(dirty); 501 differ_->MergeBlocks(dirty.get());
502 502
503 ASSERT_EQ(4UL, dirty->size()); 503 ASSERT_EQ(4UL, dirty->size());
504 CheckDirtyRect(dirty->at(0), 0, 0, 3, 1); 504 CheckDirtyRect(dirty->at(0), 0, 0, 3, 1);
505 CheckDirtyRect(dirty->at(1), 0, 1, 1, 2); 505 CheckDirtyRect(dirty->at(1), 0, 1, 1, 2);
506 CheckDirtyRect(dirty->at(2), 2, 1, 1, 2); 506 CheckDirtyRect(dirty->at(2), 2, 1, 1, 2);
507 CheckDirtyRect(dirty->at(3), 1, 2, 1, 1); 507 CheckDirtyRect(dirty->at(3), 1, 2, 1, 1);
508 508
509 // +---+---+---+---+ +---+---+---+ 509 // +---+---+---+---+ +---+---+---+
510 // | X | X | | _ | | 0 0 | | 510 // | X | X | | _ | | 0 0 | |
511 // +---+---+---+---+ + +---+ 511 // +---+---+---+---+ + +---+
512 // | X | X | | _ | | 0 0 | | 512 // | X | X | | _ | | 0 0 | |
513 // +---+---+---+---+ => +---+---+---+ 513 // +---+---+---+---+ => +---+---+---+
514 // | | X | | _ | | | 1 | | 514 // | | X | | _ | | | 1 | |
515 // +---+---+---+---+ +---+---+---+ 515 // +---+---+---+---+ +---+---+---+
516 // | _ | _ | _ | _ | 516 // | _ | _ | _ | _ |
517 // +---+---+---+---+ 517 // +---+---+---+---+
518 ClearDiffInfo(); 518 ClearDiffInfo();
519 MarkBlocks(0, 0, 2, 2); 519 MarkBlocks(0, 0, 2, 2);
520 MarkBlocks(1, 2, 1, 1); 520 MarkBlocks(1, 2, 1, 1);
521 521
522 dirty = new DirtyRects(); 522 dirty.reset(new DirtyRects());
523 differ_->MergeBlocks(dirty); 523 differ_->MergeBlocks(dirty.get());
524 524
525 ASSERT_EQ(2UL, dirty->size()); 525 ASSERT_EQ(2UL, dirty->size());
526 CheckDirtyRect(dirty->at(0), 0, 0, 2, 2); 526 CheckDirtyRect(dirty->at(0), 0, 0, 2, 2);
527 CheckDirtyRect(dirty->at(1), 1, 2, 1, 1); 527 CheckDirtyRect(dirty->at(1), 1, 2, 1, 1);
528 } 528 }
529 529
530 } // namespace remoting 530 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/differ.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698