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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintChunkTest.cpp

Issue 2286843002: Rename DisplayItem::Type enum constants to Chromium style. (Closed)
Patch Set: Rebasing... Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/paint/PaintChunk.h" 5 #include "platform/graphics/paint/PaintChunk.h"
6 6
7 #include "platform/RuntimeEnabledFeatures.h" 7 #include "platform/RuntimeEnabledFeatures.h"
8 #include "platform/testing/FakeDisplayItemClient.h" 8 #include "platform/testing/FakeDisplayItemClient.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "wtf/Optional.h" 10 #include "wtf/Optional.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 TEST(PaintChunkTest, matchesSame) 14 TEST(PaintChunkTest, matchesSame)
15 { 15 {
16 PaintChunkProperties properties; 16 PaintChunkProperties properties;
17 FakeDisplayItemClient client; 17 FakeDisplayItemClient client;
18 client.updateCacheGeneration(); 18 client.updateCacheGeneration();
19 DisplayItem::Id id(client, DisplayItem::DrawingFirst); 19 DisplayItem::Id id(client, DisplayItem::kDrawingFirst);
20 EXPECT_TRUE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, &id, properties))); 20 EXPECT_TRUE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, &id, properties)));
21 } 21 }
22 22
23 TEST(PaintChunkTest, matchesEqual) 23 TEST(PaintChunkTest, matchesEqual)
24 { 24 {
25 PaintChunkProperties properties; 25 PaintChunkProperties properties;
26 FakeDisplayItemClient client; 26 FakeDisplayItemClient client;
27 client.updateCacheGeneration(); 27 client.updateCacheGeneration();
28 DisplayItem::Id id(client, DisplayItem::DrawingFirst); 28 DisplayItem::Id id(client, DisplayItem::kDrawingFirst);
29 DisplayItem::Id idEqual = id; 29 DisplayItem::Id idEqual = id;
30 EXPECT_TRUE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, &idEq ual, properties))); 30 EXPECT_TRUE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, &idEq ual, properties)));
31 EXPECT_TRUE(PaintChunk(0, 1, &idEqual, properties).matches(PaintChunk(0, 1, &id, properties))); 31 EXPECT_TRUE(PaintChunk(0, 1, &idEqual, properties).matches(PaintChunk(0, 1, &id, properties)));
32 } 32 }
33 33
34 TEST(PaintChunkTest, IdNotMatches) 34 TEST(PaintChunkTest, IdNotMatches)
35 { 35 {
36 PaintChunkProperties properties; 36 PaintChunkProperties properties;
37 FakeDisplayItemClient client1; 37 FakeDisplayItemClient client1;
38 client1.updateCacheGeneration(); 38 client1.updateCacheGeneration();
39 DisplayItem::Id id1a(client1, DisplayItem::DrawingFirst); 39 DisplayItem::Id id1a(client1, DisplayItem::kDrawingFirst);
40 DisplayItem::Id id1b(client1, DisplayItem::Subsequence); 40 DisplayItem::Id id1b(client1, DisplayItem::kSubsequence);
41 EXPECT_FALSE(PaintChunk(0, 1, &id1a, properties).matches(PaintChunk(0, 1, &i d1b, properties))); 41 EXPECT_FALSE(PaintChunk(0, 1, &id1a, properties).matches(PaintChunk(0, 1, &i d1b, properties)));
42 EXPECT_FALSE(PaintChunk(0, 1, &id1b, properties).matches(PaintChunk(0, 1, &i d1a, properties))); 42 EXPECT_FALSE(PaintChunk(0, 1, &id1b, properties).matches(PaintChunk(0, 1, &i d1a, properties)));
43 43
44 FakeDisplayItemClient client2; 44 FakeDisplayItemClient client2;
45 client2.updateCacheGeneration(); 45 client2.updateCacheGeneration();
46 DisplayItem::Id id2(client2, DisplayItem::DrawingFirst); 46 DisplayItem::Id id2(client2, DisplayItem::kDrawingFirst);
47 EXPECT_FALSE(PaintChunk(0, 1, &id1a, properties).matches(PaintChunk(0, 1, &i d2, properties))); 47 EXPECT_FALSE(PaintChunk(0, 1, &id1a, properties).matches(PaintChunk(0, 1, &i d2, properties)));
48 EXPECT_FALSE(PaintChunk(0, 1, &id2, properties).matches(PaintChunk(0, 1, &id 1a, properties))); 48 EXPECT_FALSE(PaintChunk(0, 1, &id2, properties).matches(PaintChunk(0, 1, &id 1a, properties)));
49 } 49 }
50 50
51 TEST(PaintChunkTest, IdNotMatchesNull) 51 TEST(PaintChunkTest, IdNotMatchesNull)
52 { 52 {
53 PaintChunkProperties properties; 53 PaintChunkProperties properties;
54 FakeDisplayItemClient client; 54 FakeDisplayItemClient client;
55 client.updateCacheGeneration(); 55 client.updateCacheGeneration();
56 DisplayItem::Id id(client, DisplayItem::DrawingFirst); 56 DisplayItem::Id id(client, DisplayItem::kDrawingFirst);
57 EXPECT_FALSE(PaintChunk(0, 1, nullptr, properties).matches(PaintChunk(0, 1, &id, properties))); 57 EXPECT_FALSE(PaintChunk(0, 1, nullptr, properties).matches(PaintChunk(0, 1, &id, properties)));
58 EXPECT_FALSE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, null ptr, properties))); 58 EXPECT_FALSE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, null ptr, properties)));
59 EXPECT_FALSE(PaintChunk(0, 1, nullptr, properties).matches(PaintChunk(0, 1, nullptr, properties))); 59 EXPECT_FALSE(PaintChunk(0, 1, nullptr, properties).matches(PaintChunk(0, 1, nullptr, properties)));
60 } 60 }
61 61
62 TEST(PaintChunkTest, IdNotMatchesJustCreated) 62 TEST(PaintChunkTest, IdNotMatchesJustCreated)
63 { 63 {
64 PaintChunkProperties properties; 64 PaintChunkProperties properties;
65 Optional<FakeDisplayItemClient> client; 65 Optional<FakeDisplayItemClient> client;
66 client.emplace(); 66 client.emplace();
67 EXPECT_TRUE(client->isJustCreated()); 67 EXPECT_TRUE(client->isJustCreated());
68 // Invalidation won't change the "just created" status. 68 // Invalidation won't change the "just created" status.
69 client->setDisplayItemsUncached(); 69 client->setDisplayItemsUncached();
70 EXPECT_TRUE(client->isJustCreated()); 70 EXPECT_TRUE(client->isJustCreated());
71 71
72 DisplayItem::Id id(*client, DisplayItem::DrawingFirst); 72 DisplayItem::Id id(*client, DisplayItem::kDrawingFirst);
73 // A chunk of a newly created client doesn't match any chunk because it's ne ver cached. 73 // A chunk of a newly created client doesn't match any chunk because it's ne ver cached.
74 EXPECT_FALSE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, &id, properties))); 74 EXPECT_FALSE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, &id, properties)));
75 75
76 client->updateCacheGeneration(); 76 client->updateCacheGeneration();
77 EXPECT_TRUE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, &id, properties))); 77 EXPECT_TRUE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, &id, properties)));
78 78
79 // Delete the current object and create a new object at the same address. 79 // Delete the current object and create a new object at the same address.
80 client = WTF::nullopt; 80 client = WTF::nullopt;
81 client.emplace(); 81 client.emplace();
82 EXPECT_TRUE(client->isJustCreated()); 82 EXPECT_TRUE(client->isJustCreated());
83 EXPECT_FALSE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, &id, properties))); 83 EXPECT_FALSE(PaintChunk(0, 1, &id, properties).matches(PaintChunk(0, 1, &id, properties)));
84 } 84 }
85 85
86 } // namespace blink 86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698