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

Unified Diff: third_party/WebKit/Source/core/frame/UseCounterTest.cpp

Issue 2678143003: Move CSS animations use counters to UseCounter (Closed)
Patch Set: Replace FIXME with test expectation file Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/UseCounterTest.cpp
diff --git a/third_party/WebKit/Source/core/frame/UseCounterTest.cpp b/third_party/WebKit/Source/core/frame/UseCounterTest.cpp
index 6db3efa66c6950eb0f032698c32d1cdd15168eb5..25e25eba22ab2213bdf96dc859ae8da2fbf2f1b9 100644
--- a/third_party/WebKit/Source/core/frame/UseCounterTest.cpp
+++ b/third_party/WebKit/Source/core/frame/UseCounterTest.cpp
@@ -12,13 +12,18 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace {
-// Note that the new histogram names will change once the semantics stabilize;
const char* const kFeaturesHistogramName = "Blink.UseCounter.Features";
const char* const kCSSHistogramName = "Blink.UseCounter.CSSProperties";
+const char* const kAnimatedCSSHistogramName =
+ "Blink.UseCounter.AnimatedCSSProperties";
+
const char* const kSVGFeaturesHistogramName =
"Blink.UseCounter.SVGImage.Features";
const char* const kSVGCSSHistogramName =
"Blink.UseCounter.SVGImage.CSSProperties";
+const char* const kSVGAnimatedCSSHistogramName =
+ "Blink.UseCounter.SVGImage.AnimatedCSSProperties";
+
const char* const kLegacyFeaturesHistogramName = "WebCore.FeatureObserver";
const char* const kLegacyCSSHistogramName =
"WebCore.FeatureObserver.CSSProperties";
@@ -45,12 +50,16 @@ void histogramBasicTest(const std::string& histogram,
count(item);
EXPECT_TRUE(counted(item));
histogramTester.expectUniqueSample(histogram, histogramMap(item), 1);
- histogramTester.expectTotalCount(legacyHistogram, 0);
+ if (!legacyHistogram.empty()) {
+ histogramTester.expectTotalCount(legacyHistogram, 0);
+ }
// Test that repeated measurements have no effect
count(item);
histogramTester.expectUniqueSample(histogram, histogramMap(item), 1);
- histogramTester.expectTotalCount(legacyHistogram, 0);
+ if (!legacyHistogram.empty()) {
+ histogramTester.expectTotalCount(legacyHistogram, 0);
+ }
// Test recording a different sample
EXPECT_FALSE(counted(secondItem));
@@ -59,7 +68,9 @@ void histogramBasicTest(const std::string& histogram,
histogramTester.expectBucketCount(histogram, histogramMap(item), 1);
histogramTester.expectBucketCount(histogram, histogramMap(secondItem), 1);
histogramTester.expectTotalCount(histogram, 2);
- histogramTester.expectTotalCount(legacyHistogram, 0);
+ if (!legacyHistogram.empty()) {
+ histogramTester.expectTotalCount(legacyHistogram, 0);
+ }
// After a page load, the histograms will be updated, even when the URL
// scheme is internal
@@ -70,11 +81,13 @@ void histogramBasicTest(const std::string& histogram,
histogramTester.expectTotalCount(histogram, 3);
// And verify the legacy histogram now looks the same
- histogramTester.expectBucketCount(legacyHistogram, histogramMap(item), 1);
- histogramTester.expectBucketCount(legacyHistogram, histogramMap(secondItem),
- 1);
- histogramTester.expectBucketCount(legacyHistogram, pageVisitBucket, 1);
- histogramTester.expectTotalCount(legacyHistogram, 3);
+ if (!legacyHistogram.empty()) {
+ histogramTester.expectBucketCount(legacyHistogram, histogramMap(item), 1);
+ histogramTester.expectBucketCount(legacyHistogram, histogramMap(secondItem),
+ 1);
+ histogramTester.expectBucketCount(legacyHistogram, pageVisitBucket, 1);
+ histogramTester.expectTotalCount(legacyHistogram, 3);
+ }
// Now a repeat measurement should get recorded again, exactly once
EXPECT_FALSE(counted(item));
@@ -86,11 +99,13 @@ void histogramBasicTest(const std::string& histogram,
// And on the next page load, the legacy histogram will again be updated
didCommitLoad(URLTestHelpers::toKURL(url));
- histogramTester.expectBucketCount(legacyHistogram, histogramMap(item), 2);
- histogramTester.expectBucketCount(legacyHistogram, histogramMap(secondItem),
- 1);
- histogramTester.expectBucketCount(legacyHistogram, pageVisitBucket, 2);
- histogramTester.expectTotalCount(legacyHistogram, 5);
+ if (!legacyHistogram.empty()) {
+ histogramTester.expectBucketCount(legacyHistogram, histogramMap(item), 2);
+ histogramTester.expectBucketCount(legacyHistogram, histogramMap(secondItem),
+ 1);
+ histogramTester.expectBucketCount(legacyHistogram, pageVisitBucket, 2);
+ histogramTester.expectTotalCount(legacyHistogram, 5);
+ }
for (size_t i = 0; i < unaffectedHistograms.size(); ++i) {
histogramTester.expectTotalCount(unaffectedHistograms[i], 0);
@@ -139,6 +154,23 @@ TEST(UseCounterTest, RecordingCSSProperties) {
"https://dummysite.com/", 1 /* page visit bucket */);
}
+TEST(UseCounterTest, RecordingAnimatedCSSProperties) {
+ UseCounter useCounter;
+ histogramBasicTest<CSSPropertyID>(
+ kAnimatedCSSHistogramName, "",
+ {kSVGCSSHistogramName, kSVGAnimatedCSSHistogramName}, CSSPropertyOpacity,
Rick Byers 2017/02/25 15:10:57 worth adding this new histogram to the list of una
+ CSSPropertyVariable,
+ [&](CSSPropertyID property) -> bool {
+ return useCounter.isCountedAnimatedCSS(property);
+ },
+ [&](CSSPropertyID property) { useCounter.countAnimatedCSS(property); },
+ [](CSSPropertyID property) -> int {
+ return UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(property);
+ },
+ [&](KURL kurl) { useCounter.didCommitLoad(kurl); },
+ "https://dummysite.com/", 1 /* page visit bucket */);
+}
+
// Failing on Android: crbug.com/667913
#if OS(ANDROID)
#define MAYBE_SVGImageContextFeatures DISABLED_SVGImageContextFeatures
@@ -184,6 +216,24 @@ TEST(UseCounterTest, SVGImageContextCSSProperties) {
1 /* page visit bucket */);
}
+TEST(UseCounterTest, SVGImageContextAnimatedCSSProperties) {
+ UseCounter useCounter(UseCounter::SVGImageContext);
+ histogramBasicTest<CSSPropertyID>(
+ kSVGAnimatedCSSHistogramName, "",
+ {kCSSHistogramName, kAnimatedCSSHistogramName}, CSSPropertyOpacity,
+ CSSPropertyVariable,
+ [&](CSSPropertyID property) -> bool {
+ return useCounter.isCountedAnimatedCSS(property);
+ },
+ [&](CSSPropertyID property) { useCounter.countAnimatedCSS(property); },
+ [](CSSPropertyID property) -> int {
+ return UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(property);
+ },
+ [&](KURL kurl) { useCounter.didCommitLoad(kurl); }, "about:blank",
+ // In practice SVGs always appear to be loaded with an about:blank URL
+ 1 /* page visit bucket */);
+}
+
// Failing on Android: crbug.com/667913
#if OS(ANDROID)
#define MAYBE_InspectorDisablesMeasurement DISABLED_InspectorDisablesMeasurement

Powered by Google App Engine
This is Rietveld 408576698