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

Unified Diff: chrome/renderer/paint_aggregator_unittest.cc

Issue 403005: Refactors RenderWidget to extract a PaintAggregator class.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/paint_aggregator.cc ('k') | chrome/renderer/render_widget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/paint_aggregator_unittest.cc
===================================================================
--- chrome/renderer/paint_aggregator_unittest.cc (revision 0)
+++ chrome/renderer/paint_aggregator_unittest.cc (revision 0)
@@ -0,0 +1,128 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/paint_aggregator.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(PaintAggregator, InitialState) {
+ PaintAggregator greg;
+ EXPECT_FALSE(greg.HasPendingUpdate());
+}
+
+TEST(PaintAggregator, SingleInvalidation) {
+ PaintAggregator greg;
+
+ gfx::Rect rect(2, 4, 10, 16);
+ greg.InvalidateRect(rect);
+
+ EXPECT_TRUE(greg.HasPendingUpdate());
+ EXPECT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty());
+ EXPECT_FALSE(greg.GetPendingUpdate().paint_rect.IsEmpty());
+
+ EXPECT_EQ(rect.x(), greg.GetPendingUpdate().paint_rect.x());
+ EXPECT_EQ(rect.y(), greg.GetPendingUpdate().paint_rect.y());
+ EXPECT_EQ(rect.width(), greg.GetPendingUpdate().paint_rect.width());
+ EXPECT_EQ(rect.height(), greg.GetPendingUpdate().paint_rect.height());
+}
+
+TEST(PaintAggregator, DoubleDisjointInvalidation) {
+ PaintAggregator greg;
+
+ gfx::Rect r1(2, 4, 2, 4);
+ gfx::Rect r2(4, 2, 4, 2);
+
+ greg.InvalidateRect(r1);
+ greg.InvalidateRect(r2);
+
+ gfx::Rect expected = r1.Union(r2);
+
+ EXPECT_TRUE(greg.HasPendingUpdate());
+ EXPECT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty());
+ EXPECT_FALSE(greg.GetPendingUpdate().paint_rect.IsEmpty());
+
+ EXPECT_EQ(expected.x(), greg.GetPendingUpdate().paint_rect.x());
+ EXPECT_EQ(expected.y(), greg.GetPendingUpdate().paint_rect.y());
+ EXPECT_EQ(expected.width(), greg.GetPendingUpdate().paint_rect.width());
+ EXPECT_EQ(expected.height(), greg.GetPendingUpdate().paint_rect.height());
+}
+
+TEST(PaintAggregator, SingleScroll) {
+ PaintAggregator greg;
+
+ gfx::Rect rect(1, 2, 3, 4);
+ gfx::Point delta(1, 0);
+ greg.ScrollRect(delta.x(), delta.y(), rect);
+
+ EXPECT_TRUE(greg.HasPendingUpdate());
+ EXPECT_TRUE(greg.GetPendingUpdate().paint_rect.IsEmpty());
+ EXPECT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty());
+
+ EXPECT_EQ(rect.x(), greg.GetPendingUpdate().scroll_rect.x());
+ EXPECT_EQ(rect.y(), greg.GetPendingUpdate().scroll_rect.y());
+ EXPECT_EQ(rect.width(), greg.GetPendingUpdate().scroll_rect.width());
+ EXPECT_EQ(rect.height(), greg.GetPendingUpdate().scroll_rect.height());
+
+ EXPECT_EQ(delta.x(), greg.GetPendingUpdate().scroll_delta.x());
+ EXPECT_EQ(delta.y(), greg.GetPendingUpdate().scroll_delta.y());
+
+ gfx::Rect resulting_damage = greg.GetPendingUpdate().GetScrollDamage();
+ gfx::Rect expected_damage(1, 2, 1, 4);
+ EXPECT_EQ(expected_damage.x(), resulting_damage.x());
+ EXPECT_EQ(expected_damage.y(), resulting_damage.y());
+ EXPECT_EQ(expected_damage.width(), resulting_damage.width());
+ EXPECT_EQ(expected_damage.height(), resulting_damage.height());
+}
+
+TEST(PaintAggregator, DoubleOverlappingScroll) {
+ PaintAggregator greg;
+
+ gfx::Rect rect(1, 2, 3, 4);
+ gfx::Point delta1(1, 0);
+ gfx::Point delta2(1, 0);
+ greg.ScrollRect(delta1.x(), delta1.y(), rect);
+ greg.ScrollRect(delta2.x(), delta2.y(), rect);
+
+ EXPECT_TRUE(greg.HasPendingUpdate());
+ EXPECT_TRUE(greg.GetPendingUpdate().paint_rect.IsEmpty());
+ EXPECT_FALSE(greg.GetPendingUpdate().scroll_rect.IsEmpty());
+
+ EXPECT_EQ(rect.x(), greg.GetPendingUpdate().scroll_rect.x());
+ EXPECT_EQ(rect.y(), greg.GetPendingUpdate().scroll_rect.y());
+ EXPECT_EQ(rect.width(), greg.GetPendingUpdate().scroll_rect.width());
+ EXPECT_EQ(rect.height(), greg.GetPendingUpdate().scroll_rect.height());
+
+ gfx::Point expected_delta(delta1.x() + delta2.x(),
+ delta1.y() + delta2.y());
+ EXPECT_EQ(expected_delta.x(), greg.GetPendingUpdate().scroll_delta.x());
+ EXPECT_EQ(expected_delta.y(), greg.GetPendingUpdate().scroll_delta.y());
+
+ gfx::Rect resulting_damage = greg.GetPendingUpdate().GetScrollDamage();
+ gfx::Rect expected_damage(1, 2, 2, 4);
+ EXPECT_EQ(expected_damage.x(), resulting_damage.x());
+ EXPECT_EQ(expected_damage.y(), resulting_damage.y());
+ EXPECT_EQ(expected_damage.width(), resulting_damage.width());
+ EXPECT_EQ(expected_damage.height(), resulting_damage.height());
+}
+
+TEST(PaintAggregator, DiagonalScroll) {
+ PaintAggregator greg;
+
+ // We don't support optimized diagonal scrolling, so this should result in
+ // repainting.
+
+ gfx::Rect rect(1, 2, 3, 4);
+ gfx::Point delta(1, 1);
+ greg.ScrollRect(delta.x(), delta.y(), rect);
+
+ EXPECT_TRUE(greg.HasPendingUpdate());
+ EXPECT_TRUE(greg.GetPendingUpdate().scroll_rect.IsEmpty());
+ EXPECT_FALSE(greg.GetPendingUpdate().paint_rect.IsEmpty());
+
+ EXPECT_EQ(rect.x(), greg.GetPendingUpdate().paint_rect.x());
+ EXPECT_EQ(rect.y(), greg.GetPendingUpdate().paint_rect.y());
+ EXPECT_EQ(rect.width(), greg.GetPendingUpdate().paint_rect.width());
+ EXPECT_EQ(rect.height(), greg.GetPendingUpdate().paint_rect.height());
+}
+
+// TODO(darin): Add tests for mixed scrolling and invalidation
Property changes on: chrome\renderer\paint_aggregator_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/renderer/paint_aggregator.cc ('k') | chrome/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698