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

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp

Issue 1379883003: Create PaintChunk and begin writing code to build paint chunks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enable RuntimeEnabledFeature for PaintChunkerTest Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..38be4a4e2c804612d0a7c9e67f5c6d0b1b98715b
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
@@ -0,0 +1,85 @@
+// Copyright 2015 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 "config.h"
+#include "platform/graphics/paint/PaintChunker.h"
+
+#include "platform/RuntimeEnabledFeatures.h"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using testing::ElementsAre;
+
+namespace blink {
+namespace {
+
+static PaintProperties samplePaintProperties() { return PaintProperties(); }
+
+class PaintChunkerTest : public testing::Test {
+protected:
+ void SetUp() override
+ {
+ RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
+ }
+
+ void TearDown() override
+ {
+ m_featuresBackup.restore();
+ }
+
+private:
+ RuntimeEnabledFeatures::Backup m_featuresBackup;
+};
+
+TEST_F(PaintChunkerTest, Empty)
+{
+ Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks();
+ ASSERT_TRUE(chunks.isEmpty());
+}
+
+TEST_F(PaintChunkerTest, SingleNonEmptyRange)
+{
+ PaintChunker chunker;
+ chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.incrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 2, samplePaintProperties())));
+}
+
+TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk)
+{
+ PaintChunker chunker;
+ chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.incrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+ chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.incrementDisplayItemIndex();
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 3, samplePaintProperties())));
+}
+
+TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex)
+{
+ PaintChunker chunker;
+ chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.incrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+ chunker.decrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 2, samplePaintProperties())));
+}
+
+// TODO(jbroman): Add more tests one it is possible for there to be two distinct
+// PaintProperties.
+
+} // namespace
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698