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

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

Issue 2116693002: PaintChunk::id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@CommitOnTheWay
Patch Set: - Created 4 years, 5 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 2016 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 "platform/graphics/paint/PaintChunk.h"
6
7 #include "platform/RuntimeEnabledFeatures.h"
8 #include "platform/testing/FakeDisplayItemClient.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "wtf/Optional.h"
11
12 namespace blink {
13
14 TEST(PaintChunkTest, IdMatchesSame)
15 {
16 PaintChunkProperties properties;
17 FakeDisplayItemClient client;
18 client.updateCacheGeneration();
19 DisplayItem::Id id(client, DisplayItem::DrawingFirst);
20 EXPECT_TRUE(PaintChunk(0, 1, &id, properties).idMatches(PaintChunk(0, 1, &id , properties)));
21 }
22
23 TEST(PaintChunkTest, IdMatchesEqual)
24 {
25 PaintChunkProperties properties;
26 FakeDisplayItemClient client;
27 client.updateCacheGeneration();
28 DisplayItem::Id id(client, DisplayItem::DrawingFirst);
29 DisplayItem::Id idEqual = id;
30 EXPECT_TRUE(PaintChunk(0, 1, &id, properties).idMatches(PaintChunk(0, 1, &id Equal, properties)));
31 EXPECT_TRUE(PaintChunk(0, 1, &idEqual, properties).idMatches(PaintChunk(0, 1 , &id, properties)));
32 }
33
34 TEST(PaintChunkTest, IdNotMatches)
35 {
36 PaintChunkProperties properties;
37 FakeDisplayItemClient client1;
38 client1.updateCacheGeneration();
39 DisplayItem::Id id1a(client1, DisplayItem::DrawingFirst);
40 DisplayItem::Id id1b(client1, DisplayItem::Subsequence);
41 EXPECT_FALSE(PaintChunk(0, 1, &id1a, properties).idMatches(PaintChunk(0, 1, &id1b, properties)));
42 EXPECT_FALSE(PaintChunk(0, 1, &id1b, properties).idMatches(PaintChunk(0, 1, &id1a, properties)));
43
44 FakeDisplayItemClient client2;
45 client2.updateCacheGeneration();
46 DisplayItem::Id id2(client2, DisplayItem::DrawingFirst);
47 EXPECT_FALSE(PaintChunk(0, 1, &id1a, properties).idMatches(PaintChunk(0, 1, &id2, properties)));
48 EXPECT_FALSE(PaintChunk(0, 1, &id2, properties).idMatches(PaintChunk(0, 1, & id1a, properties)));
49 }
50
51 TEST(PaintChunkTest, IdNotMatchesNull)
52 {
53 PaintChunkProperties properties;
54 FakeDisplayItemClient client;
55 client.updateCacheGeneration();
56 DisplayItem::Id id(client, DisplayItem::DrawingFirst);
57 EXPECT_FALSE(PaintChunk(0, 1, nullptr, properties).idMatches(PaintChunk(0, 1 , &id, properties)));
58 EXPECT_FALSE(PaintChunk(0, 1, &id, properties).idMatches(PaintChunk(0, 1, nu llptr, properties)));
59 EXPECT_FALSE(PaintChunk(0, 1, nullptr, properties).idMatches(PaintChunk(0, 1 , nullptr, properties)));
60 }
61
62 TEST(PaintChunkTest, IdNotMatchesJustCreated)
63 {
64 PaintChunkProperties properties;
65 Optional<FakeDisplayItemClient> client;
66 client.emplace();
67 DisplayItem::Id id(*client, DisplayItem::DrawingFirst);
68 // A chunk of a newly create client doesn't match any chunk because it's nev er cached.
69 EXPECT_FALSE(PaintChunk(0, 1, &id, properties).idMatches(PaintChunk(0, 1, &i d, properties)));
70
71 client->updateCacheGeneration();
72 EXPECT_TRUE(PaintChunk(0, 1, &id, properties).idMatches(PaintChunk(0, 1, &id , properties)));
73
74 // Delete the current object and create a new object is created at the same address.
75 client = WTF::nullopt;
76 client.emplace();
77 EXPECT_FALSE(PaintChunk(0, 1, &id, properties).idMatches(PaintChunk(0, 1, &i d, properties)));
78 }
79
80 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698