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

Side by Side Diff: Source/core/css/invalidation/DescendantInvalidationSetTest.cpp

Issue 1317533002: Sibling invalidation sets (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 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
(Empty)
1 // Copyright 2014 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 "core/css/invalidation/DescendantInvalidationSet.h"
7
8 #include <gtest/gtest.h>
9
10 namespace blink {
11
12 // Once we setWholeSubtreeInvalid, we should not keep the HashSets.
13 TEST(DescendantInvalidationSetTest, SubtreeInvalid_AddBefore)
14 {
15 RefPtrWillBeRawPtr<DescendantInvalidationSet> set = DescendantInvalidationSe t::create();
16 set->addClass("a");
17 set->setWholeSubtreeInvalid();
18
19 ASSERT_TRUE(set->isEmpty());
20 }
21
22 // Don't (re)create HashSets if we've already setWholeSubtreeInvalid.
23 TEST(DescendantInvalidationSetTest, SubtreeInvalid_AddAfter)
24 {
25 RefPtrWillBeRawPtr<DescendantInvalidationSet> set = DescendantInvalidationSe t::create();
26 set->setWholeSubtreeInvalid();
27 set->addTagName("a");
28
29 ASSERT_TRUE(set->isEmpty());
30 }
31
32 // No need to keep the HashSets when combining with a wholeSubtreeInvalid set.
33 TEST(DescendantInvalidationSetTest, SubtreeInvalid_Combine_1)
34 {
35 RefPtrWillBeRawPtr<DescendantInvalidationSet> set1 = DescendantInvalidationS et::create();
36 RefPtrWillBeRawPtr<DescendantInvalidationSet> set2 = DescendantInvalidationS et::create();
37
38 set1->addId("a");
39 set2->setWholeSubtreeInvalid();
40
41 set1->combine(*set2);
42
43 ASSERT_TRUE(set1->wholeSubtreeInvalid());
44 ASSERT_TRUE(set1->isEmpty());
45 }
46
47 // No need to add HashSets from combining set when we already have wholeSubtreeI nvalid.
48 TEST(DescendantInvalidationSetTest, SubtreeInvalid_Combine_2)
49 {
50 RefPtrWillBeRawPtr<DescendantInvalidationSet> set1 = DescendantInvalidationS et::create();
51 RefPtrWillBeRawPtr<DescendantInvalidationSet> set2 = DescendantInvalidationS et::create();
52
53 set1->setWholeSubtreeInvalid();
54 set2->addAttribute("a");
55
56 set1->combine(*set2);
57
58 ASSERT_TRUE(set1->wholeSubtreeInvalid());
59 ASSERT_TRUE(set1->isEmpty());
60 }
61
62 TEST(DescendantInvalidationSetTest, SubtreeInvalid_AddCustomPseudoBefore)
63 {
64 RefPtrWillBeRawPtr<DescendantInvalidationSet> set = DescendantInvalidationSe t::create();
65 set->setCustomPseudoInvalid();
66 ASSERT_FALSE(set->isEmpty());
67
68 set->setWholeSubtreeInvalid();
69 ASSERT_TRUE(set->isEmpty());
70 }
71
72 #ifndef NDEBUG
73 TEST(DescendantInvalidationSetTest, ShowDebug)
74 {
75 RefPtrWillBeRawPtr<DescendantInvalidationSet> set = DescendantInvalidationSe t::create();
76 set->show();
77 }
78 #endif // NDEBUG
79
80 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698