OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "platform/graphics/paint/PaintChunker.h" |
| 7 |
| 8 #include <gmock/gmock.h> |
| 9 #include <gtest/gtest.h> |
| 10 |
| 11 using testing::ElementsAre; |
| 12 |
| 13 namespace blink { |
| 14 namespace { |
| 15 |
| 16 static PaintProperties samplePaintProperties() { return PaintProperties(); } |
| 17 |
| 18 template <typename T> |
| 19 static std::vector<T> toStdVector(const Vector<T>& vector) |
| 20 { |
| 21 return std::vector<T>(vector.begin(), vector.end()); |
| 22 } |
| 23 |
| 24 TEST(PaintChunkerTest, Empty) |
| 25 { |
| 26 Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks(); |
| 27 ASSERT_TRUE(chunks.isEmpty()); |
| 28 } |
| 29 |
| 30 TEST(PaintChunkerTest, SingleNonEmptyRange) |
| 31 { |
| 32 PaintChunker chunker; |
| 33 chunker.updateCurrentPaintProperties(samplePaintProperties()); |
| 34 chunker.incrementDisplayItemIndex(); |
| 35 chunker.incrementDisplayItemIndex(); |
| 36 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
| 37 |
| 38 EXPECT_THAT(toStdVector(chunks), ElementsAre( |
| 39 PaintChunk(0, 2, samplePaintProperties()))); |
| 40 } |
| 41 |
| 42 TEST(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) |
| 43 { |
| 44 PaintChunker chunker; |
| 45 chunker.updateCurrentPaintProperties(samplePaintProperties()); |
| 46 chunker.incrementDisplayItemIndex(); |
| 47 chunker.incrementDisplayItemIndex(); |
| 48 chunker.updateCurrentPaintProperties(samplePaintProperties()); |
| 49 chunker.incrementDisplayItemIndex(); |
| 50 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
| 51 |
| 52 EXPECT_THAT(toStdVector(chunks), ElementsAre( |
| 53 PaintChunk(0, 3, samplePaintProperties()))); |
| 54 } |
| 55 |
| 56 TEST(PaintChunkerTest, CanRewindDisplayItemIndex) |
| 57 { |
| 58 PaintChunker chunker; |
| 59 chunker.updateCurrentPaintProperties(samplePaintProperties()); |
| 60 chunker.incrementDisplayItemIndex(); |
| 61 chunker.incrementDisplayItemIndex(); |
| 62 chunker.decrementDisplayItemIndex(); |
| 63 chunker.incrementDisplayItemIndex(); |
| 64 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
| 65 |
| 66 EXPECT_THAT(toStdVector(chunks), ElementsAre( |
| 67 PaintChunk(0, 2, samplePaintProperties()))); |
| 68 } |
| 69 |
| 70 // TODO(jbroman): Add more tests one it is possible for there to be two distinct |
| 71 // PaintProperties. |
| 72 |
| 73 } // namespace |
| 74 } // namespace blink |
OLD | NEW |