| OLD | NEW |
| 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/FrameHost.h" | 6 #include "core/frame/FrameHost.h" |
| 7 #include "core/frame/UseCounter.h" | 7 #include "core/frame/UseCounter.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 "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyZoom), | 180 UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyZoom), |
| 181 1); | 181 1); |
| 182 histogramTester.expectBucketCount(kLegacyCSSHistogramName, 1, 2); | 182 histogramTester.expectBucketCount(kLegacyCSSHistogramName, 1, 2); |
| 183 histogramTester.expectTotalCount(kLegacyCSSHistogramName, 5); | 183 histogramTester.expectTotalCount(kLegacyCSSHistogramName, 5); |
| 184 | 184 |
| 185 // None of this should update any of the SVG histograms | 185 // None of this should update any of the SVG histograms |
| 186 histogramTester.expectTotalCount(kSVGFeaturesHistogramName, 0); | 186 histogramTester.expectTotalCount(kSVGFeaturesHistogramName, 0); |
| 187 histogramTester.expectTotalCount(kSVGCSSHistogramName, 0); | 187 histogramTester.expectTotalCount(kSVGCSSHistogramName, 0); |
| 188 } | 188 } |
| 189 | 189 |
| 190 TEST(UseCounterTest, SVGImageContext) { | 190 // Failing on Android: crbug.com/667913 |
| 191 #if OS(ANDROID) |
| 192 #define MAYBE_SVGImageContext DISABLED_SVGImageContext |
| 193 #else |
| 194 #define MAYBE_SVGImageContext SVGImageContext |
| 195 #endif |
| 196 |
| 197 TEST(UseCounterTest, MAYBE_SVGImageContext) { |
| 191 UseCounter useCounter(UseCounter::SVGImageContext); | 198 UseCounter useCounter(UseCounter::SVGImageContext); |
| 192 HistogramTester histogramTester; | 199 HistogramTester histogramTester; |
| 193 | 200 |
| 194 // Verify that SVGImage related feature counters get recorded in a separate | 201 // Verify that SVGImage related feature counters get recorded in a separate |
| 195 // histogram. | 202 // histogram. |
| 196 EXPECT_FALSE( | 203 EXPECT_FALSE( |
| 197 useCounter.hasRecordedMeasurement(UseCounter::SVGSMILAdditiveAnimation)); | 204 useCounter.hasRecordedMeasurement(UseCounter::SVGSMILAdditiveAnimation)); |
| 198 useCounter.recordMeasurement(UseCounter::SVGSMILAdditiveAnimation); | 205 useCounter.recordMeasurement(UseCounter::SVGSMILAdditiveAnimation); |
| 199 EXPECT_TRUE( | 206 EXPECT_TRUE( |
| 200 useCounter.hasRecordedMeasurement(UseCounter::SVGSMILAdditiveAnimation)); | 207 useCounter.hasRecordedMeasurement(UseCounter::SVGSMILAdditiveAnimation)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 229 UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyFont), | 236 UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyFont), |
| 230 1); | 237 1); |
| 231 histogramTester.expectBucketCount(kLegacyCSSHistogramName, 1, 1); | 238 histogramTester.expectBucketCount(kLegacyCSSHistogramName, 1, 1); |
| 232 histogramTester.expectTotalCount(kLegacyCSSHistogramName, 2); | 239 histogramTester.expectTotalCount(kLegacyCSSHistogramName, 2); |
| 233 | 240 |
| 234 // None of this should update the non-legacy non-SVG histograms | 241 // None of this should update the non-legacy non-SVG histograms |
| 235 histogramTester.expectTotalCount(kCSSHistogramName, 0); | 242 histogramTester.expectTotalCount(kCSSHistogramName, 0); |
| 236 histogramTester.expectTotalCount(kFeaturesHistogramName, 0); | 243 histogramTester.expectTotalCount(kFeaturesHistogramName, 0); |
| 237 } | 244 } |
| 238 | 245 |
| 246 // Failing on Android: crbug.com/667913 |
| 247 #if OS(ANDROID) |
| 248 #define MAYBE_InspectorDisablesMeasurement DISABLED_InspectorDisablesMeasurement |
| 249 #else |
| 250 #define MAYBE_InspectorDisablesMeasurement InspectorDisablesMeasurement |
| 251 #endif |
| 252 |
| 239 TEST(UseCounterTest, InspectorDisablesMeasurement) { | 253 TEST(UseCounterTest, InspectorDisablesMeasurement) { |
| 240 UseCounter useCounter; | 254 UseCounter useCounter; |
| 241 HistogramTester histogramTester; | 255 HistogramTester histogramTester; |
| 242 | 256 |
| 243 // The specific feature we use here isn't important. | 257 // The specific feature we use here isn't important. |
| 244 UseCounter::Feature feature = UseCounter::Feature::SVGSMILElementInDocument; | 258 UseCounter::Feature feature = UseCounter::Feature::SVGSMILElementInDocument; |
| 245 CSSPropertyID property = CSSPropertyFontWeight; | 259 CSSPropertyID property = CSSPropertyFontWeight; |
| 246 CSSParserMode parserMode = HTMLStandardMode; | 260 CSSParserMode parserMode = HTMLStandardMode; |
| 247 | 261 |
| 248 EXPECT_FALSE(useCounter.hasRecordedMeasurement(feature)); | 262 EXPECT_FALSE(useCounter.hasRecordedMeasurement(feature)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 338 |
| 325 m_deprecation.unmuteForInspector(); | 339 m_deprecation.unmuteForInspector(); |
| 326 Deprecation::warnOnDeprecatedProperties(frame(), property); | 340 Deprecation::warnOnDeprecatedProperties(frame(), property); |
| 327 // TODO: use the actually deprecated property to get a deprecation message. | 341 // TODO: use the actually deprecated property to get a deprecation message. |
| 328 EXPECT_FALSE(m_deprecation.isSuppressed(property)); | 342 EXPECT_FALSE(m_deprecation.isSuppressed(property)); |
| 329 Deprecation::countDeprecation(frame(), feature); | 343 Deprecation::countDeprecation(frame(), feature); |
| 330 EXPECT_TRUE(m_useCounter.hasRecordedMeasurement(feature)); | 344 EXPECT_TRUE(m_useCounter.hasRecordedMeasurement(feature)); |
| 331 } | 345 } |
| 332 | 346 |
| 333 } // namespace blink | 347 } // namespace blink |
| OLD | NEW |