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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 "platform/RuntimeEnabledFeatures.h"
9 #include <gmock/gmock.h>
10 #include <gtest/gtest.h>
11
12 using testing::ElementsAre;
13
14 namespace blink {
15 namespace {
16
17 static PaintProperties samplePaintProperties() { return PaintProperties(); }
18
19 class PaintChunkerTest : public testing::Test {
20 protected:
21 void SetUp() override
22 {
23 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
24 }
25
26 void TearDown() override
27 {
28 m_featuresBackup.restore();
29 }
30
31 private:
32 RuntimeEnabledFeatures::Backup m_featuresBackup;
33 };
34
35 TEST_F(PaintChunkerTest, Empty)
36 {
37 Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks();
38 ASSERT_TRUE(chunks.isEmpty());
39 }
40
41 TEST_F(PaintChunkerTest, SingleNonEmptyRange)
42 {
43 PaintChunker chunker;
44 chunker.updateCurrentPaintProperties(samplePaintProperties());
45 chunker.incrementDisplayItemIndex();
46 chunker.incrementDisplayItemIndex();
47 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
48
49 EXPECT_THAT(chunks, ElementsAre(
50 PaintChunk(0, 2, samplePaintProperties())));
51 }
52
53 TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk)
54 {
55 PaintChunker chunker;
56 chunker.updateCurrentPaintProperties(samplePaintProperties());
57 chunker.incrementDisplayItemIndex();
58 chunker.incrementDisplayItemIndex();
59 chunker.updateCurrentPaintProperties(samplePaintProperties());
60 chunker.incrementDisplayItemIndex();
61 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
62
63 EXPECT_THAT(chunks, ElementsAre(
64 PaintChunk(0, 3, samplePaintProperties())));
65 }
66
67 TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex)
68 {
69 PaintChunker chunker;
70 chunker.updateCurrentPaintProperties(samplePaintProperties());
71 chunker.incrementDisplayItemIndex();
72 chunker.incrementDisplayItemIndex();
73 chunker.decrementDisplayItemIndex();
74 chunker.incrementDisplayItemIndex();
75 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
76
77 EXPECT_THAT(chunks, ElementsAre(
78 PaintChunk(0, 2, samplePaintProperties())));
79 }
80
81 // TODO(jbroman): Add more tests one it is possible for there to be two distinct
82 // PaintProperties.
83
84 } // namespace
85 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698