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.
6 #include "core/css/invalidation/DescendantInvalidationSet.h"
8 #include <gtest/gtest.h>
10 using namespace WebCore;
14 // Once we setWholeSubtreeInvalid, we should not keep the HashSets.
15 TEST(DescendantInvalidationSetTest, SubtreeInvalid_AddBefore)
17 RefPtrWillBeRawPtr<DescendantInvalidationSet> set = DescendantInvalidationSet::create();
19 set->setWholeSubtreeInvalid();
21 ASSERT_TRUE(set->isEmpty());
24 // Don't (re)create HashSets if we've already setWholeSubtreeInvalid.
25 TEST(DescendantInvalidationSetTest, SubtreeInvalid_AddAfter)
27 RefPtrWillBeRawPtr<DescendantInvalidationSet> set = DescendantInvalidationSet::create();
28 set->setWholeSubtreeInvalid();
31 ASSERT_TRUE(set->isEmpty());
34 // No need to keep the HashSets when combining with a wholeSubtreeInvalid set.
35 TEST(DescendantInvalidationSetTest, SubtreeInvalid_Combine_1)
37 RefPtrWillBeRawPtr<DescendantInvalidationSet> set1 = DescendantInvalidationSet::create();
38 RefPtrWillBeRawPtr<DescendantInvalidationSet> set2 = DescendantInvalidationSet::create();
41 set2->setWholeSubtreeInvalid();
45 ASSERT_TRUE(set1->wholeSubtreeInvalid());
46 ASSERT_TRUE(set1->isEmpty());
49 // No need to add HashSets from combining set when we already have wholeSubtreeInvalid.
50 TEST(DescendantInvalidationSetTest, SubtreeInvalid_Combine_2)
52 RefPtrWillBeRawPtr<DescendantInvalidationSet> set1 = DescendantInvalidationSet::create();
53 RefPtrWillBeRawPtr<DescendantInvalidationSet> set2 = DescendantInvalidationSet::create();
55 set1->setWholeSubtreeInvalid();
56 set2->addAttribute("a");
60 ASSERT_TRUE(set1->wholeSubtreeInvalid());
61 ASSERT_TRUE(set1->isEmpty());