| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/webaudio/BaseAudioContext.h" | 5 #include "modules/webaudio/BaseAudioContext.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/DocumentUserGestureToken.h" | 8 #include "core/dom/DocumentUserGestureToken.h" |
| 9 #include "core/frame/FrameOwner.h" | 9 #include "core/frame/FrameOwner.h" |
| 10 #include "core/frame/FrameTypes.h" | 10 #include "core/frame/FrameTypes.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 double audioHardwareSampleRate() override { return 44100; } | 73 double audioHardwareSampleRate() override { return 44100; } |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 } // anonymous namespace | 76 } // anonymous namespace |
| 77 | 77 |
| 78 class BaseAudioContextTest : public ::testing::Test { | 78 class BaseAudioContextTest : public ::testing::Test { |
| 79 protected: | 79 protected: |
| 80 using AutoplayStatus = BaseAudioContext::AutoplayStatus; | 80 using AutoplayStatus = BaseAudioContext::AutoplayStatus; |
| 81 | 81 |
| 82 void SetUp() override { | 82 void SetUp() override { |
| 83 m_testPlatform.reset(new BaseAudioContextTestPlatform); |
| 83 m_dummyPageHolder = DummyPageHolder::create(); | 84 m_dummyPageHolder = DummyPageHolder::create(); |
| 84 m_dummyFrameOwner = DummyFrameOwner::create(); | 85 m_dummyFrameOwner = DummyFrameOwner::create(); |
| 85 document().updateSecurityOrigin( | 86 document().updateSecurityOrigin( |
| 86 SecurityOrigin::create("https", "example.com", 80)); | 87 SecurityOrigin::create("https", "example.com", 80)); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void TearDown() override { | 90 void TearDown() override { |
| 90 if (m_childFrame) { | 91 if (m_childFrame) { |
| 91 m_childDocumentLoader->detachFromFrame(); | 92 m_childDocumentLoader->detachFromFrame(); |
| 92 m_childDocumentLoader.clear(); | 93 m_childDocumentLoader.clear(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 audioContext->recordAutoplayStatus(); | 125 audioContext->recordAutoplayStatus(); |
| 125 } | 126 } |
| 126 | 127 |
| 127 private: | 128 private: |
| 128 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 129 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
| 129 Persistent<DummyFrameOwner> m_dummyFrameOwner; | 130 Persistent<DummyFrameOwner> m_dummyFrameOwner; |
| 130 | 131 |
| 131 Persistent<LocalFrame> m_childFrame; | 132 Persistent<LocalFrame> m_childFrame; |
| 132 Persistent<DocumentLoader> m_childDocumentLoader; | 133 Persistent<DocumentLoader> m_childDocumentLoader; |
| 133 | 134 |
| 134 BaseAudioContextTestPlatform m_testPlatform; | 135 ScopedTestingPlatformSupport<BaseAudioContextTestPlatform> m_testPlatform; |
| 135 }; | 136 }; |
| 136 | 137 |
| 137 TEST_F(BaseAudioContextTest, AutoplayMetrics_NoRestriction) { | 138 TEST_F(BaseAudioContextTest, AutoplayMetrics_NoRestriction) { |
| 138 HistogramTester histogramTester; | 139 HistogramTester histogramTester; |
| 139 | 140 |
| 140 BaseAudioContext* audioContext = | 141 BaseAudioContext* audioContext = |
| 141 BaseAudioContext::create(document(), ASSERT_NO_EXCEPTION); | 142 BaseAudioContext::create(document(), ASSERT_NO_EXCEPTION); |
| 142 recordAutoplayStatus(audioContext); | 143 recordAutoplayStatus(audioContext); |
| 143 | 144 |
| 144 histogramTester.expectTotalCount(kCrossOriginMetric, 0); | 145 histogramTester.expectTotalCount(kCrossOriginMetric, 0); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 audioContext->resumeContext(getScriptStateFrom(childDocument())); | 287 audioContext->resumeContext(getScriptStateFrom(childDocument())); |
| 287 rejectPendingResolvers(audioContext); | 288 rejectPendingResolvers(audioContext); |
| 288 recordAutoplayStatus(audioContext); | 289 recordAutoplayStatus(audioContext); |
| 289 | 290 |
| 290 histogramTester.expectBucketCount(kCrossOriginMetric, | 291 histogramTester.expectBucketCount(kCrossOriginMetric, |
| 291 AutoplayStatus::AutoplayStatusSucceeded, 1); | 292 AutoplayStatus::AutoplayStatusSucceeded, 1); |
| 292 histogramTester.expectTotalCount(kCrossOriginMetric, 1); | 293 histogramTester.expectTotalCount(kCrossOriginMetric, 1); |
| 293 } | 294 } |
| 294 | 295 |
| 295 } // namespace blink | 296 } // namespace blink |
| OLD | NEW |