| 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(
|
| + 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
|
|
|