| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/renderer/paint_aggregator.h" | 5 #include "chrome/renderer/paint_aggregator.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 TEST(PaintAggregator, InitialState) { | 8 TEST(PaintAggregator, InitialState) { |
| 9 PaintAggregator greg; | 9 PaintAggregator greg; |
| 10 EXPECT_FALSE(greg.HasPendingUpdate()); | 10 EXPECT_FALSE(greg.HasPendingUpdate()); |
| 11 } | 11 } |
| 12 | 12 |
| 13 TEST(PaintAggregator, SingleInvalidation) { | 13 TEST(PaintAggregator, SingleInvalidation) { |
| 14 PaintAggregator greg; | 14 PaintAggregator greg; |
| 15 | 15 |
| 16 gfx::Rect rect(2, 4, 10, 16); | 16 gfx::Rect rect(2, 4, 10, 16); |
| 17 greg.InvalidateRect(rect); | 17 greg.InvalidateRect(rect); |
| 18 | 18 |
| 19 EXPECT_TRUE(greg.HasPendingUpdate()); | 19 EXPECT_TRUE(greg.HasPendingUpdate()); |
| 20 EXPECT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 20 EXPECT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 21 ASSERT_EQ(1U, greg.GetPendingUpdate().paint_rects.size()); | 21 ASSERT_EQ(1U, greg.GetPendingUpdate().paint_rects.size()); |
| 22 | 22 |
| 23 EXPECT_EQ(rect, greg.GetPendingUpdate().paint_rects[0]); | 23 EXPECT_EQ(rect, greg.GetPendingUpdate().paint_rects[0]); |
| 24 } | 24 } |
| 25 | 25 |
| 26 TEST(PaintAggregator, DoubleDisjointInvalidation) { | 26 TEST(PaintAggregator, DoubleDisjointInvalidation) { |
| 27 PaintAggregator greg; | 27 PaintAggregator greg; |
| 28 | 28 |
| 29 gfx::Rect r1(2, 4, 2, 4); | 29 gfx::Rect r1(2, 4, 2, 40); |
| 30 gfx::Rect r2(4, 2, 4, 2); | 30 gfx::Rect r2(4, 2, 40, 2); |
| 31 | 31 |
| 32 greg.InvalidateRect(r1); | 32 greg.InvalidateRect(r1); |
| 33 greg.InvalidateRect(r2); | 33 greg.InvalidateRect(r2); |
| 34 | 34 |
| 35 gfx::Rect expected_bounds = r1.Union(r2); | 35 gfx::Rect expected_bounds = r1.Union(r2); |
| 36 | 36 |
| 37 EXPECT_TRUE(greg.HasPendingUpdate()); | 37 EXPECT_TRUE(greg.HasPendingUpdate()); |
| 38 EXPECT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 38 EXPECT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 39 ASSERT_EQ(2U, greg.GetPendingUpdate().paint_rects.size()); | 39 EXPECT_EQ(2U, greg.GetPendingUpdate().paint_rects.size()); |
| 40 | 40 |
| 41 EXPECT_EQ(expected_bounds, greg.GetPendingUpdate().GetPaintBounds()); | 41 EXPECT_EQ(expected_bounds, greg.GetPendingUpdate().GetPaintBounds()); |
| 42 } | 42 } |
| 43 | 43 |
| 44 TEST(PaintAggregator, DisjointInvalidationsCombined) { |
| 45 PaintAggregator greg; |
| 46 |
| 47 gfx::Rect r1(2, 4, 2, 2); |
| 48 gfx::Rect r2(4, 2, 2, 2); |
| 49 |
| 50 greg.InvalidateRect(r1); |
| 51 greg.InvalidateRect(r2); |
| 52 |
| 53 gfx::Rect expected_bounds = r1.Union(r2); |
| 54 |
| 55 EXPECT_TRUE(greg.HasPendingUpdate()); |
| 56 EXPECT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 57 ASSERT_EQ(1U, greg.GetPendingUpdate().paint_rects.size()); |
| 58 |
| 59 EXPECT_EQ(expected_bounds, greg.GetPendingUpdate().paint_rects[0]); |
| 60 } |
| 61 |
| 44 TEST(PaintAggregator, SingleScroll) { | 62 TEST(PaintAggregator, SingleScroll) { |
| 45 PaintAggregator greg; | 63 PaintAggregator greg; |
| 46 | 64 |
| 47 gfx::Rect rect(1, 2, 3, 4); | 65 gfx::Rect rect(1, 2, 3, 4); |
| 48 gfx::Point delta(1, 0); | 66 gfx::Point delta(1, 0); |
| 49 greg.ScrollRect(delta.x(), delta.y(), rect); | 67 greg.ScrollRect(delta.x(), delta.y(), rect); |
| 50 | 68 |
| 51 EXPECT_TRUE(greg.HasPendingUpdate()); | 69 EXPECT_TRUE(greg.HasPendingUpdate()); |
| 52 EXPECT_TRUE(greg.GetPendingUpdate().paint_rects.empty()); | 70 EXPECT_TRUE(greg.GetPendingUpdate().paint_rects.empty()); |
| 53 EXPECT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 71 EXPECT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 gfx::Rect expected_scroll_damage(0, 0, 4, 10); | 381 gfx::Rect expected_scroll_damage(0, 0, 4, 10); |
| 364 | 382 |
| 365 EXPECT_TRUE(greg.HasPendingUpdate()); | 383 EXPECT_TRUE(greg.HasPendingUpdate()); |
| 366 | 384 |
| 367 EXPECT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); | 385 EXPECT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty()); |
| 368 EXPECT_TRUE(greg.GetPendingUpdate().paint_rects.empty()); | 386 EXPECT_TRUE(greg.GetPendingUpdate().paint_rects.empty()); |
| 369 | 387 |
| 370 EXPECT_EQ(scroll_rect, greg.GetPendingUpdate().scroll_rect); | 388 EXPECT_EQ(scroll_rect, greg.GetPendingUpdate().scroll_rect); |
| 371 EXPECT_EQ(expected_scroll_damage, greg.GetPendingUpdate().GetScrollDamage()); | 389 EXPECT_EQ(expected_scroll_damage, greg.GetPendingUpdate().GetScrollDamage()); |
| 372 } | 390 } |
| OLD | NEW |