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