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

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

Issue 1390933003: Implement the framework for the paint property hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
index 38be4a4e2c804612d0a7c9e67f5c6d0b1b98715b..9b4ddf604ed85a2d0673cf36e13ea8a0b0caf926 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp
@@ -14,7 +14,7 @@ using testing::ElementsAre;
namespace blink {
namespace {
-static PaintProperties samplePaintProperties() { return PaintProperties(); }
+static PaintProperties rootPaintProperties() { return PaintProperties(); }
class PaintChunkerTest : public testing::Test {
protected:
@@ -41,33 +41,33 @@ TEST_F(PaintChunkerTest, Empty)
TEST_F(PaintChunkerTest, SingleNonEmptyRange)
{
PaintChunker chunker;
- chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
chunker.incrementDisplayItemIndex();
chunker.incrementDisplayItemIndex();
Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 2, samplePaintProperties())));
+ PaintChunk(0, 2, rootPaintProperties())));
}
TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk)
{
PaintChunker chunker;
- chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
chunker.incrementDisplayItemIndex();
chunker.incrementDisplayItemIndex();
- chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
chunker.incrementDisplayItemIndex();
Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 3, samplePaintProperties())));
+ PaintChunk(0, 3, rootPaintProperties())));
}
TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex)
{
PaintChunker chunker;
- chunker.updateCurrentPaintProperties(samplePaintProperties());
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
chunker.incrementDisplayItemIndex();
chunker.incrementDisplayItemIndex();
chunker.decrementDisplayItemIndex();
@@ -75,11 +75,61 @@ TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex)
Vector<PaintChunk> chunks = chunker.releasePaintChunks();
EXPECT_THAT(chunks, ElementsAre(
- PaintChunk(0, 2, samplePaintProperties())));
+ PaintChunk(0, 2, rootPaintProperties())));
}
-// TODO(jbroman): Add more tests one it is possible for there to be two distinct
-// PaintProperties.
+TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging)
+{
+ PaintChunker chunker;
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
+ chunker.incrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+
+ PaintProperties simpleTransform;
+ simpleTransform.transform = adoptRef(new TransformPaintProperty(TransformPaintProperty::Type::Transform, TransformationMatrix(), FloatPoint3D()));
jbroman 2015/10/07 15:22:22 nit: ::Type is unnecessary; enumerators exist in t
+ chunker.updateCurrentPaintProperties(simpleTransform);
+ chunker.incrementDisplayItemIndex();
+
+ PaintProperties anotherTransform;
+ anotherTransform.transform = adoptRef(new TransformPaintProperty(TransformPaintProperty::Type::Transform, TransformationMatrix(), FloatPoint3D()));
+ chunker.updateCurrentPaintProperties(anotherTransform);
+ chunker.incrementDisplayItemIndex();
+
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 2, rootPaintProperties()),
+ PaintChunk(2, 3, simpleTransform),
+ PaintChunk(3, 4, anotherTransform)));
+}
+
+TEST_F(PaintChunkerTest, BuildLinearChunksFromNestedTransforms)
+{
+ // Test that "nested" transforms linearize using the following
+ // sequence of transforms and display items:
+ // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>, </root xform>
+ PaintChunker chunker;
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
+ chunker.incrementDisplayItemIndex();
+
+ PaintProperties simpleTransform;
+ simpleTransform.transform = adoptRef(new TransformPaintProperty(TransformPaintProperty::Type::Transform, TransformationMatrix(), FloatPoint3D()));
+ chunker.updateCurrentPaintProperties(simpleTransform);
+ chunker.incrementDisplayItemIndex();
+ chunker.incrementDisplayItemIndex();
+
+ chunker.updateCurrentPaintProperties(rootPaintProperties());
+ chunker.incrementDisplayItemIndex();
+
+ Vector<PaintChunk> chunks = chunker.releasePaintChunks();
+
+ EXPECT_THAT(chunks, ElementsAre(
+ PaintChunk(0, 1, rootPaintProperties()),
+ PaintChunk(1, 3, simpleTransform),
+ PaintChunk(3, 4, rootPaintProperties())));
+}
+
+// TODO(pdr): Add more tests once we have more paint properties.
jbroman 2015/10/07 15:22:22 I'd also like tests for the case that trchen menti
pdr. 2015/10/07 20:19:11 Done
} // namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698