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

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: Created 5 years, 3 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..329d27e1ab0ee9c21a394e865b028159fdf00b08
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
@@ -0,0 +1,74 @@
+// 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 <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using testing::ElementsAre;
+
+namespace blink {
+namespace {
+
+static PaintProperties samplePaintProperties() { return PaintProperties(); }
+
+template <typename T>
+static std::vector<T> toStdVector(const Vector<T>& vector)
+{
+ return std::vector<T>(vector.begin(), vector.end());
+}
+
+TEST(PaintChunkerTest, Empty)
+{
+ Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks();
+ ASSERT_TRUE(chunks.isEmpty());
+}
+
+TEST(PaintChunkerTest, SingleNonEmptyRange)
+{
+ PaintChunker chunker;
+ chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.incrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(toStdVector(chunks), ElementsAre(
pdr. 2015/10/01 00:32:48 This expect_that elementsAre pattern is cool.
jbroman 2015/10/01 18:04:20 Yeah, GMock is awesome. Better yet, the arguments
+ PaintChunk(0, 2, samplePaintProperties())));
+}
+
+TEST(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk)
+{
+ PaintChunker chunker;
+ chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.incrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+ chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.incrementDisplayItemIndex();
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(toStdVector(chunks), ElementsAre(
+ PaintChunk(0, 3, samplePaintProperties())));
+}
+
+TEST(PaintChunkerTest, CanRewindDisplayItemIndex)
+{
+ PaintChunker chunker;
+ chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.incrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+ chunker.decrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(toStdVector(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