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

Side by Side Diff: third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollectionTest.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/dom/TreeScopeStyleSheetCollection.h" 5 #include "core/dom/TreeScopeStyleSheetCollection.h"
6 6
7 #include "core/css/CSSStyleSheet.h" 7 #include "core/css/CSSStyleSheet.h"
8 #include "core/css/StyleSheetContents.h" 8 #include "core/css/StyleSheetContents.h"
9 #include "core/css/parser/CSSParserMode.h" 9 #include "core/css/parser/CSSParserMode.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class TreeScopeStyleSheetCollectionTest : public testing::Test { 14 class TreeScopeStyleSheetCollectionTest : public testing::Test {
15 protected: 15 protected:
16 using SheetVector = WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>>; 16 using SheetVector = HeapVector<Member<CSSStyleSheet>>;
17 using ContentsVector = WillBeHeapVector<RawPtrWillBeMember<StyleSheetContent s>>; 17 using ContentsVector = HeapVector<Member<StyleSheetContents>>;
18 18
19 enum UpdateType { 19 enum UpdateType {
20 Reconstruct = TreeScopeStyleSheetCollection::Reconstruct, 20 Reconstruct = TreeScopeStyleSheetCollection::Reconstruct,
21 Reset = TreeScopeStyleSheetCollection::Reset, 21 Reset = TreeScopeStyleSheetCollection::Reset,
22 Additive = TreeScopeStyleSheetCollection::Additive 22 Additive = TreeScopeStyleSheetCollection::Additive
23 }; 23 };
24 24
25 static PassRefPtrWillBeRawPtr<CSSStyleSheet> createSheet() 25 static RawPtr<CSSStyleSheet> createSheet()
26 { 26 {
27 return CSSStyleSheet::create(StyleSheetContents::create(CSSParserContext (HTMLStandardMode, nullptr))); 27 return CSSStyleSheet::create(StyleSheetContents::create(CSSParserContext (HTMLStandardMode, nullptr)));
28 } 28 }
29 29
30 static void compareStyleSheets(const SheetVector& oldStyleSheets, const Shee tVector& newStyleSheets, const ContentsVector& expAddedSheets, UpdateType testUp dateType) 30 static void compareStyleSheets(const SheetVector& oldStyleSheets, const Shee tVector& newStyleSheets, const ContentsVector& expAddedSheets, UpdateType testUp dateType)
31 { 31 {
32 ContentsVector addedSheets; 32 ContentsVector addedSheets;
33 UpdateType updateType = static_cast<UpdateType>(TreeScopeStyleSheetColle ction::compareStyleSheets(oldStyleSheets, newStyleSheets, addedSheets)); 33 UpdateType updateType = static_cast<UpdateType>(TreeScopeStyleSheetColle ction::compareStyleSheets(oldStyleSheets, newStyleSheets, addedSheets));
34 EXPECT_EQ(testUpdateType, updateType); 34 EXPECT_EQ(testUpdateType, updateType);
35 EXPECT_EQ(expAddedSheets.size(), addedSheets.size()); 35 EXPECT_EQ(expAddedSheets.size(), addedSheets.size());
36 if (expAddedSheets.size() == addedSheets.size()) { 36 if (expAddedSheets.size() == addedSheets.size()) {
37 for (unsigned i = 0; i < addedSheets.size(); i++) 37 for (unsigned i = 0; i < addedSheets.size(); i++)
38 EXPECT_EQ(expAddedSheets.at(i), addedSheets.at(i)); 38 EXPECT_EQ(expAddedSheets.at(i), addedSheets.at(i));
39 } 39 }
40 } 40 }
41 }; 41 };
42 42
43 TEST_F(TreeScopeStyleSheetCollectionTest, CompareStyleSheetsAppend) 43 TEST_F(TreeScopeStyleSheetCollectionTest, CompareStyleSheetsAppend)
44 { 44 {
45 RefPtrWillBeRawPtr<CSSStyleSheet> sheet1 = createSheet(); 45 RawPtr<CSSStyleSheet> sheet1 = createSheet();
46 RefPtrWillBeRawPtr<CSSStyleSheet> sheet2 = createSheet(); 46 RawPtr<CSSStyleSheet> sheet2 = createSheet();
47 47
48 ContentsVector added; 48 ContentsVector added;
49 SheetVector previous; 49 SheetVector previous;
50 SheetVector current; 50 SheetVector current;
51 51
52 previous.append(sheet1); 52 previous.append(sheet1);
53 53
54 current.append(sheet1); 54 current.append(sheet1);
55 current.append(sheet2); 55 current.append(sheet2);
56 56
57 added.append(sheet2->contents()); 57 added.append(sheet2->contents());
58 58
59 compareStyleSheets(previous, current, added, Additive); 59 compareStyleSheets(previous, current, added, Additive);
60 } 60 }
61 61
62 TEST_F(TreeScopeStyleSheetCollectionTest, CompareStyleSheetsPrepend) 62 TEST_F(TreeScopeStyleSheetCollectionTest, CompareStyleSheetsPrepend)
63 { 63 {
64 RefPtrWillBeRawPtr<CSSStyleSheet> sheet1 = createSheet(); 64 RawPtr<CSSStyleSheet> sheet1 = createSheet();
65 RefPtrWillBeRawPtr<CSSStyleSheet> sheet2 = createSheet(); 65 RawPtr<CSSStyleSheet> sheet2 = createSheet();
66 66
67 ContentsVector added; 67 ContentsVector added;
68 SheetVector previous; 68 SheetVector previous;
69 SheetVector current; 69 SheetVector current;
70 70
71 previous.append(sheet2); 71 previous.append(sheet2);
72 72
73 current.append(sheet1); 73 current.append(sheet1);
74 current.append(sheet2); 74 current.append(sheet2);
75 75
76 added.append(sheet1->contents()); 76 added.append(sheet1->contents());
77 77
78 compareStyleSheets(previous, current, added, Reconstruct); 78 compareStyleSheets(previous, current, added, Reconstruct);
79 } 79 }
80 80
81 TEST_F(TreeScopeStyleSheetCollectionTest, CompareStyleSheetsInsert) 81 TEST_F(TreeScopeStyleSheetCollectionTest, CompareStyleSheetsInsert)
82 { 82 {
83 RefPtrWillBeRawPtr<CSSStyleSheet> sheet1 = createSheet(); 83 RawPtr<CSSStyleSheet> sheet1 = createSheet();
84 RefPtrWillBeRawPtr<CSSStyleSheet> sheet2 = createSheet(); 84 RawPtr<CSSStyleSheet> sheet2 = createSheet();
85 RefPtrWillBeRawPtr<CSSStyleSheet> sheet3 = createSheet(); 85 RawPtr<CSSStyleSheet> sheet3 = createSheet();
86 86
87 ContentsVector added; 87 ContentsVector added;
88 SheetVector previous; 88 SheetVector previous;
89 SheetVector current; 89 SheetVector current;
90 90
91 previous.append(sheet1); 91 previous.append(sheet1);
92 previous.append(sheet3); 92 previous.append(sheet3);
93 93
94 current.append(sheet1); 94 current.append(sheet1);
95 current.append(sheet2); 95 current.append(sheet2);
96 current.append(sheet3); 96 current.append(sheet3);
97 97
98 added.append(sheet2->contents()); 98 added.append(sheet2->contents());
99 99
100 compareStyleSheets(previous, current, added, Reconstruct); 100 compareStyleSheets(previous, current, added, Reconstruct);
101 } 101 }
102 102
103 TEST_F(TreeScopeStyleSheetCollectionTest, CompareStyleSheetsRemove) 103 TEST_F(TreeScopeStyleSheetCollectionTest, CompareStyleSheetsRemove)
104 { 104 {
105 RefPtrWillBeRawPtr<CSSStyleSheet> sheet1 = createSheet(); 105 RawPtr<CSSStyleSheet> sheet1 = createSheet();
106 RefPtrWillBeRawPtr<CSSStyleSheet> sheet2 = createSheet(); 106 RawPtr<CSSStyleSheet> sheet2 = createSheet();
107 RefPtrWillBeRawPtr<CSSStyleSheet> sheet3 = createSheet(); 107 RawPtr<CSSStyleSheet> sheet3 = createSheet();
108 108
109 ContentsVector added; 109 ContentsVector added;
110 SheetVector previous; 110 SheetVector previous;
111 SheetVector current; 111 SheetVector current;
112 112
113 previous.append(sheet1); 113 previous.append(sheet1);
114 previous.append(sheet2); 114 previous.append(sheet2);
115 previous.append(sheet3); 115 previous.append(sheet3);
116 116
117 current.append(sheet1); 117 current.append(sheet1);
118 current.append(sheet3); 118 current.append(sheet3);
119 119
120 added.append(sheet2->contents()); 120 added.append(sheet2->contents());
121 121
122 // This is really the same as Insert. TreeScopeStyleSheetCollection::compare StyleSheets 122 // This is really the same as Insert. TreeScopeStyleSheetCollection::compare StyleSheets
123 // will assert if you pass an array that is longer as the first parameter. 123 // will assert if you pass an array that is longer as the first parameter.
124 compareStyleSheets(current, previous, added, Reconstruct); 124 compareStyleSheets(current, previous, added, Reconstruct);
125 } 125 }
126 126
127 TEST_F(TreeScopeStyleSheetCollectionTest, CompareStyleSheetsInsertRemove) 127 TEST_F(TreeScopeStyleSheetCollectionTest, CompareStyleSheetsInsertRemove)
128 { 128 {
129 RefPtrWillBeRawPtr<CSSStyleSheet> sheet1 = createSheet(); 129 RawPtr<CSSStyleSheet> sheet1 = createSheet();
130 RefPtrWillBeRawPtr<CSSStyleSheet> sheet2 = createSheet(); 130 RawPtr<CSSStyleSheet> sheet2 = createSheet();
131 RefPtrWillBeRawPtr<CSSStyleSheet> sheet3 = createSheet(); 131 RawPtr<CSSStyleSheet> sheet3 = createSheet();
132 132
133 ContentsVector added; 133 ContentsVector added;
134 SheetVector previous; 134 SheetVector previous;
135 SheetVector current; 135 SheetVector current;
136 136
137 previous.append(sheet1); 137 previous.append(sheet1);
138 previous.append(sheet2); 138 previous.append(sheet2);
139 139
140 current.append(sheet2); 140 current.append(sheet2);
141 current.append(sheet3); 141 current.append(sheet3);
142 142
143 // TODO(rune@opera.com): This is clearly wrong. We add sheet3 and remove she et1 and 143 // TODO(rune@opera.com): This is clearly wrong. We add sheet3 and remove she et1 and
144 // compareStyleSheets returns sheet2 and sheet3 as added (crbug/475858). 144 // compareStyleSheets returns sheet2 and sheet3 as added (crbug/475858).
145 added.append(sheet2->contents()); 145 added.append(sheet2->contents());
146 added.append(sheet3->contents()); 146 added.append(sheet3->contents());
147 147
148 compareStyleSheets(previous, current, added, Reconstruct); 148 compareStyleSheets(previous, current, added, Reconstruct);
149 } 149 }
150 150
151 } // namespace blink 151 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698