| 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" | |
| 7 #include "core/frame/UseCounter.h" | 6 #include "core/frame/UseCounter.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" |
| 11 #include "platform/weborigin/KURL.h" | 11 #include "platform/weborigin/KURL.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 // Note that the new histogram names will change once the semantics stabilize; | 15 // Note that the new histogram names will change once the semantics stabilize; |
| 16 const char* const kFeaturesHistogramName = "Blink.UseCounter.Features"; | 16 const char* const kFeaturesHistogramName = "Blink.UseCounter.Features"; |
| 17 const char* const kCSSHistogramName = "Blink.UseCounter.CSSProperties"; | 17 const char* const kCSSHistogramName = "Blink.UseCounter.CSSProperties"; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 useCounter.recordMeasurement(UseCounter::Fetch); | 345 useCounter.recordMeasurement(UseCounter::Fetch); |
| 346 useCounter.count(HTMLStandardMode, CSSPropertyFontWeight); | 346 useCounter.count(HTMLStandardMode, CSSPropertyFontWeight); |
| 347 expectHistograms(histogramTester, 3, UseCounter::Fetch, 4, | 347 expectHistograms(histogramTester, 3, UseCounter::Fetch, 4, |
| 348 CSSPropertyFontWeight, 4); | 348 CSSPropertyFontWeight, 4); |
| 349 } | 349 } |
| 350 | 350 |
| 351 class DeprecationTest : public ::testing::Test { | 351 class DeprecationTest : public ::testing::Test { |
| 352 public: | 352 public: |
| 353 DeprecationTest() | 353 DeprecationTest() |
| 354 : m_dummy(DummyPageHolder::create()), | 354 : m_dummy(DummyPageHolder::create()), |
| 355 m_deprecation(m_dummy->page().frameHost().deprecation()), | 355 m_deprecation(m_dummy->page().deprecation()), |
| 356 m_useCounter(m_dummy->page().frameHost().useCounter()) {} | 356 m_useCounter(m_dummy->page().useCounter()) {} |
| 357 | 357 |
| 358 protected: | 358 protected: |
| 359 LocalFrame* frame() { return &m_dummy->frame(); } | 359 LocalFrame* frame() { return &m_dummy->frame(); } |
| 360 | 360 |
| 361 std::unique_ptr<DummyPageHolder> m_dummy; | 361 std::unique_ptr<DummyPageHolder> m_dummy; |
| 362 Deprecation& m_deprecation; | 362 Deprecation& m_deprecation; |
| 363 UseCounter& m_useCounter; | 363 UseCounter& m_useCounter; |
| 364 }; | 364 }; |
| 365 | 365 |
| 366 TEST_F(DeprecationTest, InspectorDisablesDeprecation) { | 366 TEST_F(DeprecationTest, InspectorDisablesDeprecation) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 390 | 390 |
| 391 m_deprecation.unmuteForInspector(); | 391 m_deprecation.unmuteForInspector(); |
| 392 Deprecation::warnOnDeprecatedProperties(frame(), property); | 392 Deprecation::warnOnDeprecatedProperties(frame(), property); |
| 393 // TODO: use the actually deprecated property to get a deprecation message. | 393 // TODO: use the actually deprecated property to get a deprecation message. |
| 394 EXPECT_FALSE(m_deprecation.isSuppressed(property)); | 394 EXPECT_FALSE(m_deprecation.isSuppressed(property)); |
| 395 Deprecation::countDeprecation(frame(), feature); | 395 Deprecation::countDeprecation(frame(), feature); |
| 396 EXPECT_TRUE(m_useCounter.hasRecordedMeasurement(feature)); | 396 EXPECT_TRUE(m_useCounter.hasRecordedMeasurement(feature)); |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace blink | 399 } // namespace blink |
| OLD | NEW |