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_oldMockScrollbarSetting = Settings::mockScrollbarsEnabled(); |
| 84 Settings::setMockScrollbarsEnabled(true); |
83 m_dummyPageHolder = DummyPageHolder::create(); | 85 m_dummyPageHolder = DummyPageHolder::create(); |
84 m_dummyFrameOwner = DummyFrameOwner::create(); | 86 m_dummyFrameOwner = DummyFrameOwner::create(); |
85 document().updateSecurityOrigin( | 87 document().updateSecurityOrigin( |
86 SecurityOrigin::create("https", "example.com", 80)); | 88 SecurityOrigin::create("https", "example.com", 80)); |
87 } | 89 } |
88 | 90 |
89 void TearDown() override { | 91 void TearDown() override { |
| 92 Settings::setMockScrollbarsEnabled(m_oldMockScrollbarSetting); |
90 if (m_childFrame) { | 93 if (m_childFrame) { |
91 m_childDocumentLoader->detachFromFrame(); | 94 m_childDocumentLoader->detachFromFrame(); |
92 m_childDocumentLoader.clear(); | 95 m_childDocumentLoader.clear(); |
93 m_childFrame->detach(FrameDetachType::Remove); | 96 m_childFrame->detach(FrameDetachType::Remove); |
94 } | 97 } |
95 } | 98 } |
96 | 99 |
97 void createChildFrame() { | 100 void createChildFrame() { |
98 m_childFrame = LocalFrame::create( | 101 m_childFrame = LocalFrame::create( |
99 MockCrossOriginFrameLoaderClient::create(document().frame()), | 102 MockCrossOriginFrameLoaderClient::create(document().frame()), |
(...skipping 25 matching lines...) Expand all Loading... |
125 audioContext->recordAutoplayStatus(); | 128 audioContext->recordAutoplayStatus(); |
126 } | 129 } |
127 | 130 |
128 private: | 131 private: |
129 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 132 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
130 Persistent<DummyFrameOwner> m_dummyFrameOwner; | 133 Persistent<DummyFrameOwner> m_dummyFrameOwner; |
131 | 134 |
132 Persistent<LocalFrame> m_childFrame; | 135 Persistent<LocalFrame> m_childFrame; |
133 Persistent<DocumentLoader> m_childDocumentLoader; | 136 Persistent<DocumentLoader> m_childDocumentLoader; |
134 | 137 |
| 138 bool m_oldMockScrollbarSetting; |
135 BaseAudioContextTestPlatform m_testPlatform; | 139 BaseAudioContextTestPlatform m_testPlatform; |
136 }; | 140 }; |
137 | 141 |
138 TEST_F(BaseAudioContextTest, AutoplayMetrics_NoRestriction) { | 142 TEST_F(BaseAudioContextTest, AutoplayMetrics_NoRestriction) { |
139 HistogramTester histogramTester; | 143 HistogramTester histogramTester; |
140 | 144 |
141 BaseAudioContext* audioContext = | 145 BaseAudioContext* audioContext = |
142 BaseAudioContext::create(document(), ASSERT_NO_EXCEPTION); | 146 BaseAudioContext::create(document(), ASSERT_NO_EXCEPTION); |
143 recordAutoplayStatus(audioContext); | 147 recordAutoplayStatus(audioContext); |
144 | 148 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 audioContext->resumeContext(getScriptStateFrom(childDocument())); | 291 audioContext->resumeContext(getScriptStateFrom(childDocument())); |
288 rejectPendingResolvers(audioContext); | 292 rejectPendingResolvers(audioContext); |
289 recordAutoplayStatus(audioContext); | 293 recordAutoplayStatus(audioContext); |
290 | 294 |
291 histogramTester.expectBucketCount(kCrossOriginMetric, | 295 histogramTester.expectBucketCount(kCrossOriginMetric, |
292 AutoplayStatus::AutoplayStatusSucceeded, 1); | 296 AutoplayStatus::AutoplayStatusSucceeded, 1); |
293 histogramTester.expectTotalCount(kCrossOriginMetric, 1); | 297 histogramTester.expectTotalCount(kCrossOriginMetric, 1); |
294 } | 298 } |
295 | 299 |
296 } // namespace blink | 300 } // namespace blink |
OLD | NEW |