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 "content/renderer/paint_aggregator.h" | 5 #include "content/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()); |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 TEST(PaintAggregator, DoubleDisjointInvalidation) { | 29 TEST(PaintAggregator, DoubleDisjointInvalidation) { |
30 PaintAggregator greg; | 30 PaintAggregator greg; |
31 | 31 |
32 gfx::Rect r1(2, 4, 2, 40); | 32 gfx::Rect r1(2, 4, 2, 40); |
33 gfx::Rect r2(4, 2, 40, 2); | 33 gfx::Rect r2(4, 2, 40, 2); |
34 | 34 |
35 greg.InvalidateRect(r1); | 35 greg.InvalidateRect(r1); |
36 greg.InvalidateRect(r2); | 36 greg.InvalidateRect(r2); |
37 | 37 |
38 gfx::Rect expected_bounds = r1.Union(r2); | 38 gfx::Rect expected_bounds = r1; |
| 39 expected_bounds.Union(r2); |
39 | 40 |
40 EXPECT_TRUE(greg.HasPendingUpdate()); | 41 EXPECT_TRUE(greg.HasPendingUpdate()); |
41 PaintAggregator::PendingUpdate update; | 42 PaintAggregator::PendingUpdate update; |
42 greg.PopPendingUpdate(&update); | 43 greg.PopPendingUpdate(&update); |
43 | 44 |
44 EXPECT_TRUE(update.scroll_rect.IsEmpty()); | 45 EXPECT_TRUE(update.scroll_rect.IsEmpty()); |
45 EXPECT_EQ(2U, update.paint_rects.size()); | 46 EXPECT_EQ(2U, update.paint_rects.size()); |
46 | 47 |
47 EXPECT_EQ(expected_bounds, update.GetPaintBounds()); | 48 EXPECT_EQ(expected_bounds, update.GetPaintBounds()); |
48 } | 49 } |
49 | 50 |
50 TEST(PaintAggregator, DisjointInvalidationsCombined) { | 51 TEST(PaintAggregator, DisjointInvalidationsCombined) { |
51 PaintAggregator greg; | 52 PaintAggregator greg; |
52 | 53 |
53 // Make the rectangles such that they don't overlap but cover a very large | 54 // Make the rectangles such that they don't overlap but cover a very large |
54 // percentage of the area of covered by their union. This is so we're not | 55 // percentage of the area of covered by their union. This is so we're not |
55 // very sensitive to the combining heuristic in the paint aggregator. | 56 // very sensitive to the combining heuristic in the paint aggregator. |
56 gfx::Rect r1(2, 4, 2, 1000); | 57 gfx::Rect r1(2, 4, 2, 1000); |
57 gfx::Rect r2(5, 2, 2, 1000); | 58 gfx::Rect r2(5, 2, 2, 1000); |
58 | 59 |
59 greg.InvalidateRect(r1); | 60 greg.InvalidateRect(r1); |
60 greg.InvalidateRect(r2); | 61 greg.InvalidateRect(r2); |
61 | 62 |
62 gfx::Rect expected_bounds = r1.Union(r2); | 63 gfx::Rect expected_bounds = r1; |
| 64 expected_bounds.Union(r2); |
63 | 65 |
64 EXPECT_TRUE(greg.HasPendingUpdate()); | 66 EXPECT_TRUE(greg.HasPendingUpdate()); |
65 PaintAggregator::PendingUpdate update; | 67 PaintAggregator::PendingUpdate update; |
66 greg.PopPendingUpdate(&update); | 68 greg.PopPendingUpdate(&update); |
67 | 69 |
68 EXPECT_TRUE(update.scroll_rect.IsEmpty()); | 70 EXPECT_TRUE(update.scroll_rect.IsEmpty()); |
69 ASSERT_EQ(1U, update.paint_rects.size()); | 71 ASSERT_EQ(1U, update.paint_rects.size()); |
70 | 72 |
71 EXPECT_EQ(expected_bounds, update.paint_rects[0]); | 73 EXPECT_EQ(expected_bounds, update.paint_rects[0]); |
72 } | 74 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 270 |
269 TEST(PaintAggregator, OverlappingPaintBeforeScroll) { | 271 TEST(PaintAggregator, OverlappingPaintBeforeScroll) { |
270 PaintAggregator greg; | 272 PaintAggregator greg; |
271 | 273 |
272 gfx::Rect paint_rect(4, 4, 10, 2); | 274 gfx::Rect paint_rect(4, 4, 10, 2); |
273 greg.InvalidateRect(paint_rect); | 275 greg.InvalidateRect(paint_rect); |
274 | 276 |
275 gfx::Rect scroll_rect(0, 0, 10, 10); | 277 gfx::Rect scroll_rect(0, 0, 10, 10); |
276 greg.ScrollRect(2, 0, scroll_rect); | 278 greg.ScrollRect(2, 0, scroll_rect); |
277 | 279 |
278 gfx::Rect expected_paint_rect = scroll_rect.Union(paint_rect); | 280 gfx::Rect expected_paint_rect = scroll_rect; |
| 281 expected_paint_rect.Union(paint_rect); |
279 | 282 |
280 EXPECT_TRUE(greg.HasPendingUpdate()); | 283 EXPECT_TRUE(greg.HasPendingUpdate()); |
281 PaintAggregator::PendingUpdate update; | 284 PaintAggregator::PendingUpdate update; |
282 greg.PopPendingUpdate(&update); | 285 greg.PopPendingUpdate(&update); |
283 | 286 |
284 EXPECT_TRUE(update.scroll_rect.IsEmpty()); | 287 EXPECT_TRUE(update.scroll_rect.IsEmpty()); |
285 EXPECT_EQ(1U, update.paint_rects.size()); | 288 EXPECT_EQ(1U, update.paint_rects.size()); |
286 | 289 |
287 EXPECT_EQ(expected_paint_rect, update.paint_rects[0]); | 290 EXPECT_EQ(expected_paint_rect, update.paint_rects[0]); |
288 } | 291 } |
289 | 292 |
290 TEST(PaintAggregator, OverlappingPaintAfterScroll) { | 293 TEST(PaintAggregator, OverlappingPaintAfterScroll) { |
291 PaintAggregator greg; | 294 PaintAggregator greg; |
292 | 295 |
293 gfx::Rect scroll_rect(0, 0, 10, 10); | 296 gfx::Rect scroll_rect(0, 0, 10, 10); |
294 greg.ScrollRect(2, 0, scroll_rect); | 297 greg.ScrollRect(2, 0, scroll_rect); |
295 | 298 |
296 gfx::Rect paint_rect(4, 4, 10, 2); | 299 gfx::Rect paint_rect(4, 4, 10, 2); |
297 greg.InvalidateRect(paint_rect); | 300 greg.InvalidateRect(paint_rect); |
298 | 301 |
299 gfx::Rect expected_paint_rect = scroll_rect.Union(paint_rect); | 302 gfx::Rect expected_paint_rect = scroll_rect; |
| 303 expected_paint_rect.Union(paint_rect); |
300 | 304 |
301 EXPECT_TRUE(greg.HasPendingUpdate()); | 305 EXPECT_TRUE(greg.HasPendingUpdate()); |
302 PaintAggregator::PendingUpdate update; | 306 PaintAggregator::PendingUpdate update; |
303 greg.PopPendingUpdate(&update); | 307 greg.PopPendingUpdate(&update); |
304 | 308 |
305 EXPECT_TRUE(update.scroll_rect.IsEmpty()); | 309 EXPECT_TRUE(update.scroll_rect.IsEmpty()); |
306 EXPECT_EQ(1U, update.paint_rects.size()); | 310 EXPECT_EQ(1U, update.paint_rects.size()); |
307 | 311 |
308 EXPECT_EQ(expected_paint_rect, update.paint_rects[0]); | 312 EXPECT_EQ(expected_paint_rect, update.paint_rects[0]); |
309 } | 313 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 EXPECT_TRUE(greg.HasPendingUpdate()); | 432 EXPECT_TRUE(greg.HasPendingUpdate()); |
429 PaintAggregator::PendingUpdate update; | 433 PaintAggregator::PendingUpdate update; |
430 greg.PopPendingUpdate(&update); | 434 greg.PopPendingUpdate(&update); |
431 | 435 |
432 EXPECT_FALSE(update.scroll_rect.IsEmpty()); | 436 EXPECT_FALSE(update.scroll_rect.IsEmpty()); |
433 EXPECT_TRUE(update.paint_rects.empty()); | 437 EXPECT_TRUE(update.paint_rects.empty()); |
434 | 438 |
435 EXPECT_EQ(scroll_rect, update.scroll_rect); | 439 EXPECT_EQ(scroll_rect, update.scroll_rect); |
436 EXPECT_EQ(expected_scroll_damage, update.GetScrollDamage()); | 440 EXPECT_EQ(expected_scroll_damage, update.GetScrollDamage()); |
437 } | 441 } |
OLD | NEW |