| OLD | NEW |
| (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/analyzer/DescendantInvalidationSet.h" | |
| 7 | |
| 8 #include <gtest/gtest.h> | |
| 9 | |
| 10 using namespace WebCore; | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 // Once we setWholeSubtreeInvalid, we should not keep the HashSets. | |
| 15 TEST(DescendantInvalidationSetTest, SubtreeInvalid_AddBefore) | |
| 16 { | |
| 17 RefPtr<DescendantInvalidationSet> set = DescendantInvalidationSet::create(); | |
| 18 set->addClass("a"); | |
| 19 set->setWholeSubtreeInvalid(); | |
| 20 | |
| 21 Vector<AtomicString> classes; | |
| 22 set->getClasses(classes); | |
| 23 | |
| 24 ASSERT_TRUE(classes.isEmpty()); | |
| 25 } | |
| 26 | |
| 27 // Don't (re)create HashSets if we've already setWholeSubtreeInvalid. | |
| 28 TEST(DescendantInvalidationSetTest, SubtreeInvalid_AddAfter) | |
| 29 { | |
| 30 RefPtr<DescendantInvalidationSet> set = DescendantInvalidationSet::create(); | |
| 31 set->setWholeSubtreeInvalid(); | |
| 32 set->addClass("a"); | |
| 33 | |
| 34 Vector<AtomicString> classes; | |
| 35 set->getClasses(classes); | |
| 36 | |
| 37 ASSERT_TRUE(classes.isEmpty()); | |
| 38 } | |
| 39 | |
| 40 // No need to keep the HashSets when combining with a wholeSubtreeInvalid set. | |
| 41 TEST(DescendantInvalidationSetTest, SubtreeInvalid_Combine_1) | |
| 42 { | |
| 43 RefPtr<DescendantInvalidationSet> set1 = DescendantInvalidationSet::create()
; | |
| 44 RefPtr<DescendantInvalidationSet> set2 = DescendantInvalidationSet::create()
; | |
| 45 | |
| 46 set1->addClass("a"); | |
| 47 set2->setWholeSubtreeInvalid(); | |
| 48 | |
| 49 set1->combine(*set2); | |
| 50 | |
| 51 Vector<AtomicString> classes; | |
| 52 set1->getClasses(classes); | |
| 53 | |
| 54 ASSERT_TRUE(set1->wholeSubtreeInvalid()); | |
| 55 ASSERT_TRUE(classes.isEmpty()); | |
| 56 } | |
| 57 | |
| 58 // No need to add HashSets from combining set when we already have wholeSubtreeI
nvalid. | |
| 59 TEST(DescendantInvalidationSetTest, SubtreeInvalid_Combine_2) | |
| 60 { | |
| 61 RefPtr<DescendantInvalidationSet> set1 = DescendantInvalidationSet::create()
; | |
| 62 RefPtr<DescendantInvalidationSet> set2 = DescendantInvalidationSet::create()
; | |
| 63 | |
| 64 set1->setWholeSubtreeInvalid(); | |
| 65 set2->addClass("a"); | |
| 66 | |
| 67 set1->combine(*set2); | |
| 68 | |
| 69 Vector<AtomicString> classes; | |
| 70 set1->getClasses(classes); | |
| 71 | |
| 72 ASSERT_TRUE(set1->wholeSubtreeInvalid()); | |
| 73 ASSERT_TRUE(classes.isEmpty()); | |
| 74 } | |
| 75 | |
| 76 } // namespace | |
| OLD | NEW |