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

Side by Side Diff: third_party/WebKit/Source/core/frame/UseCounterTest.cpp

Issue 2894063002: Expose UseCounter::Feature enum out of blink as WebFeature (Closed)
Patch Set: Rebase update Created 3 years, 6 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/frame/Deprecation.h" 5 #include "core/frame/Deprecation.h"
6 #include "core/frame/UseCounter.h" 6 #include "core/frame/UseCounter.h"
7 #include "core/page/Page.h" 7 #include "core/page/Page.h"
8 #include "core/testing/DummyPageHolder.h" 8 #include "core/testing/DummyPageHolder.h"
9 #include "platform/testing/HistogramTester.h" 9 #include "platform/testing/HistogramTester.h"
10 #include "platform/testing/URLTestHelpers.h" 10 #include "platform/testing/URLTestHelpers.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 histogram_tester.ExpectTotalCount( 146 histogram_tester.ExpectTotalCount(
147 unaffected_histogram, 147 unaffected_histogram,
148 0 + histogram_tester.GetBucketCount( 148 0 + histogram_tester.GetBucketCount(
149 unaffected_histogram, 149 unaffected_histogram,
150 GetPageVisitsBucketforHistogram(unaffected_histogram))); 150 GetPageVisitsBucketforHistogram(unaffected_histogram)));
151 } 151 }
152 } 152 }
153 153
154 TEST(UseCounterTest, RecordingFeatures) { 154 TEST(UseCounterTest, RecordingFeatures) {
155 UseCounter use_counter; 155 UseCounter use_counter;
156 HistogramBasicTest<UseCounter::Feature>( 156 HistogramBasicTest<WebFeature>(
157 kFeaturesHistogramName, kLegacyFeaturesHistogramName, UseCounter::kFetch, 157 kFeaturesHistogramName, kLegacyFeaturesHistogramName, WebFeature::kFetch,
158 UseCounter::kFetchBodyStream, 158 WebFeature::kFetchBodyStream,
159 [&](UseCounter::Feature feature) -> bool { 159 [&](WebFeature feature) -> bool {
160 return use_counter.HasRecordedMeasurement(feature); 160 return use_counter.HasRecordedMeasurement(feature);
161 }, 161 },
162 [&](UseCounter::Feature feature) { 162 [&](WebFeature feature) { use_counter.RecordMeasurement(feature); },
163 use_counter.RecordMeasurement(feature); 163 [](WebFeature feature) -> int { return static_cast<int>(feature); },
164 },
165 [](UseCounter::Feature feature) -> int { return feature; },
166 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kHttpsUrl); 164 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kHttpsUrl);
167 } 165 }
168 166
169 TEST(UseCounterTest, RecordingCSSProperties) { 167 TEST(UseCounterTest, RecordingCSSProperties) {
170 UseCounter use_counter; 168 UseCounter use_counter;
171 HistogramBasicTest<CSSPropertyID>( 169 HistogramBasicTest<CSSPropertyID>(
172 kCSSHistogramName, kLegacyCSSHistogramName, CSSPropertyFont, 170 kCSSHistogramName, kLegacyCSSHistogramName, CSSPropertyFont,
173 CSSPropertyZoom, 171 CSSPropertyZoom,
174 [&](CSSPropertyID property) -> bool { 172 [&](CSSPropertyID property) -> bool {
175 return use_counter.IsCounted(property); 173 return use_counter.IsCounted(property);
(...skipping 16 matching lines...) Expand all
192 }, 190 },
193 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); }, 191 [&](CSSPropertyID property) { use_counter.CountAnimatedCSS(property); },
194 [](CSSPropertyID property) -> int { 192 [](CSSPropertyID property) -> int {
195 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property); 193 return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property);
196 }, 194 },
197 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kHttpsUrl); 195 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kHttpsUrl);
198 } 196 }
199 197
200 TEST(UseCounterTest, RecordingExtensions) { 198 TEST(UseCounterTest, RecordingExtensions) {
201 UseCounter use_counter(UseCounter::kExtensionContext); 199 UseCounter use_counter(UseCounter::kExtensionContext);
202 HistogramBasicTest<UseCounter::Feature>( 200 HistogramBasicTest<WebFeature>(
203 kExtensionFeaturesHistogramName, kLegacyFeaturesHistogramName, 201 kExtensionFeaturesHistogramName, kLegacyFeaturesHistogramName,
204 UseCounter::kFetch, UseCounter::kFetchBodyStream, 202 WebFeature::kFetch, WebFeature::kFetchBodyStream,
205 [&](UseCounter::Feature feature) -> bool { 203 [&](WebFeature feature) -> bool {
206 return use_counter.HasRecordedMeasurement(feature); 204 return use_counter.HasRecordedMeasurement(feature);
207 }, 205 },
208 [&](UseCounter::Feature feature) { 206 [&](WebFeature feature) { use_counter.RecordMeasurement(feature); },
209 use_counter.RecordMeasurement(feature); 207 [](WebFeature feature) -> int { return static_cast<int>(feature); },
210 },
211 [](UseCounter::Feature feature) -> int { return feature; },
212 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kExtensionUrl); 208 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kExtensionUrl);
213 } 209 }
214 210
215 TEST(UseCounterTest, SVGImageContextFeatures) { 211 TEST(UseCounterTest, SVGImageContextFeatures) {
216 UseCounter use_counter(UseCounter::kSVGImageContext); 212 UseCounter use_counter(UseCounter::kSVGImageContext);
217 HistogramBasicTest<UseCounter::Feature>( 213 HistogramBasicTest<WebFeature>(
218 kSVGFeaturesHistogramName, kLegacyFeaturesHistogramName, 214 kSVGFeaturesHistogramName, kLegacyFeaturesHistogramName,
219 UseCounter::kSVGSMILAdditiveAnimation, 215 WebFeature::kSVGSMILAdditiveAnimation,
220 UseCounter::kSVGSMILAnimationElementTiming, 216 WebFeature::kSVGSMILAnimationElementTiming,
221 [&](UseCounter::Feature feature) -> bool { 217 [&](WebFeature feature) -> bool {
222 return use_counter.HasRecordedMeasurement(feature); 218 return use_counter.HasRecordedMeasurement(feature);
223 }, 219 },
224 [&](UseCounter::Feature feature) { 220 [&](WebFeature feature) { use_counter.RecordMeasurement(feature); },
225 use_counter.RecordMeasurement(feature); 221 [](WebFeature feature) -> int { return static_cast<int>(feature); },
226 },
227 [](UseCounter::Feature feature) -> int { return feature; },
228 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kSvgUrl); 222 [&](KURL kurl) { use_counter.DidCommitLoad(kurl); }, kSvgUrl);
229 } 223 }
230 224
231 TEST(UseCounterTest, SVGImageContextCSSProperties) { 225 TEST(UseCounterTest, SVGImageContextCSSProperties) {
232 UseCounter use_counter(UseCounter::kSVGImageContext); 226 UseCounter use_counter(UseCounter::kSVGImageContext);
233 HistogramBasicTest<CSSPropertyID>( 227 HistogramBasicTest<CSSPropertyID>(
234 kSVGCSSHistogramName, kLegacyCSSHistogramName, CSSPropertyFont, 228 kSVGCSSHistogramName, kLegacyCSSHistogramName, CSSPropertyFont,
235 CSSPropertyZoom, 229 CSSPropertyZoom,
236 [&](CSSPropertyID property) -> bool { 230 [&](CSSPropertyID property) -> bool {
237 return use_counter.IsCounted(property); 231 return use_counter.IsCounted(property);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 445
452 deprecation_.UnmuteForInspector(); 446 deprecation_.UnmuteForInspector();
453 Deprecation::WarnOnDeprecatedProperties(GetFrame(), property); 447 Deprecation::WarnOnDeprecatedProperties(GetFrame(), property);
454 // TODO: use the actually deprecated property to get a deprecation message. 448 // TODO: use the actually deprecated property to get a deprecation message.
455 EXPECT_FALSE(deprecation_.IsSuppressed(property)); 449 EXPECT_FALSE(deprecation_.IsSuppressed(property));
456 Deprecation::CountDeprecation(GetFrame(), feature); 450 Deprecation::CountDeprecation(GetFrame(), feature);
457 EXPECT_TRUE(use_counter_.HasRecordedMeasurement(feature)); 451 EXPECT_TRUE(use_counter_.HasRecordedMeasurement(feature));
458 } 452 }
459 453
460 } // namespace blink 454 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.cpp ('k') | third_party/WebKit/Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698